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
Here's how you can generate multiple start scripts if you need to package your apps
application {
applicationName = "myapp"
mainClassName = "my.Main1"
}
tasks.named("startScripts") {
applicationName = "myapp-main1"
}
val main2StartScripts by tasks.register("main2StartScripts", CreateStartScripts::class) {
applicationName = "myapp-main2"
outputDir = file("build/scripts") // By putting these scripts here, they will be picked up automatically by the installDist task
mainClassName = "my.Main2"
classpath = project.tasks.getAt(JavaPlugin.JAR_TASK_NAME).outputs.files.plus(project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)) // I took this from ApplicationPlugin.java:129
}
tasks.named("installDist") {
dependsOn(main2StartScripts)
}