Comparable<Task>
, org.gradle.api.internal.DynamicObjectAware
, org.gradle.api.internal.IConventionAware
, org.gradle.api.internal.TaskInternal
, ExtensionAware
, Task
, org.gradle.util.Configurable<Task>
public class CreateStartScripts extends CreateStartScripts
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 CreateStartScripts.getWindowsStartScriptGenerator()
and CreateStartScripts.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 TemplateBasedScriptGenerator
, with default templates.
This templates can be changed via the 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
defaultJvmOpts
appNameSystemProperty
appHomeRelativePath
classpath
Example:
task createStartScripts(type: CreateStartScripts) { unixStartScriptGenerator.template = resources.text.fromFile('customUnixStartScript.txt') windowsStartScriptGenerator.template = resources.text.fromFile('customWindowsStartScript.txt') }
Task.Namer
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
Constructor | Description |
---|---|
CreateStartScripts() |
generate, getApplicationName, getClasspath, getDefaultJvmOpts, getExecutableDir, getExitEnvironmentVar, getMainClassName, getOptsEnvironmentVar, getOutputDir, getRelativeClasspath, getUnixScript, getUnixStartScriptGenerator, getWindowsScript, getWindowsStartScriptGenerator, setApplicationName, setClasspath, setDefaultJvmOpts, setExecutableDir, setExitEnvironmentVar, setMainClassName, setOptsEnvironmentVar, setOutputDir, setUnixStartScriptGenerator, setWindowsStartScriptGenerator
conventionMapping, conventionMapping, getConventionMapping
newInputDirectory, newInputFile, newOutputDirectory, newOutputFile
appendParallelSafeAction, compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTaskIdentity, getTemporaryDir, getTemporaryDirFactory, getTimeout, hasProperty, hasTaskActions, injectIntoNewInstance, isEnabled, isHasCustomActions, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, replaceLogger, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, toString