1

To start Java program, I can pass arguments like:

java Main arg1 arg2 arg3

What are the good ways to do that in gradle command line:

gradle startProgram arg1 arg2 arg3

And this is in build.gradle:

task startProgram(dependsOn: 'classes', type: JavaExec) {
    main = 'Main'
    classpath = sourceSets.main.runtimeClasspath
    systemProperties = System.properties
}
evanwong
  • 5,054
  • 3
  • 31
  • 44
  • possible duplicate of [How to pass arguments from command line to gradle](http://stackoverflow.com/questions/11696521/how-to-pass-arguments-from-command-line-to-gradle) – Joshua Goldberg Jul 02 '15 at 21:05

1 Answers1

1

Best way is to use java system properties (-D switch) but these are more 'global'. Instead You can use simple properties (-P switch) and get the passed values using instance of Project class.

Opal
  • 81,889
  • 28
  • 189
  • 210