org.gradle.api.tasks.application.CreateStartScripts Maven / Gradle / Ivy
Show all versions of gradle-api Show documentation
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.api.tasks.application;
import org.gradle.work.DisableCachingByDefault;
/**
* 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 {@code "application"} plugin adds a pre-configured task of this type named {@code "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 {@link #getWindowsStartScriptGenerator()} and {@link #getUnixStartScriptGenerator()} properties, of type
* {@link org.gradle.jvm.application.scripts.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 {@link org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator}, with default templates.
* This templates can be changed via the {@link org.gradle.jvm.application.scripts.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:
*
* - {@code applicationName}
* - {@code optsEnvironmentVar}
* - {@code exitEnvironmentVar}
* - {@code mainModule}
* - {@code mainClass}
* - {@code defaultJvmOpts}
* - {@code appNameSystemProperty}
* - {@code appHomeRelativePath}
* - {@code classpath}
*
*
* Example:
*
* task createStartScripts(type: CreateStartScripts) {
* unixStartScriptGenerator.template = resources.text.fromFile('customUnixStartScript.txt')
* windowsStartScriptGenerator.template = resources.text.fromFile('customWindowsStartScript.txt')
* }
*
*/
@DisableCachingByDefault(because = "Not worth caching")
public abstract class CreateStartScripts extends org.gradle.jvm.application.tasks.CreateStartScripts {
}