Package: org.gradle.jvm.application.tasks

## [Java] Class CreateStartScripts

- org.gradle.jvm.application.tasks.CreateStartScripts

- 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 `"createStartScripts"`.

  The task generates separate scripts targeted at Microsoft Windows environments and UNIX-like environments (e.g. Linux, Mac OS X). 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 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')
       }

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class org.gradle.api.internal.ConventionTask` | `TASK_NAME, TASK_DESCRIPTION, TASK_GROUP, TASK_TYPE, TASK_DEPENDS_ON, TASK_OVERWRITE, TASK_ACTION`
    `class DefaultTask` | `TASK_NAME, TASK_DESCRIPTION, TASK_GROUP, TASK_TYPE, TASK_DEPENDS_ON, TASK_OVERWRITE, TASK_ACTION`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `void` | `generate()`
    `String` | `getApplicationName()` The application's name.
    `FileCollection` | `getClasspath()` The class path for the application.
    `Iterable<String>` | `getDefaultJvmOpts()` The application's default JVM options.
    `String` | `getExitEnvironmentVar()` The environment variable to use to control exit value (Windows only).
    `String` | `getMainClassName()` The main classname used to start the Java application.
    `String` | `getOptsEnvironmentVar()` The environment variable to use to provide additional options to the JVM.
    `File` | `getOutputDir()` The directory to write the scripts into.
    `File` | `getUnixScript()` Returns the full path to the Unix script.
    `ScriptGenerator` | `getUnixStartScriptGenerator()` The UNIX-like start script generator.
    `File` | `getWindowsScript()` Returns the full path to the Windows script.
    `ScriptGenerator` | `getWindowsStartScriptGenerator()` The Windows start script generator.
    `void` | `setApplicationName(String applicationName)`
    `void` | `setClasspath(FileCollection classpath)`
    `void` | `setDefaultJvmOpts(Iterable<String> defaultJvmOpts)`
    `void` | `setExitEnvironmentVar(String exitEnvironmentVar)`
    `void` | `setMainClassName(String mainClassName)`
    `void` | `setOptsEnvironmentVar(String optsEnvironmentVar)`
    `void` | `setOutputDir(File outputDir)`
    `void` | `setUnixStartScriptGenerator(ScriptGenerator unixStartScriptGenerator)`
    `void` | `setWindowsStartScriptGenerator(ScriptGenerator windowsStartScriptGenerator)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class org.gradle.api.internal.ConventionTask` | `org.gradle.api.internal.ConventionTask#conventionMapping(java.lang.String, groovy.lang.Closure), org.gradle.api.internal.ConventionTask#conventionMapping(java.lang.String, java.util.concurrent.Callable), org.gradle.api.internal.ConventionTask#getConventionMapping(), org.gradle.api.internal.ConventionTask#setProperty(java.lang.String, java.lang.Object), org.gradle.api.internal.ConventionTask#toString(), org.gradle.api.internal.ConventionTask#compareTo(java.lang.Object), org.gradle.api.internal.ConventionTask#compareTo(org.gradle.api.Task), org.gradle.api.internal.ConventionTask#getName(), org.gradle.api.internal.ConventionTask#getActions(), org.gradle.api.internal.ConventionTask#getState(), org.gradle.api.internal.ConventionTask#getState(), org.gradle.api.internal.ConventionTask#setName(java.lang.String), org.gradle.api.internal.ConventionTask#getPath(), org.gradle.api.internal.ConventionTask#getExtensions(), org.gradle.api.internal.ConventionTask#getLogger(), org.gradle.api.internal.ConventionTask#execute(), org.gradle.api.internal.ConventionTask#configure(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#configure(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#getDescription(), org.gradle.api.internal.ConventionTask#leftShift(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#property(java.lang.String), org.gradle.api.internal.ConventionTask#isEnabled(), org.gradle.api.internal.ConventionTask#setEnabled(boolean), org.gradle.api.internal.ConventionTask#getOutputs(), org.gradle.api.internal.ConventionTask#getOutputs(), org.gradle.api.internal.ConventionTask#dependsOn([Ljava.lang.Object;), org.gradle.api.internal.ConventionTask#onlyIf(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#onlyIf(org.gradle.api.specs.Spec), org.gradle.api.internal.ConventionTask#setOnlyIf(org.gradle.api.specs.Spec), org.gradle.api.internal.ConventionTask#setOnlyIf(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#setDidWork(boolean), org.gradle.api.internal.ConventionTask#getDidWork(), org.gradle.api.internal.ConventionTask#doFirst(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#doFirst(org.gradle.api.Action), org.gradle.api.internal.ConventionTask#deleteAllActions(), org.gradle.api.internal.ConventionTask#getProject(), org.gradle.api.internal.ConventionTask#getTaskDependencies(), org.gradle.api.internal.ConventionTask#getTaskDependencies(), org.gradle.api.internal.ConventionTask#doLast(org.gradle.api.Action), org.gradle.api.internal.ConventionTask#doLast(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#getEnabled(), org.gradle.api.internal.ConventionTask#getAnt(), org.gradle.api.internal.ConventionTask#getLogging(), org.gradle.api.internal.ConventionTask#getLogging(), org.gradle.api.internal.ConventionTask#hasProperty(java.lang.String), org.gradle.api.internal.ConventionTask#getConvention(), org.gradle.api.internal.ConventionTask#setDescription(java.lang.String), org.gradle.api.internal.ConventionTask#getGroup(), org.gradle.api.internal.ConventionTask#setGroup(java.lang.String), org.gradle.api.internal.ConventionTask#dependsOnTaskDidWork(), org.gradle.api.internal.ConventionTask#getInputs(), org.gradle.api.internal.ConventionTask#getTemporaryDir(), org.gradle.api.internal.ConventionTask#mustRunAfter([Ljava.lang.Object;), org.gradle.api.internal.ConventionTask#setMustRunAfter(java.lang.Iterable), org.gradle.api.internal.ConventionTask#getMustRunAfter(), org.gradle.api.internal.ConventionTask#finalizedBy([Ljava.lang.Object;), org.gradle.api.internal.ConventionTask#setFinalizedBy(java.lang.Iterable), org.gradle.api.internal.ConventionTask#getFinalizedBy(), org.gradle.api.internal.ConventionTask#shouldRunAfter([Ljava.lang.Object;), org.gradle.api.internal.ConventionTask#setShouldRunAfter(java.lang.Iterable), org.gradle.api.internal.ConventionTask#getShouldRunAfter(), org.gradle.api.internal.ConventionTask#setActions(java.util.List), org.gradle.api.internal.ConventionTask#getDependsOn(), org.gradle.api.internal.ConventionTask#setDependsOn(java.lang.Iterable), org.gradle.api.internal.ConventionTask#getStandardOutputCapture(), org.gradle.api.internal.ConventionTask#getAsDynamicObject(), org.gradle.api.internal.ConventionTask#setProject(org.gradle.api.Project), org.gradle.api.internal.ConventionTask#addValidator(org.gradle.api.internal.tasks.execution.TaskValidator), org.gradle.api.internal.ConventionTask#prependParallelSafeAction(org.gradle.api.Action), org.gradle.api.internal.ConventionTask#injectIntoNewInstance(org.gradle.api.internal.project.ProjectInternal, java.lang.String, java.util.concurrent.Callable), org.gradle.api.internal.ConventionTask#setImpliesSubProjects(boolean), org.gradle.api.internal.ConventionTask#getExecuter(), org.gradle.api.internal.ConventionTask#setExecuter(org.gradle.api.internal.tasks.TaskExecuter), org.gradle.api.internal.ConventionTask#getTemporaryDirFactory(), org.gradle.api.internal.ConventionTask#getValidators(), org.gradle.api.internal.ConventionTask#appendParallelSafeAction(org.gradle.api.Action), org.gradle.api.internal.ConventionTask#isHasCustomActions(), org.gradle.api.internal.ConventionTask#getTaskActions(), org.gradle.api.internal.ConventionTask#getOnlyIf(), org.gradle.api.internal.ConventionTask#getImpliesSubProjects(), org.gradle.api.internal.ConventionTask#wait(long, int), org.gradle.api.internal.ConventionTask#wait(long), org.gradle.api.internal.ConventionTask#wait(), org.gradle.api.internal.ConventionTask#equals(java.lang.Object), org.gradle.api.internal.ConventionTask#hashCode(), org.gradle.api.internal.ConventionTask#getClass(), org.gradle.api.internal.ConventionTask#notify(), org.gradle.api.internal.ConventionTask#notifyAll()`
    `class DefaultTask` | `setProperty, toString, compareTo, compareTo, getName, getActions, getState, getState, setName, getPath, getExtensions, getLogger, execute, configure, configure, getDescription, leftShift, property, isEnabled, setEnabled, getOutputs, getOutputs, dependsOn, onlyIf, onlyIf, setOnlyIf, setOnlyIf, setDidWork, getDidWork, doFirst, doFirst, deleteAllActions, getProject, getTaskDependencies, getTaskDependencies, doLast, doLast, getEnabled, getAnt, getLogging, getLogging, hasProperty, getConvention, setDescription, getGroup, setGroup, dependsOnTaskDidWork, getInputs, getTemporaryDir, mustRunAfter, setMustRunAfter, getMustRunAfter, finalizedBy, setFinalizedBy, getFinalizedBy, shouldRunAfter, setShouldRunAfter, getShouldRunAfter, setActions, getDependsOn, setDependsOn, getStandardOutputCapture, getAsDynamicObject, setProject, addValidator, prependParallelSafeAction, injectIntoNewInstance, setImpliesSubProjects, getExecuter, setExecuter, getTemporaryDirFactory, getValidators, appendParallelSafeAction, isHasCustomActions, getTaskActions, getOnlyIf, getImpliesSubProjects, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll`

- - ### Method Detail

    - #### @TaskAction public void generate()

    - #### @Input public String getApplicationName()

      The application's name.

    - #### @InputFiles public FileCollection getClasspath()

      The class path for the application.

    - #### @Input @Optional public Iterable<String> getDefaultJvmOpts()

      The application's default JVM options. Defaults to an empty list.

    - #### @Input @Optional public String getExitEnvironmentVar()

      The environment variable to use to control exit value (Windows only).

    - #### @Input public String getMainClassName()

      The main classname used to start the Java application.

    - #### @Input @Optional public String getOptsEnvironmentVar()

      The environment variable to use to provide additional options to the JVM.

    - #### @OutputDirectory public File getOutputDir()

      The directory to write the scripts into.

    - #### public File getUnixScript()

      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.

    - #### @Incubating public ScriptGenerator getUnixStartScriptGenerator()

      The UNIX-like start script generator.

      Defaults to an implementation of TemplateBasedScriptGenerator.

    - #### public File getWindowsScript()

      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.

    - #### @Incubating public ScriptGenerator getWindowsStartScriptGenerator()

      The Windows start script generator.

      Defaults to an implementation of TemplateBasedScriptGenerator.

    - #### public void setApplicationName(String applicationName)

    - #### public void setClasspath(FileCollection classpath)

    - #### public void setDefaultJvmOpts(Iterable<String> defaultJvmOpts)

    - #### public void setExitEnvironmentVar(String exitEnvironmentVar)

    - #### public void setMainClassName(String mainClassName)

    - #### public void setOptsEnvironmentVar(String optsEnvironmentVar)

    - #### public void setOutputDir(File outputDir)

    - #### public void setUnixStartScriptGenerator(ScriptGenerator unixStartScriptGenerator)

    - #### public void setWindowsStartScriptGenerator(ScriptGenerator windowsStartScriptGenerator)