Search in sources :

Example 1 with JavaForkOptions

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

the class DefaultWorkerExecutor method toDaemonOptions.

private DaemonForkOptions toDaemonOptions(Class<?> actionClass, Iterable<Class<?>> paramClasses, JavaForkOptions userForkOptions, Iterable<File> classpath) {
    ImmutableSet.Builder<File> classpathBuilder = ImmutableSet.builder();
    ImmutableSet.Builder<String> sharedPackagesBuilder = ImmutableSet.builder();
    sharedPackagesBuilder.add("javax.inject");
    if (classpath != null) {
        classpathBuilder.addAll(classpath);
    }
    addVisibilityFor(actionClass, classpathBuilder, sharedPackagesBuilder, true);
    for (Class<?> paramClass : paramClasses) {
        addVisibilityFor(paramClass, classpathBuilder, sharedPackagesBuilder, false);
    }
    Iterable<File> daemonClasspath = classpathBuilder.build();
    Iterable<String> daemonSharedPackages = sharedPackagesBuilder.build();
    JavaForkOptions forkOptions = new DefaultJavaForkOptions(fileResolver);
    userForkOptions.copyTo(forkOptions);
    forkOptions.setWorkingDir(workerDirectoryProvider.getIdleWorkingDirectory());
    return new DaemonForkOptionsBuilder(fileResolver).javaForkOptions(forkOptions).classpath(daemonClasspath).sharedPackages(daemonSharedPackages).keepAliveMode(KeepAliveMode.DAEMON).build();
}
Also used : DefaultJavaForkOptions(org.gradle.process.internal.DefaultJavaForkOptions) ImmutableSet(com.google.common.collect.ImmutableSet) DefaultJavaForkOptions(org.gradle.process.internal.DefaultJavaForkOptions) JavaForkOptions(org.gradle.process.JavaForkOptions) File(java.io.File)

Example 2 with JavaForkOptions

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

the class DaemonGroovyCompiler method toInvocationContext.

@Override
protected InvocationContext toInvocationContext(GroovyJavaJointCompileSpec spec) {
    ForkOptions javaOptions = spec.getCompileOptions().getForkOptions();
    GroovyForkOptions groovyOptions = spec.getGroovyCompileOptions().getForkOptions();
    // Ant is optional dependency of groovy(-all) module but mandatory dependency of Groovy compiler;
    // that's why we add it here. The following assumes that any Groovy compiler version supported by Gradle
    // is compatible with Gradle's current Ant version.
    Collection<File> antFiles = classPathRegistry.getClassPath("ANT").getAsFiles();
    Iterable<File> groovyFiles = Iterables.concat(spec.getGroovyClasspath(), antFiles);
    JavaForkOptions javaForkOptions = new BaseForkOptionsConverter(fileResolver).transform(mergeForkOptions(javaOptions, groovyOptions));
    File invocationWorkingDir = javaForkOptions.getWorkingDir();
    javaForkOptions.setWorkingDir(daemonWorkingDir);
    DaemonForkOptions daemonForkOptions = new DaemonForkOptionsBuilder(fileResolver).javaForkOptions(javaForkOptions).classpath(groovyFiles).sharedPackages(SHARED_PACKAGES).keepAliveMode(KeepAliveMode.SESSION).build();
    return new InvocationContext(invocationWorkingDir, daemonForkOptions);
}
Also used : DaemonForkOptionsBuilder(org.gradle.workers.internal.DaemonForkOptionsBuilder) BaseForkOptionsConverter(org.gradle.api.internal.tasks.compile.BaseForkOptionsConverter) DaemonForkOptions(org.gradle.workers.internal.DaemonForkOptions) ForkOptions(org.gradle.api.tasks.compile.ForkOptions) DaemonForkOptions(org.gradle.workers.internal.DaemonForkOptions) JavaForkOptions(org.gradle.process.JavaForkOptions) GroovyForkOptions(org.gradle.api.tasks.compile.GroovyForkOptions) JavaForkOptions(org.gradle.process.JavaForkOptions) GroovyForkOptions(org.gradle.api.tasks.compile.GroovyForkOptions) File(java.io.File)

Example 3 with JavaForkOptions

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

the class DaemonPlayCompiler method toInvocationContext.

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

Example 4 with JavaForkOptions

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

the class DaemonScalaCompiler method toInvocationContext.

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

Example 5 with JavaForkOptions

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

the class DaemonGroovyCompiler method toDaemonForkOptions.

@Override
protected DaemonForkOptions toDaemonForkOptions(GroovyJavaJointCompileSpec spec) {
    MinimalJavaCompilerDaemonForkOptions javaOptions = spec.getCompileOptions().getForkOptions();
    MinimalGroovyCompilerDaemonForkOptions groovyOptions = spec.getGroovyCompileOptions().getForkOptions();
    // Ant is optional dependency of groovy(-all) module but mandatory dependency of Groovy compiler;
    // that's why we add it here. The following assumes that any Groovy compiler version supported by Gradle
    // is compatible with Gradle's current Ant version.
    Collection<File> antFiles = classPathRegistry.getClassPath("ANT").getAsFiles();
    Iterable<File> classpath = Iterables.concat(spec.getGroovyClasspath(), antFiles);
    VisitableURLClassLoader.Spec targetGroovyClasspath = new VisitableURLClassLoader.Spec("worker-loader", DefaultClassPath.of(classpath).getAsURLs());
    Collection<File> languageGroovyFiles = classPathRegistry.getClassPath("GROOVY-COMPILER").getAsFiles();
    VisitableURLClassLoader.Spec compilerClasspath = new VisitableURLClassLoader.Spec("compiler-loader", DefaultClassPath.of(languageGroovyFiles).getAsURLs());
    FilteringClassLoader.Spec gradleAndUserFilter = getMinimalGradleFilter();
    for (String sharedPackage : SHARED_PACKAGES) {
        gradleAndUserFilter.allowPackage(sharedPackage);
    }
    HierarchicalClassLoaderStructure classLoaderStructure = new HierarchicalClassLoaderStructure(classLoaderRegistry.getGradleWorkerExtensionSpec()).withChild(getMinimalGradleFilter()).withChild(targetGroovyClasspath).withChild(gradleAndUserFilter).withChild(compilerClasspath);
    JavaForkOptions javaForkOptions = new BaseForkOptionsConverter(forkOptionsFactory).transform(mergeForkOptions(javaOptions, groovyOptions));
    javaForkOptions.setWorkingDir(daemonWorkingDir);
    javaForkOptions.setExecutable(javaOptions.getExecutable());
    if (jvmVersionDetector.getJavaVersion(javaForkOptions.getExecutable()).isJava9Compatible()) {
        javaForkOptions.jvmArgs(JpmsConfiguration.GROOVY_JPMS_ARGS);
    }
    return new DaemonForkOptionsBuilder(forkOptionsFactory).javaForkOptions(javaForkOptions).keepAliveMode(KeepAliveMode.SESSION).withClassLoaderStructure(classLoaderStructure).build();
}
Also used : DaemonForkOptionsBuilder(org.gradle.workers.internal.DaemonForkOptionsBuilder) BaseForkOptionsConverter(org.gradle.api.internal.tasks.compile.BaseForkOptionsConverter) VisitableURLClassLoader(org.gradle.internal.classloader.VisitableURLClassLoader) MinimalGroovyCompilerDaemonForkOptions(org.gradle.api.internal.tasks.compile.MinimalGroovyCompilerDaemonForkOptions) FilteringClassLoader(org.gradle.internal.classloader.FilteringClassLoader) HierarchicalClassLoaderStructure(org.gradle.workers.internal.HierarchicalClassLoaderStructure) JavaForkOptions(org.gradle.process.JavaForkOptions) GroovyJavaJointCompileSpec(org.gradle.api.internal.tasks.compile.GroovyJavaJointCompileSpec) File(java.io.File) MinimalJavaCompilerDaemonForkOptions(org.gradle.api.internal.tasks.compile.MinimalJavaCompilerDaemonForkOptions)

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