Search in sources :

Example 11 with JavaForkOptions

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

the class DaemonScalaCompiler method toDaemonForkOptions.

@Override
protected DaemonForkOptions toDaemonForkOptions(T spec) {
    MinimalJavaCompilerDaemonForkOptions javaOptions = spec.getCompileOptions().getForkOptions();
    MinimalScalaCompilerDaemonForkOptions scalaOptions = spec.getScalaCompileOptions().getForkOptions();
    JavaForkOptions javaForkOptions = new BaseForkOptionsConverter(forkOptionsFactory).transform(mergeForkOptions(javaOptions, scalaOptions));
    javaForkOptions.setWorkingDir(daemonWorkingDir);
    String javaExecutable = javaOptions.getExecutable();
    if (javaExecutable != null) {
        javaForkOptions.setExecutable(javaExecutable);
    }
    ClassPath compilerClasspath = classPathRegistry.getClassPath("SCALA-COMPILER").plus(DefaultClassPath.of(zincClasspath));
    HierarchicalClassLoaderStructure classLoaderStructure = new HierarchicalClassLoaderStructure(classLoaderRegistry.getGradleWorkerExtensionSpec()).withChild(getScalaFilterSpec()).withChild(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) DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath) ClassPath(org.gradle.internal.classpath.ClassPath) BaseForkOptionsConverter(org.gradle.api.internal.tasks.compile.BaseForkOptionsConverter) VisitableURLClassLoader(org.gradle.internal.classloader.VisitableURLClassLoader) HierarchicalClassLoaderStructure(org.gradle.workers.internal.HierarchicalClassLoaderStructure) JavaForkOptions(org.gradle.process.JavaForkOptions) MinimalJavaCompilerDaemonForkOptions(org.gradle.api.internal.tasks.compile.MinimalJavaCompilerDaemonForkOptions)

Example 12 with JavaForkOptions

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

the class DefaultWorkerExecutor method getWorkerRequirement.

WorkerRequirement getWorkerRequirement(Class<?> executionClass, WorkerSpec configuration, WorkParameters parameters) {
    if (configuration instanceof ProcessWorkerSpec) {
        DaemonForkOptionsBuilder builder = new DaemonForkOptionsBuilder(forkOptionsFactory).keepAliveMode(KeepAliveMode.DAEMON);
        ProcessWorkerSpec processConfiguration = (ProcessWorkerSpec) configuration;
        JavaForkOptions forkOptions = forkOptionsFactory.newJavaForkOptions();
        processConfiguration.getForkOptions().copyTo(forkOptions);
        forkOptions.setWorkingDir(workerDirectoryProvider.getWorkingDirectory());
        builder.javaForkOptions(forkOptions).withClassLoaderStructure(classLoaderStructureProvider.getWorkerProcessClassLoaderStructure(processConfiguration.getClasspath(), getParamClasses(executionClass, parameters)));
        return new ForkedWorkerRequirement(baseDir, builder.build());
    } else if (configuration instanceof ClassLoaderWorkerSpec) {
        ClassLoaderWorkerSpec classLoaderConfiguration = (ClassLoaderWorkerSpec) configuration;
        return new IsolatedClassLoaderWorkerRequirement(baseDir, classLoaderStructureProvider.getInProcessClassLoaderStructure(classLoaderConfiguration.getClasspath(), getParamClasses(executionClass, parameters)));
    } else {
        return new FixedClassLoaderWorkerRequirement(baseDir, Thread.currentThread().getContextClassLoader());
    }
}
Also used : ClassLoaderWorkerSpec(org.gradle.workers.ClassLoaderWorkerSpec) JavaForkOptions(org.gradle.process.JavaForkOptions) ProcessWorkerSpec(org.gradle.workers.ProcessWorkerSpec)

Example 13 with JavaForkOptions

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

the class DefaultTestTaskPropertiesService method collectForkOptions.

private TestTaskForkOptions collectForkOptions(Test task) {
    boolean testIsModule = javaModuleDetector.isModule(task.getModularity().getInferModulePath().get(), task.getTestClassesDirs());
    JavaForkOptions forkOptions = forkOptionsFactory.newJavaForkOptions();
    task.copyTo(forkOptions);
    String executable = forkOptions.getExecutable();
    return new DefaultTestTaskForkOptions(forkOptions.getWorkingDir(), executable, detectJavaVersion(executable), javaModuleDetector.inferClasspath(testIsModule, task.getClasspath()), javaModuleDetector.inferModulePath(testIsModule, task.getClasspath()), forkOptions.getAllJvmArgs(), DefaultProcessForkOptions.getActualEnvironment(forkOptions));
}
Also used : JavaForkOptions(org.gradle.process.JavaForkOptions)

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