Using command line properties in the configuration phase


(Eric Francis ) #1

I’m trying to do ./gradlew myTask -PmyProp=foo

I want to access $myProp inside of a copy task. Is there a way to do this?

task myTask(type: Copy) {
  from: "${myProp}/"
  into: "${myProp}/bar"
}

Please link to the relevant document is this problem has already been solved.


(Lance Java) #2

There’s a few options:

  • ${myProp}
  • ${properties.myProp}
  • ${project.properties.myProp}
  • ${gradle.startParameter.projectProperties.myProp}
  • ${project.gradle.startParameter.projectProperties.myProp}