Search in sources :

Example 1 with HierarchicalClassLoaderStructure

use of org.gradle.workers.internal.HierarchicalClassLoaderStructure 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)

Example 2 with HierarchicalClassLoaderStructure

use of org.gradle.workers.internal.HierarchicalClassLoaderStructure 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)

Aggregations

BaseForkOptionsConverter (org.gradle.api.internal.tasks.compile.BaseForkOptionsConverter)2 MinimalJavaCompilerDaemonForkOptions (org.gradle.api.internal.tasks.compile.MinimalJavaCompilerDaemonForkOptions)2 VisitableURLClassLoader (org.gradle.internal.classloader.VisitableURLClassLoader)2 JavaForkOptions (org.gradle.process.JavaForkOptions)2 DaemonForkOptionsBuilder (org.gradle.workers.internal.DaemonForkOptionsBuilder)2 HierarchicalClassLoaderStructure (org.gradle.workers.internal.HierarchicalClassLoaderStructure)2 File (java.io.File)1 GroovyJavaJointCompileSpec (org.gradle.api.internal.tasks.compile.GroovyJavaJointCompileSpec)1 MinimalGroovyCompilerDaemonForkOptions (org.gradle.api.internal.tasks.compile.MinimalGroovyCompilerDaemonForkOptions)1 FilteringClassLoader (org.gradle.internal.classloader.FilteringClassLoader)1 ClassPath (org.gradle.internal.classpath.ClassPath)1 DefaultClassPath (org.gradle.internal.classpath.DefaultClassPath)1