Multiple start scripts using Gradle
Unfortunately the gradle application plugin does not provide first class support for multiple executable scripts.
Luckily though, because gradle scripts are groovy, you can change what the application plugin does reasonably easily.
The documentation for the Application plugin show that the startScripts
task is of type CreateStartScripts, so try creating yourself a second task of the same type
task schedulerScripts(type: CreateStartScripts) {
mainClassName = "foo.bar.scheduler.SchedulerMain"
applicationName = "scheduler"
outputDir = new File(project.buildDir, 'scripts')
classpath = jar.outputs.files + project.configurations.runtime
}
then include the output of that task in your distribution
applicationDistribution.into("bin") {
from(schedulerScripts)
fileMode = 0755
}
It might be better to use JavaExec
task scheduler(type: JavaExec) {
main = "foo.bar.scheduler.SchedulerMain"
classpath = sourceSets.main.runtimeClasspath
}
task web(type: JavaExec) {
main = "SpringLauncher"
classpath = sourceSets.main.runtimeClasspath
}
You can then run gradle scheduler web