open class CreateStartScripts : ConventionTask
Creates start scripts for launching JVM applications.
Example:
task createStartScripts(type: CreateStartScripts) { outputDir = file('build/sample') mainClassName = 'org.gradle.test.Main' applicationName = 'myApp' classpath = files('path/to/some.jar') }
Note: the Gradle "application"
plugin adds a pre-configured task of this type named "startScripts"
.
The task generates separate scripts targeted at Microsoft Windows environments and UNIX-like environments (e.g. Linux, macOS). The actual generation is implemented by the #getWindowsStartScriptGenerator()
and #getUnixStartScriptGenerator()
properties, of type ScriptGenerator.
Example:
task createStartScripts(type: CreateStartScripts) { unixStartScriptGenerator = new CustomUnixStartScriptGenerator() windowsStartScriptGenerator = new CustomWindowsStartScriptGenerator() } class CustomUnixStartScriptGenerator implements ScriptGenerator { void generateScript(JavaAppStartScriptGenerationDetails details, Writer destination) { // implementation } } class CustomWindowsStartScriptGenerator implements ScriptGenerator { void generateScript(JavaAppStartScriptGenerationDetails details, Writer destination) { // implementation } }
The default generators are of the type org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator, with default templates. This templates can be changed via the org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator#setTemplate(org.gradle.api.resources.TextResource)
method.
The default implementations used by this task use Groovy's SimpleTemplateEngine to parse the template, with the following variables available:
applicationName
optsEnvironmentVar
exitEnvironmentVar
mainClassName
executableDir
defaultJvmOpts
appNameSystemProperty
appHomeRelativePath
classpath
Example:
task createStartScripts(type: CreateStartScripts) { unixStartScriptGenerator.template = resources.text.fromFile('customUnixStartScript.txt') windowsStartScriptGenerator.template = resources.text.fromFile('customWindowsStartScript.txt') }
CreateStartScripts()
Creates start scripts for launching JVM applications. Example:
Note: the Gradle The task generates separate scripts targeted at Microsoft Windows environments and UNIX-like environments (e.g. Linux, macOS). The actual generation is implemented by the Example:
The default generators are of the type org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator, with default templates. This templates can be changed via the The default implementations used by this task use Groovy's SimpleTemplateEngine to parse the template, with the following variables available:
Example:
|
open fun generate(): Unit |
|
open fun getApplicationName(): String
The application's name. |
|
open fun getClasspath(): FileCollection
The class path for the application. |
|
open fun getDefaultJvmOpts(): MutableIterable<String>
The application's default JVM options. Defaults to an empty list. |
|
open fun getExecutableDir(): String
The directory to write the scripts into in the distribution. |
|
open fun getExitEnvironmentVar(): String
The environment variable to use to control exit value (Windows only). |
|
open fun getMainClassName(): String
The main classname used to start the Java application. |
|
open fun getOptsEnvironmentVar(): String
The environment variable to use to provide additional options to the JVM. |
|
open fun getOutputDir(): File
The directory to write the scripts into. |
|
open fun getUnixScript(): File
Returns the full path to the Unix script. The target directory is represented by the output directory, the file name is the application name without a file extension. |
|
open fun getUnixStartScriptGenerator(): ScriptGenerator
The UNIX-like start script generator. Defaults to an implementation of org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator. |
|
open fun getWindowsScript(): File
Returns the full path to the Windows script. The target directory is represented by the output directory, the file name is the application name plus the file extension .bat. |
|
open fun getWindowsStartScriptGenerator(): ScriptGenerator
The Windows start script generator. Defaults to an implementation of org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator. |
|
open fun setApplicationName(applicationName: String): Unit |
|
open fun setClasspath(classpath: FileCollection): Unit |
|
open fun setDefaultJvmOpts(defaultJvmOpts: MutableIterable<String>): Unit |
|
open fun setExecutableDir(executableDir: String): Unit
The directory to write the scripts into in the distribution. |
|
open fun setExitEnvironmentVar(exitEnvironmentVar: String): Unit |
|
open fun setMainClassName(mainClassName: String): Unit |
|
open fun setOptsEnvironmentVar(optsEnvironmentVar: String): Unit |
|
open fun setOutputDir(outputDir: File): Unit |
|
open fun setUnixStartScriptGenerator(unixStartScriptGenerator: ScriptGenerator): Unit |
|
open fun setWindowsStartScriptGenerator(windowsStartScriptGenerator: ScriptGenerator): Unit |
open class CreateStartScripts : CreateStartScripts
Creates start scripts for launching JVM applications. Example:
Note: the Gradle The task generates separate scripts targeted at Microsoft Windows environments and UNIX-like environments (e.g. Linux, macOS). The actual generation is implemented by the Example:
The default generators are of the type org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator, with default templates. This templates can be changed via the The default implementations used by this task use Groovy's SimpleTemplateEngine to parse the template, with the following variables available:
Example:
|