We have a Gradle project using the java plugin that has a couple of command line tools it needs to build. The project is just packaged up into a jar with its dependencies. We\
You can always drop down to the task level and declare/configure/wire the necessary tasks yourself, or declare additional tasks on top of what apply plugin: "application"
provides. See the application plugin chapter in the Gradle user guide for which related tasks are available.
Here's one way to generate multiple start scripts with Gradle's application
plugin:
mainClassName = "com.example.PrimaryEntryPoint"
startScripts {
applicationName = 'primary'
}
// For convenience, define a map of additional start scripts.
// Key is script name and value is Java class.
def extraStartScripts = [
'secondary' : 'com.example.SecondaryEntryPoint',
'tertiary' : 'com.example.TertiaryEntryPoint'
]
// Create a task for each additional entry point script.
extraStartScripts.each { scriptName, driverClass ->
task(scriptName + "-script",
group: 'CLI Script Generation',
type: CreateStartScripts) {
mainClassName = driverClass
applicationName = scriptName
outputDir = startScripts.outputDir
classpath = startScripts.classpath
}
}
// Include the additional start scripts in the distribution
applicationDistribution.into("bin") {
from(tasks.withType(CreateStartScripts))
fileMode = 0755
}