Reputation: 901
I'm trying to access a property that's set in ~/.gradle/gradle.properties from an init script distributed inside a custom gradle wrapper.
companyLogin=test
println "Company Username: " + companyLogin
This fails: "Could not find property 'companyLogin' on build.
task printCompanyLogin {
println "Company Username: " + companyLogin
}
This works fine (I have to comment out the init script one)
I am making sure I execute with $gradlew .
I've also tried putting companyLogin=test in the project root gradle.properties without success. Is this intentional behavior of Gradle? I don't recall seeing it in the manual, but I've not had as much time with Gradle in the last 6 months or so as I'd like.
Anyone have any suggestions?
Upvotes: 5
Views: 3203
Reputation: 901
The issue was one of system properties vs project properties.
Init scripts run before the project is created, and therefor cannot access project properties.
Situation resolved with the following settings:
systemProp.company.login=test
final companyLogin = System.properties["company.login"]
Upvotes: 5