Search in sources :

Example 6 with JavaForkOptions

use of org.gradle.process.JavaForkOptions in project gradle by gradle.

the class BaseForkOptionsConverter method transform.

@Override
public JavaForkOptions transform(BaseForkOptions baseForkOptions) {
    JavaForkOptions javaForkOptions = forkOptionsFactory.newJavaForkOptions();
    javaForkOptions.setMinHeapSize(baseForkOptions.getMemoryInitialSize());
    javaForkOptions.setMaxHeapSize(baseForkOptions.getMemoryMaximumSize());
    javaForkOptions.setJvmArgs(baseForkOptions.getJvmArgs());
    return javaForkOptions;
}
Also used : JavaForkOptions(org.gradle.process.JavaForkOptions)

Example 7 with JavaForkOptions

use of org.gradle.process.JavaForkOptions in project gradle by gradle.

the class ScalaDoc method generate.

@TaskAction
protected void generate() {
    ScalaDocOptions options = getScalaDocOptions();
    if (!GUtil.isTrue(options.getDocTitle())) {
        options.setDocTitle(getTitle());
    }
    WorkQueue queue = getWorkerExecutor().processIsolation(worker -> {
        worker.getClasspath().from(getScalaClasspath());
        JavaForkOptions forkOptions = worker.getForkOptions();
        if (getMaxMemory().isPresent()) {
            forkOptions.setMaxHeapSize(getMaxMemory().get());
        }
        if (javaLauncher.isPresent()) {
            forkOptions.setExecutable(javaLauncher.get().getExecutablePath().getAsFile().getAbsolutePath());
        }
    });
    queue.submit(GenerateScaladoc.class, parameters -> {
        @Nullable File optionsFile = createOptionsFile();
        parameters.getOptionsFile().set(optionsFile);
        parameters.getClasspath().from(getClasspath());
        parameters.getOutputDirectory().set(getDestinationDir());
        boolean isScala3 = ScalaRuntimeHelper.findScalaJar(getScalaClasspath(), "library_3") != null;
        parameters.getIsScala3().set(isScala3);
        if (isScala3) {
            parameters.getSources().from(getFilteredCompilationOutputs());
        } else {
            parameters.getSources().from(getSource());
            if (options.isDeprecation()) {
                parameters.getOptions().add("-deprecation");
            }
            if (options.isUnchecked()) {
                parameters.getOptions().add("-unchecked");
            }
        }
        String footer = options.getFooter();
        if (footer != null) {
            parameters.getOptions().add("-doc-footer");
            parameters.getOptions().add(footer);
        }
        String docTitle = options.getDocTitle();
        if (docTitle != null) {
            parameters.getOptions().add("-doc-title");
            parameters.getOptions().add(docTitle);
        }
        // None of these options work for Scala >=2.8
        // options.getBottom();;
        // options.getTop();
        // options.getHeader();
        // options.getWindowTitle();
        List<String> additionalParameters = options.getAdditionalParameters();
        if (additionalParameters != null) {
            parameters.getOptions().addAll(additionalParameters);
        }
    });
}
Also used : JavaForkOptions(org.gradle.process.JavaForkOptions) WorkQueue(org.gradle.workers.WorkQueue) File(java.io.File) Nullable(javax.annotation.Nullable) TaskAction(org.gradle.api.tasks.TaskAction)

Example 8 with JavaForkOptions

use of org.gradle.process.JavaForkOptions in project gradle by gradle.

the class DaemonJavaCompiler method toDaemonForkOptions.

@Override
protected DaemonForkOptions toDaemonForkOptions(JavaCompileSpec spec) {
    MinimalJavaCompilerDaemonForkOptions forkOptions = spec.getCompileOptions().getForkOptions();
    JavaForkOptions javaForkOptions = new BaseForkOptionsConverter(forkOptionsFactory).transform(forkOptions);
    javaForkOptions.setWorkingDir(daemonWorkingDir);
    javaForkOptions.setExecutable(findSuitableExecutable(spec));
    ClassPath compilerClasspath = classPathRegistry.getClassPath("JAVA-COMPILER");
    FlatClassLoaderStructure classLoaderStructure = new FlatClassLoaderStructure(new VisitableURLClassLoader.Spec("compiler", compilerClasspath.getAsURLs()));
    return new DaemonForkOptionsBuilder(forkOptionsFactory).javaForkOptions(javaForkOptions).withClassLoaderStructure(classLoaderStructure).keepAliveMode(KeepAliveMode.SESSION).build();
}
Also used : DaemonForkOptionsBuilder(org.gradle.workers.internal.DaemonForkOptionsBuilder) ClassPath(org.gradle.internal.classpath.ClassPath) FlatClassLoaderStructure(org.gradle.workers.internal.FlatClassLoaderStructure) VisitableURLClassLoader(org.gradle.internal.classloader.VisitableURLClassLoader) JavaForkOptions(org.gradle.process.JavaForkOptions)

Example 9 with JavaForkOptions

use of org.gradle.process.JavaForkOptions in project gradle by gradle.

the class Test method createTestExecutionSpec.

/**
 * {@inheritDoc}
 *
 * @since 4.4
 */
@Override
protected JvmTestExecutionSpec createTestExecutionSpec() {
    validateToolchainConfiguration();
    JavaForkOptions javaForkOptions = getForkOptionsFactory().newJavaForkOptions();
    copyTo(javaForkOptions);
    JavaModuleDetector javaModuleDetector = getJavaModuleDetector();
    boolean testIsModule = javaModuleDetector.isModule(modularity.getInferModulePath().get(), getTestClassesDirs());
    FileCollection classpath = javaModuleDetector.inferClasspath(testIsModule, stableClasspath);
    FileCollection modulePath = javaModuleDetector.inferModulePath(testIsModule, stableClasspath);
    return new JvmTestExecutionSpec(getTestFramework(), classpath, modulePath, getCandidateClassFiles(), isScanForTestClasses(), getTestClassesDirs(), getPath(), getIdentityPath(), getForkEvery(), javaForkOptions, getMaxParallelForks(), getPreviousFailedTestClasses());
}
Also used : JavaForkOptions(org.gradle.process.JavaForkOptions) JavaModuleDetector(org.gradle.internal.jvm.JavaModuleDetector) ConfigurableFileCollection(org.gradle.api.file.ConfigurableFileCollection) FileCollection(org.gradle.api.file.FileCollection) JvmTestExecutionSpec(org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec)

Example 10 with JavaForkOptions

use of org.gradle.process.JavaForkOptions in project gradle by gradle.

the class DaemonJavaCompiler method toInvocationContext.

@Override
protected InvocationContext toInvocationContext(JavaCompileSpec spec) {
    ForkOptions forkOptions = spec.getCompileOptions().getForkOptions();
    JavaForkOptions javaForkOptions = new BaseForkOptionsConverter(fileResolver).transform(forkOptions);
    File invocationWorkingDir = javaForkOptions.getWorkingDir();
    javaForkOptions.setWorkingDir(daemonWorkingDir);
    DaemonForkOptions daemonForkOptions = new DaemonForkOptionsBuilder(fileResolver).javaForkOptions(javaForkOptions).sharedPackages(SHARED_PACKAGES).keepAliveMode(KeepAliveMode.SESSION).build();
    return new InvocationContext(invocationWorkingDir, daemonForkOptions);
}
Also used : DaemonForkOptionsBuilder(org.gradle.workers.internal.DaemonForkOptionsBuilder) DaemonForkOptions(org.gradle.workers.internal.DaemonForkOptions) ForkOptions(org.gradle.api.tasks.compile.ForkOptions) DaemonForkOptions(org.gradle.workers.internal.DaemonForkOptions) JavaForkOptions(org.gradle.process.JavaForkOptions) JavaForkOptions(org.gradle.process.JavaForkOptions) File(java.io.File)

Aggregations

JavaForkOptions (org.gradle.process.JavaForkOptions)13 File (java.io.File)7 DaemonForkOptionsBuilder (org.gradle.workers.internal.DaemonForkOptionsBuilder)7 BaseForkOptionsConverter (org.gradle.api.internal.tasks.compile.BaseForkOptionsConverter)5 DaemonForkOptions (org.gradle.workers.internal.DaemonForkOptions)4 ForkOptions (org.gradle.api.tasks.compile.ForkOptions)3 VisitableURLClassLoader (org.gradle.internal.classloader.VisitableURLClassLoader)3 MinimalJavaCompilerDaemonForkOptions (org.gradle.api.internal.tasks.compile.MinimalJavaCompilerDaemonForkOptions)2 ClassPath (org.gradle.internal.classpath.ClassPath)2 HierarchicalClassLoaderStructure (org.gradle.workers.internal.HierarchicalClassLoaderStructure)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Nullable (javax.annotation.Nullable)1 ConfigurableFileCollection (org.gradle.api.file.ConfigurableFileCollection)1 FileCollection (org.gradle.api.file.FileCollection)1 GroovyJavaJointCompileSpec (org.gradle.api.internal.tasks.compile.GroovyJavaJointCompileSpec)1 MinimalGroovyCompilerDaemonForkOptions (org.gradle.api.internal.tasks.compile.MinimalGroovyCompilerDaemonForkOptions)1 JvmTestExecutionSpec (org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec)1 TaskAction (org.gradle.api.tasks.TaskAction)1 BaseForkOptions (org.gradle.api.tasks.compile.BaseForkOptions)1 GroovyForkOptions (org.gradle.api.tasks.compile.GroovyForkOptions)1