2

I am just trying to assign the value from the parameter I pass to a gradle task. For example I run this task gradlew assembleTestApp -PtestParam=testVarible

in my build.gradle i want to assign the value to a variable

def var = $testParam

above is not working.

1 Answer 1

2

Gradle uses the $ only to ineterpolate variable values inside a string. To use a parameter as a regular variable, you do not need the $sign.

def var = testParam
println "var: " + var + " testParam: " + testParam
println "var: $var testParam: $testParam"

results in:

gradle -q -PtestParam=foo
  var: foo testParam: foo
  var: foo testParam: foo
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.