Closed rahulj closed 10 years ago
I'm not able to reproduce this problem. When I do a build, if there is a property in an environment file, it overrides values in gradle.properties.
Are you using the latest version of the plugin?
How are you invoking Gradle, and what are your environment files named?
I am using net.saliman:gradle-properties-plugin:1.1.1
I have following properties file:
gradle.properties
gradle-perf.properties
and I am invoking gradle as "gradle
One thing that is different is that I have added the gradle plugin along with properties file to parent module and the tasks that I am running are defined inside child/submodule.
I can reproduce this now - I don't do much with child projects...
The issue is that while Gradle itself seems to walk up the tree to find the gradle.properties file, the plugin does not walk up the tree to find gradle-
There is a workaround:
apply plugin: 'properties'
line in the parent project's build.gradle with:
allprojects { apply plugin: 'java' }
When I get some time, I'll work on an actual fix to the problem. I think it makes sense to require users to explicitly apply the plugin to the specific modules where it is needed/wanted rather than assume that the plugin should pass properties to child projects. But when the plugin is applied, it should use the same rules for locating environment specific files as Gradle itself uses to find the gradle.properties. file.
I have just released version 1.2.0 of the properties plugin. This version is now multi-project aware and will allow you to do what you were describing. The project's README.md has full details.
You will still need to explicitly apply the plugin to all projects where you want it, but once done, it will inherit properties from the parent project (regardless of whether or not the parent project applied the plugin),and you will be able to override them in a child project.
The artifacts should be available on Maven Central shortly.
Thank you for bringing this up,
Steve
works beautifully
I wanted to keep a default value for a property in gradle.properties, and override it for only few specific environments. Right now this is not possible, because once a property is defined in gradle.properties, all env specific properties files are ignored for that property.
Currently this can be achieved by making sure you don't have any property in gradle.properties which is not common across environments, which means even if there is just one environment which needs a different value, you will end up putting it in across all environment specific files.