Search in sources :

Example 1 with StartScriptGenerator

use of org.gradle.api.internal.plugins.StartScriptGenerator in project gradle by gradle.

the class CreateStartScripts method generate.

@TaskAction
public void generate() {
    StartScriptGenerator generator = new StartScriptGenerator(unixStartScriptGenerator, windowsStartScriptGenerator);
    JavaModuleDetector javaModuleDetector = getJavaModuleDetector();
    generator.setApplicationName(getApplicationName());
    generator.setMainClassName(fullMainArgument());
    generator.setDefaultJvmOpts(getDefaultJvmOpts());
    generator.setOptsEnvironmentVar(getOptsEnvironmentVar());
    generator.setExitEnvironmentVar(getExitEnvironmentVar());
    generator.setClasspath(getRelativePath(javaModuleDetector.inferClasspath(mainModule.isPresent(), getClasspath())));
    generator.setModulePath(getRelativePath(javaModuleDetector.inferModulePath(mainModule.isPresent(), getClasspath())));
    if (StringUtils.isEmpty(getExecutableDir())) {
        generator.setScriptRelPath(getUnixScript().getName());
    } else {
        generator.setScriptRelPath(getExecutableDir() + "/" + getUnixScript().getName());
    }
    generator.generateUnixScript(getUnixScript());
    generator.generateWindowsScript(getWindowsScript());
}
Also used : UnixStartScriptGenerator(org.gradle.api.internal.plugins.UnixStartScriptGenerator) WindowsStartScriptGenerator(org.gradle.api.internal.plugins.WindowsStartScriptGenerator) StartScriptGenerator(org.gradle.api.internal.plugins.StartScriptGenerator) JavaModuleDetector(org.gradle.internal.jvm.JavaModuleDetector) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with StartScriptGenerator

use of org.gradle.api.internal.plugins.StartScriptGenerator in project gradle by gradle.

the class Wrapper method generate.

@TaskAction
void generate() {
    File jarFileDestination = getJarFile();
    File unixScript = getScriptFile();
    FileResolver resolver = getFileLookup().getFileResolver(unixScript.getParentFile());
    String jarFileRelativePath = resolver.resolveAsRelativePath(jarFileDestination);
    writeProperties(getPropertiesFile());
    writeWrapperTo(jarFileDestination);
    StartScriptGenerator generator = new StartScriptGenerator();
    generator.setApplicationName("Gradle");
    generator.setMainClassName(GradleWrapperMain.class.getName());
    generator.setClasspath(WrapUtil.toList(jarFileRelativePath));
    generator.setOptsEnvironmentVar("GRADLE_OPTS");
    generator.setExitEnvironmentVar("GRADLE_EXIT_CONSOLE");
    generator.setAppNameSystemProperty("org.gradle.appname");
    generator.setScriptRelPath(unixScript.getName());
    generator.setDefaultJvmOpts(ImmutableList.of("-Xmx64m", "-Xms64m"));
    generator.generateUnixScript(unixScript);
    generator.generateWindowsScript(getBatchScript());
}
Also used : GradleWrapperMain(org.gradle.wrapper.GradleWrapperMain) StartScriptGenerator(org.gradle.api.internal.plugins.StartScriptGenerator) FileResolver(org.gradle.api.internal.file.FileResolver) File(java.io.File) OutputFile(org.gradle.api.tasks.OutputFile) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

StartScriptGenerator (org.gradle.api.internal.plugins.StartScriptGenerator)2 TaskAction (org.gradle.api.tasks.TaskAction)2 File (java.io.File)1 FileResolver (org.gradle.api.internal.file.FileResolver)1 UnixStartScriptGenerator (org.gradle.api.internal.plugins.UnixStartScriptGenerator)1 WindowsStartScriptGenerator (org.gradle.api.internal.plugins.WindowsStartScriptGenerator)1 OutputFile (org.gradle.api.tasks.OutputFile)1 JavaModuleDetector (org.gradle.internal.jvm.JavaModuleDetector)1 GradleWrapperMain (org.gradle.wrapper.GradleWrapperMain)1