I\'m using the gradle \'application\' plugin to start my application. This works well. Now I want to add the option to start a different main class in the same project. Can I ch
Use javaExec
task to handle it :
task run(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
if (project.hasProperty('first')){
if (chooseMain == 'Main1'){
main = 'application.Main1'
} else if (chooseMain == 'second'){
main = 'application.Main2'
}
} else {
println 'please pass the main name'
}
}
And from the command line pass your option in that way :
gradle run -PchooseMain=first