Class CreateStartScripts
- java.lang.Object
-
- org.gradle.api.internal.AbstractTask
-
- org.gradle.api.DefaultTask
-
- org.gradle.api.internal.ConventionTask
-
- org.gradle.jvm.application.tasks.CreateStartScripts
-
- org.gradle.api.tasks.application.CreateStartScripts
-
- All Implemented Interfaces:
java.lang.Comparable<Task>
,org.gradle.api.internal.DynamicObjectAware
,org.gradle.api.internal.IConventionAware
,org.gradle.api.internal.TaskInternal
,Named
,ExtensionAware
,Task
,Configurable<Task>
@DisableCachingByDefault(because="Not worth caching") public abstract class CreateStartScripts extends CreateStartScripts
Creates start scripts for launching JVM applications.Example:
task createStartScripts(type: CreateStartScripts) { outputDir = file('build/sample') mainClass = '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()
andCreateStartScripts.getUnixStartScriptGenerator()
properties, of typeScriptGenerator
.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 theTemplateBasedScriptGenerator.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
mainModule
mainClass
defaultJvmOpts
appNameSystemProperty
appHomeRelativePath
classpath
Example:
task createStartScripts(type: CreateStartScripts) { unixStartScriptGenerator.template = resources.text.fromFile('customUnixStartScript.txt') windowsStartScriptGenerator.template = resources.text.fromFile('customWindowsStartScript.txt') }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.gradle.api.Task
Task.Namer
-
-
Field Summary
-
Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
-
-
Constructor Summary
Constructors Constructor Description CreateStartScripts()
-
Method Summary
-
Methods inherited from class org.gradle.jvm.application.tasks.CreateStartScripts
generate, getApplicationName, getClasspath, getDefaultJvmOpts, getExecutableDir, getExitEnvironmentVar, getJavaModuleDetector, getMainClass, getMainClassName, getMainModule, getModularity, getObjectFactory, getOptsEnvironmentVar, getOutputDir, getRelativeClasspath, getUnixScript, getUnixStartScriptGenerator, getWindowsScript, getWindowsStartScriptGenerator, setApplicationName, setClasspath, setDefaultJvmOpts, setExecutableDir, setExitEnvironmentVar, setMainClassName, setOptsEnvironmentVar, setOutputDir, setUnixStartScriptGenerator, setWindowsStartScriptGenerator
-
Methods inherited from class org.gradle.api.internal.ConventionTask
conventionMapping, conventionMapping, getConventionMapping
-
Methods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService
-
Methods inherited from class org.gradle.api.internal.AbstractTask
acceptServiceReferences, appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.gradle.api.Task
doNotTrackState, getConvention, notCompatibleWithConfigurationCache
-
-