Subproject not getting Settings object


I’m having trouble referencing properties set in my root’s file. It seems like during the initialization phase of the build the Settings object being passed to my subproject is not complete.

My directory hierarchy looks like this:

Root |–settings.gradle |–build.gradle |– | |–CoreProject

|–build.gradle |–Plugins




include 'CoreProject'
include 'Plugins:PluginA'


Both “CoreProject/build.gradle” and “Plugins/PluginA/build.gradle” contain:

// ...
dependencies { compile 'log4j:log4j:$log4jVersion' }
// ...

This works fine for the core project, but for the plugin Gradle doesn’t substitute the property and tries to find the version $log4jVersion, not 1.2.16. I tried to print out $settingsDir and $rootDir in both build scripts, but Gradle could not find them in the plugin project.

Any ideas why my plugin project cannot reference the Settings object?

Groovy only performs string interpolation for double quoted string literals.

Sorry, the tree looks like this:

Root |–settings.gradle |–build.gradle |– | |–/CoreProject |–build.gradle |–/Plugins |----/PluginA |------build.gradle

Putting the version numbers in double-quoted strings didn’t change anything. The CoreProject interprets the properties fine. As I said, the PluginA project is not given a Settings object (I cannot call $rootDir r $settingsDir in PluginA’s build.gradle). It seems the Settings is not initialized correctly for PluginA, which would mean the properties would not be inherited.

I am using Gradle 1.10

With single quoted strings, it will never work, no matter which script. The ‘Settings’ object is the object underlying ‘settings.gradle’, and I don’t see how it relates to the problem at hand. ‘rootDir’ is shorthand for ‘project.rootDir’, and is available in every build script. ‘settingsDir’ is only available in ‘settings.gradle’ (unless you defined your own property with that name). Properties specified in a top-level ‘’ are available in every build script (just double-checked for a multi-project build). If you need more help with this, please provide a self-contained minimal reproducible example.

Okay, thanks for clarifying the Settings object. I’m new to Gradle, and I was reading too much into section 55.4 of the user guide (