Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Last active November 20, 2015 02:17
Show Gist options
  • Save diegopacheco/96e77130553523da1747 to your computer and use it in GitHub Desktop.
Save diegopacheco/96e77130553523da1747 to your computer and use it in GitHub Desktop.
How to make gradle / gradlew pass args to java class?
gradle execute -DmainClass=com.my.package.MainClassX -Dexec.args="arg1 arg2 arg3"
task execute (type:JavaExec) {
    main = System.getProperty("mainClass")
    classpath = sourceSets.main.runtimeClasspath 
    systemProperties System.getProperties()
    args System.getProperty("exec.args").split()    
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment