Class CreateStartScripts
- All Implemented Interfaces:
- Comparable<Task>,- org.gradle.api.internal.DynamicObjectAware,- org.gradle.api.internal.IConventionAware,- org.gradle.api.internal.TaskInternal,- Named,- ExtensionAware,- Task,- Configurable<Task>
- Direct Known Subclasses:
- CreateStartScripts
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 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 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- See- JavaAppStartScriptGenerationDetails.getApplicationName().
- optsEnvironmentVar- See- JavaAppStartScriptGenerationDetails.getOptsEnvironmentVar().
- exitEnvironmentVar- See- JavaAppStartScriptGenerationDetails.getExitEnvironmentVar().
- moduleEntryPoint- The module entry point, or- nullif none. Will also include the main class name if present, in the form- [moduleName]/[className].
- mainClassName- The main class name, or usually- ""if none. For legacy reasons, this may be set to- --module [moduleEntryPoint]when using a main module. This behavior should not be relied upon and may be removed in a future release.
- entryPointArgs- The arguments to be used on the command-line to enter the application, as a joined string. It should be inserted before the program arguments.
- defaultJvmOpts- See- JavaAppStartScriptGenerationDetails.getDefaultJvmOpts().
- appNameSystemProperty- See- JavaAppStartScriptGenerationDetails.getAppNameSystemProperty().
- appHomeRelativePath- The path, relative to the script's own path, of the app home.
- classpath- See- JavaAppStartScriptGenerationDetails.getClasspath(). It is already encoded as a joined string.
- modulePath(different capitalization) - See- JavaAppStartScriptGenerationDetails.getModulePath(). It is already encoded as a joined string.
 The encoded paths expect a variable named APP_HOME to be present in the script, set to the application home directory which can be resolved using appHomeRelativePath.
 
Example:
 task createStartScripts(type: CreateStartScripts) {
   unixStartScriptGenerator.template = resources.text.fromFile('customUnixStartScript.txt')
   windowsStartScriptGenerator.template = resources.text.fromFile('customWindowsStartScript.txt')
 }
 - 
Nested Class SummaryNested classes/interfaces inherited from interface org.gradle.api.TaskTask.Namer
- 
Field SummaryFields inherited from interface org.gradle.api.TaskTASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidgenerate()The application's name.The class path for the application.The application's default JVM options.The directory to write the scripts into in the distribution.The environment variable to use to control exit value (Windows only).protected org.gradle.internal.jvm.JavaModuleDetectorThe main class name used to start the Java application.Deprecated.The main module name used to start the modular Java application.Returns the module path handling for executing the main class.protected ObjectFactoryThe environment variable to use to provide additional options to the JVM.The directory to write the scripts into.Returns the full path to the Unix script.The UNIX-like start script generator.Returns the full path to the Windows script.The Windows start script generator.voidsetApplicationName(String applicationName) voidsetClasspath(FileCollection classpath) voidsetDefaultJvmOpts(Iterable<String> defaultJvmOpts) voidsetExecutableDir(String executableDir) The directory to write the scripts into in the distribution.voidsetExitEnvironmentVar(String exitEnvironmentVar) voidsetMainClassName(String mainClassName) Deprecated.voidsetOptsEnvironmentVar(String optsEnvironmentVar) voidsetOutputDir(File outputDir) voidsetUnixStartScriptGenerator(ScriptGenerator unixStartScriptGenerator) voidsetWindowsStartScriptGenerator(ScriptGenerator windowsStartScriptGenerator) Methods inherited from class org.gradle.api.internal.ConventionTaskconventionMapping, conventionMapping, getConventionMappingMethods inherited from class org.gradle.api.DefaultTaskcompareTo, 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, usesServiceMethods inherited from class org.gradle.api.internal.AbstractTaskacceptServiceReferences, appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjectsMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.TaskdoNotTrackState, getConvention, notCompatibleWithConfigurationCache
- 
Constructor Details- 
CreateStartScriptspublic CreateStartScripts()
 
- 
- 
Method Details- 
getObjectFactory
- 
getJavaModuleDetector@Inject protected org.gradle.internal.jvm.JavaModuleDetector getJavaModuleDetector()
- 
getOptsEnvironmentVarThe environment variable to use to provide additional options to the JVM.
- 
getExitEnvironmentVarThe environment variable to use to control exit value (Windows only).
- 
getUnixScriptReturns 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.
- 
getWindowsScriptReturns 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.
- 
getOutputDirThe directory to write the scripts into.
- 
setOutputDir
- 
getExecutableDirThe directory to write the scripts into in the distribution.- Since:
- 4.5
 
- 
setExecutableDirThe directory to write the scripts into in the distribution.- Since:
- 4.5
 
- 
getMainModuleThe main module name used to start the modular Java application.- Since:
- 6.4
 
- 
getMainClassThe main class name used to start the Java application.- Since:
- 6.4
 
- 
getMainClassNameDeprecated.The main class name used to start the Java application.
- 
setMainClassNameDeprecated.
- 
getDefaultJvmOptsThe application's default JVM options. Defaults to an empty list.
- 
setDefaultJvmOpts
- 
getApplicationNameThe application's name.
- 
setApplicationName
- 
setOptsEnvironmentVar
- 
setExitEnvironmentVar
- 
getClasspathThe class path for the application.
- 
getModularityReturns the module path handling for executing the main class.- Since:
- 6.4
 
- 
setClasspath
- 
getUnixStartScriptGeneratorThe UNIX-like start script generator.Defaults to an implementation of TemplateBasedScriptGenerator.
- 
setUnixStartScriptGenerator
- 
getWindowsStartScriptGeneratorThe Windows start script generator.Defaults to an implementation of TemplateBasedScriptGenerator.
- 
setWindowsStartScriptGenerator
- 
generatepublic void generate()
- 
getRelativeClasspath
 
-