Search in sources :

Example 6 with ClassPath

use of org.gradle.internal.classpath.ClassPath in project gradle by gradle.

the class FinalizerThread method run.

public void run() {
    try {
        while (!stopped.get()) {
            Cleanup entry = (Cleanup) referenceQueue.remove();
            ClassPath key = entry.getKey();
            removeCacheEntry(key, entry, DONT_CLOSE_CLASSLOADER);
        }
    } catch (InterruptedException ex) {
        LOG.debug("Shutdown of classloader cache in progress");
    }
}
Also used : ClassPath(org.gradle.internal.classpath.ClassPath)

Example 7 with ClassPath

use of org.gradle.internal.classpath.ClassPath in project gradle by gradle.

the class CachingToolingImplementationLoader method create.

public ConsumerConnection create(Distribution distribution, ProgressLoggerFactory progressLoggerFactory, InternalBuildProgressListener progressListener, ConnectionParameters connectionParameters, BuildCancellationToken cancellationToken) {
    ClassPath classpath = distribution.getToolingImplementationClasspath(progressLoggerFactory, progressListener, connectionParameters.getGradleUserHomeDir(), cancellationToken);
    ConsumerConnection connection = connections.get(classpath);
    if (connection == null) {
        connection = loader.create(distribution, progressLoggerFactory, progressListener, connectionParameters, cancellationToken);
        connections.put(classpath, connection);
    }
    return connection;
}
Also used : ClassPath(org.gradle.internal.classpath.ClassPath) ConsumerConnection(org.gradle.tooling.internal.consumer.connection.ConsumerConnection)

Example 8 with ClassPath

use of org.gradle.internal.classpath.ClassPath in project gradle by gradle.

the class ValidateTaskProperties method validateTaskClasses.

@TaskAction
public void validateTaskClasses() throws IOException {
    ClassLoader previousContextClassLoader = Thread.currentThread().getContextClassLoader();
    ClassPath classPath = new DefaultClassPath(Iterables.concat(Collections.singleton(getClassesDir()), getClasspath()));
    ClassLoader classLoader = getClassLoaderFactory().createIsolatedClassLoader(classPath);
    Thread.currentThread().setContextClassLoader(classLoader);
    try {
        validateTaskClasses(classLoader);
    } finally {
        Thread.currentThread().setContextClassLoader(previousContextClassLoader);
        ClassLoaderUtils.tryClose(classLoader);
    }
}
Also used : DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath) ClassPath(org.gradle.internal.classpath.ClassPath) DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath) TaskAction(org.gradle.api.tasks.TaskAction)

Example 9 with ClassPath

use of org.gradle.internal.classpath.ClassPath in project gradle by gradle.

the class DefaultPluginRequestApplicator method defineScriptHandlerClassScope.

private void defineScriptHandlerClassScope(ScriptHandlerInternal scriptHandler, ClassLoaderScope classLoaderScope, Iterable<PluginImplementation<?>> pluginsFromOtherLoaders) {
    ClassPath classPath = scriptHandler.getScriptClassPath();
    ClassPath cachedJarClassPath = cachedClasspathTransformer.transform(classPath);
    classLoaderScope.export(cachedJarClassPath);
    for (PluginImplementation<?> pluginImplementation : pluginsFromOtherLoaders) {
        classLoaderScope.export(pluginImplementation.asClass().getClassLoader());
    }
    classLoaderScope.lock();
}
Also used : ClassPath(org.gradle.internal.classpath.ClassPath)

Example 10 with ClassPath

use of org.gradle.internal.classpath.ClassPath in project gradle by gradle.

the class ClassPathPluginResolution method execute.

@Override
public void execute(PluginResolveContext pluginResolveContext) {
    ClassPath classPath = classPathFactory.create();
    ClassLoaderScope loaderScope = parent.createChild("plugin-" + pluginId.getId());
    loaderScope.local(classPath);
    loaderScope.lock();
    PluginRegistry pluginRegistry = new DefaultPluginRegistry(pluginInspector, loaderScope);
    PluginImplementation<?> plugin = pluginRegistry.lookup(pluginId);
    if (plugin == null) {
        throw new UnknownPluginException("Plugin with id '" + pluginId + "' not found.");
    }
    pluginResolveContext.add(plugin);
}
Also used : ClassPath(org.gradle.internal.classpath.ClassPath) DefaultPluginRegistry(org.gradle.api.internal.plugins.DefaultPluginRegistry) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) PluginRegistry(org.gradle.api.internal.plugins.PluginRegistry) DefaultPluginRegistry(org.gradle.api.internal.plugins.DefaultPluginRegistry) UnknownPluginException(org.gradle.api.plugins.UnknownPluginException)

Aggregations

ClassPath (org.gradle.internal.classpath.ClassPath)14 DefaultClassPath (org.gradle.internal.classpath.DefaultClassPath)7 File (java.io.File)3 IOException (java.io.IOException)3 Module (org.gradle.api.internal.classpath.Module)3 Method (java.lang.reflect.Method)2 UncheckedIOException (org.gradle.api.UncheckedIOException)2 DefaultModuleRegistry (org.gradle.api.internal.classpath.DefaultModuleRegistry)2 ClassLoaderScope (org.gradle.api.internal.initialization.ClassLoaderScope)2 VisitableURLClassLoader (org.gradle.internal.classloader.VisitableURLClassLoader)2 StreamByteBuffer (org.gradle.internal.io.StreamByteBuffer)2 EncodedStream (org.gradle.process.internal.streams.EncodedStream)2 DataOutputStream (java.io.DataOutputStream)1 InputStream (java.io.InputStream)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1