В зависимости от пользователя из файла загружается другой набор свойств.
ext.userProps = new Properties(defaults.userProperties)
file("env/configurations/user_${userName}.properties").withInputStream { userProps.load(it) }
- Пользователь запускает первую сборку -> все отлично работает
- Пользователь изменяет свойство в файле
- Запускает сборку снова -> gradle по-прежнему использует старые свойства
Обходной путь: запуск gradlew clean после каждого изменения файла свойств. Тогда это работает как ожидалось.
Как я могу напрямую указать gradle: не кэшировать загруженные свойства?
Редактировать: Свойства затем используются для замены строк в файлах конфигурации.
ext.dbconfig = ""
ext.siteProps = new Properties(defaults.siteProperties)
file("env/configurations/site_${siteName}.properties").withInputStream { siteProps.load(it) }
ext.userProps = new Properties(defaults.userProperties)
file("env/configurations/user_${userName}.properties").withInputStream { userProps.load(it) }
ext.tokens = [
// WEB-INF/web.xml
smtpHostName : "${siteProps.'mail.smtp.host'}".toString(),
smtpPassword : "${siteProps.'mail.smtp.password'}".toString(),
hibernateSchemaCreation : "${userProps.'hibernate.schema.creation'}".toString(),
documentExportMode : "${userProps.'document.exportMode'}".toString(),
multipartConfigLocation : "${siteProps.'multipartConfigLocation'}".toString(),
// META-INF/context.xml">
'hibernate.datasource.url': "${userProps.'hibernate.datasource.url'}".toString(),
'hibernate.dialect' : "${userProps.'hibernate.dialect'}".toString(),
'hibernate.connection.username' : "${userProps.'hibernate.connection.username'}".toString(),
'hibernate.connection.password' : "${userProps.'hibernate.connection.password'}".toString(),
'hibernate.connection.driver.class': "${userProps.'hibernate.connection.driver.class'}".toString(),
]