Closed ravi-b-m closed 7 years ago
The only way I fixed my problem is by using project.delete('gradle.properties')
in my prep task..
Sorry accidentally closed it... still does not work :)
The first thing that catches my attention is that you are trying to delete and recreate the gradle.properties
file. You probably shouldn't do this, as it defeats the purpose of this plugin. By using this plugin you can override the properties in gradle.properties
with environment specific values in the various 'gradle-\<env>.properties' files. The kinds of files you'd typically delete and recreate from templates are files that need to be included in your build that might need to change from environment to environment, such as log4j.properties, Spring application.properties files, etc.
This may also explain why requiredProteries
isn't working as you expect. If I unserstand your setup correctly you have a property with a value in gradle.properties from your last build, but that property is not in the particular 'gradle-\<env>.properties' for this build. In this case, Gradle will do the following:
gradle.properties
still exists with the values from the last run.prep
task. At this point, the property in question has a value (from the not yet deleted gradle.properties file
), so requiredProperties
is happy.gradle.properties
file, though it will probablt be incorrect.In my builds, I have a clean
task that removes generated files, and a prep
task to regenerate them, but I don't have a dependency between them because prep should be out of date when Gradle sees that a property value has changed. As for build logic, I'd put properties in gradle.properties
files that are likely to be standard across environments, such as mlAppname
or mlRestPort
, or mlAdminUserName
. For properties that are different, like mlAdminUserPassword
, I'd put the production value into gradle-prod.properties
, the test value into gradle-test.properties
, etc. If, for some reason, the test environment needed a different rest port than the standard, I could redefine mlRestPort
in gradle-test.properties
as well.
I hope this helps.
If the properties files that is being created already exists and when I run the
prep
task for a different env and the env-properties files does not have some of the "required Properties", the plugin does not do the check. So I tried thedelete
task first and then prep task usingmustRunAfter
and alsodependsOn
, thedelete
task is not deleting the file whenprep
task is called, but deletes the file when I call thedelete
separately. Am I missing something here ? Following is how I am doing