[GRADLE-2475] System properties can only be passed to buildSrc build if there is an irrelevant settings.gradle above Created: 12/Sep/12  Updated: 22/Mar/16  Resolved: 22/Mar/16

Status: Resolved
Project: Gradle
Affects Version/s: 1.2
Fix Version/s: 2.13-rc-1

Type: Bug
Reporter: Luke Daley Assignee: Pepper Lebeck-Jobe
Resolution: Fixed Votes: 1


 Description   

Create a project with a buildSrc/build.gradle…

println "property: " + System.properties["prop"]

Running gradle -Dprop=foo will give you property: null.

If you create a settings file at ../settings.gradle that does not include the original project and rerun gradle -Dprop=foo you will get property: foo.

It's not clear what the expected behaviour is (i.e. can you pass system properties to buildSrc builds?), but this difference in behaviour is weird.



 Comments   
Comment by Luke Daley [ 13/Sep/12 ]

Forum topic: http://forums.gradle.org/gradle/topics/pass_properties_to_buildsrc_build_part

Comment by Eric Deandrea [ 18/Mar/14 ]

I would like to see this fixed. I'm trying to control the base url of the maven repository via a -D parameter & our buildSrc project applies the same custom plugins as the main build which knows how to set up the correct maven repositories to use for the build. Why should the buildSrc project behave any differently? Shouldn't the same custom plugin my gradle distro has be able to be applied in the buildSrc project as in the main project itself?

Comment by Ryan Ernst [ 17/Mar/16 ]

I tracked this down and opened a PR to fix it: https://github.com/gradle/gradle/pull/597

Generated at Wed Jun 30 12:22:56 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.