Search in sources :

Example 1 with ClassPathRegistry

use of org.gradle.api.internal.ClassPathRegistry in project gradle by gradle.

the class ScalaCompile method getCompiler.

@Override
protected org.gradle.language.base.internal.compile.Compiler<ScalaJavaJointCompileSpec> getCompiler(ScalaJavaJointCompileSpec spec) {
    assertScalaClasspathIsNonEmpty();
    if (compiler == null) {
        WorkerDaemonFactory workerDaemonFactory = getServices().get(WorkerDaemonFactory.class);
        JavaForkOptionsFactory forkOptionsFactory = getServices().get(JavaForkOptionsFactory.class);
        ClassPathRegistry classPathRegistry = getServices().get(ClassPathRegistry.class);
        ClassLoaderRegistry classLoaderRegistry = getServices().get(ClassLoaderRegistry.class);
        ActionExecutionSpecFactory actionExecutionSpecFactory = getServices().get(ActionExecutionSpecFactory.class);
        ScalaCompilerFactory scalaCompilerFactory = new ScalaCompilerFactory(getServices().get(WorkerDirectoryProvider.class).getWorkingDirectory(), workerDaemonFactory, getScalaClasspath(), getZincClasspath(), forkOptionsFactory, classPathRegistry, classLoaderRegistry, actionExecutionSpecFactory, getServices().get(ClasspathHasher.class));
        compiler = scalaCompilerFactory.newCompiler(spec);
    }
    return compiler;
}
Also used : ActionExecutionSpecFactory(org.gradle.workers.internal.ActionExecutionSpecFactory) JavaForkOptionsFactory(org.gradle.process.internal.JavaForkOptionsFactory) ClassLoaderRegistry(org.gradle.initialization.ClassLoaderRegistry) ScalaCompilerFactory(org.gradle.api.internal.tasks.scala.ScalaCompilerFactory) ClasspathHasher(org.gradle.internal.classloader.ClasspathHasher) WorkerDaemonFactory(org.gradle.workers.internal.WorkerDaemonFactory) ClassPathRegistry(org.gradle.api.internal.ClassPathRegistry)

Example 2 with ClassPathRegistry

use of org.gradle.api.internal.ClassPathRegistry in project gradle by gradle.

the class ProcessBootstrap method runNoExit.

private static void runNoExit(String mainClassName, String[] args) throws Exception {
    ClassPathRegistry classPathRegistry = new DefaultClassPathRegistry(new DefaultClassPathProvider(new DefaultModuleRegistry(CurrentGradleInstallation.get())));
    ClassLoaderFactory classLoaderFactory = new DefaultClassLoaderFactory();
    ClassPath antClasspath = classPathRegistry.getClassPath("ANT");
    ClassPath runtimeClasspath = classPathRegistry.getClassPath("GRADLE_RUNTIME");
    ClassLoader antClassLoader = classLoaderFactory.createIsolatedClassLoader("ant-loader", antClasspath);
    ClassLoader runtimeClassLoader = new VisitableURLClassLoader("ant-and-gradle-loader", antClassLoader, runtimeClasspath);
    ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(runtimeClassLoader);
    try {
        Class<?> mainClass = runtimeClassLoader.loadClass(mainClassName);
        Object entryPoint = mainClass.getConstructor().newInstance();
        Method mainMethod = mainClass.getMethod("run", String[].class);
        mainMethod.invoke(entryPoint, new Object[] { args });
    } finally {
        Thread.currentThread().setContextClassLoader(oldClassLoader);
        ClassLoaderUtils.tryClose(runtimeClassLoader);
        ClassLoaderUtils.tryClose(antClassLoader);
    }
}
Also used : DefaultClassLoaderFactory(org.gradle.internal.classloader.DefaultClassLoaderFactory) ClassPath(org.gradle.internal.classpath.ClassPath) ClassLoaderFactory(org.gradle.internal.classloader.ClassLoaderFactory) DefaultClassLoaderFactory(org.gradle.internal.classloader.DefaultClassLoaderFactory) VisitableURLClassLoader(org.gradle.internal.classloader.VisitableURLClassLoader) DefaultClassPathProvider(org.gradle.api.internal.DefaultClassPathProvider) Method(java.lang.reflect.Method) ClassPathRegistry(org.gradle.api.internal.ClassPathRegistry) DefaultClassPathRegistry(org.gradle.api.internal.DefaultClassPathRegistry) DefaultModuleRegistry(org.gradle.api.internal.classpath.DefaultModuleRegistry) DefaultClassPathRegistry(org.gradle.api.internal.DefaultClassPathRegistry) VisitableURLClassLoader(org.gradle.internal.classloader.VisitableURLClassLoader)

Aggregations

ClassPathRegistry (org.gradle.api.internal.ClassPathRegistry)2 Method (java.lang.reflect.Method)1 DefaultClassPathProvider (org.gradle.api.internal.DefaultClassPathProvider)1 DefaultClassPathRegistry (org.gradle.api.internal.DefaultClassPathRegistry)1 DefaultModuleRegistry (org.gradle.api.internal.classpath.DefaultModuleRegistry)1 ScalaCompilerFactory (org.gradle.api.internal.tasks.scala.ScalaCompilerFactory)1 ClassLoaderRegistry (org.gradle.initialization.ClassLoaderRegistry)1 ClassLoaderFactory (org.gradle.internal.classloader.ClassLoaderFactory)1 ClasspathHasher (org.gradle.internal.classloader.ClasspathHasher)1 DefaultClassLoaderFactory (org.gradle.internal.classloader.DefaultClassLoaderFactory)1 VisitableURLClassLoader (org.gradle.internal.classloader.VisitableURLClassLoader)1 ClassPath (org.gradle.internal.classpath.ClassPath)1 JavaForkOptionsFactory (org.gradle.process.internal.JavaForkOptionsFactory)1 ActionExecutionSpecFactory (org.gradle.workers.internal.ActionExecutionSpecFactory)1 WorkerDaemonFactory (org.gradle.workers.internal.WorkerDaemonFactory)1