CreateStartScripts (Gradle API 2.14.1)

org.gradle.jvm.application.tasks

## 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

- All Implemented Interfaces:
    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 org.gradle.api.internal.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 `"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(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')
       }

- - ### 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_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CreateStartScripts()`

  - ### Method Summary

    Methods
    Modifier and Type | Method 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)`

    - ### Methods inherited from class org.gradle.api.internal.ConventionTask

      `conventionMapping, conventionMapping, getConventionMapping`

    - ### Methods inherited from class org.gradle.api.internal.AbstractTask

      `addValidator, appendParallelSafeAction, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doLast, doLast, execute, finalizedBy, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDidWork, getEnabled, getExecuter, getExtensions, getFinalizedBy, getGroup, getImpliesSubProjects, getInputs, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTemporaryDir, getTemporaryDirFactory, getValidators, hasProperty, injectIntoNewInstance, isEnabled, isHasCustomActions, leftShift, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setName, setOnlyIf, setOnlyIf, setProject, setProperty, setShouldRunAfter, shouldRunAfter, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CreateStartScripts

          public CreateStartScripts()

  - ### Method Detail

    - #### getOptsEnvironmentVar

          @Input
          @Optional
          public String getOptsEnvironmentVar()

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

    - #### getExitEnvironmentVar

          @Input
          @Optional
          public String getExitEnvironmentVar()

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

    - #### getUnixScript

          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.

    - #### getWindowsScript

          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.

    - #### getOutputDir

          @OutputDirectory
          public File getOutputDir()

      The directory to write the scripts into.

    - #### setOutputDir

          public void setOutputDir(File outputDir)

    - #### getMainClassName

          @Input
          public String getMainClassName()

      The main classname used to start the Java application.

    - #### setMainClassName

          public void setMainClassName(String mainClassName)

    - #### getDefaultJvmOpts

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

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

    - #### setDefaultJvmOpts

          public void setDefaultJvmOpts(Iterable<String> defaultJvmOpts)

    - #### getApplicationName

          @Input
          public String getApplicationName()

      The application's name.

    - #### setApplicationName

          public void setApplicationName(String applicationName)

    - #### setOptsEnvironmentVar

          public void setOptsEnvironmentVar(String optsEnvironmentVar)

    - #### setExitEnvironmentVar

          public void setExitEnvironmentVar(String exitEnvironmentVar)

    - #### getClasspath

          @InputFiles
          public FileCollection getClasspath()

      The class path for the application.

    - #### setClasspath

          public void setClasspath(FileCollection classpath)

    - #### getUnixStartScriptGenerator

          @Incubating
          public ScriptGenerator getUnixStartScriptGenerator()

      The UNIX-like start script generator.

      Defaults to an implementation of `TemplateBasedScriptGenerator`.

    - #### setUnixStartScriptGenerator

          public void setUnixStartScriptGenerator(ScriptGenerator unixStartScriptGenerator)

    - #### getWindowsStartScriptGenerator

          @Incubating
          public ScriptGenerator getWindowsStartScriptGenerator()

      The Windows start script generator.

      Defaults to an implementation of `TemplateBasedScriptGenerator`.

    - #### setWindowsStartScriptGenerator

          public void setWindowsStartScriptGenerator(ScriptGenerator windowsStartScriptGenerator)

    - #### generate

          public void generate()