org.gradle.internal.classpath.DefaultClassPath Java Examples

The following examples show how to use org.gradle.internal.classpath.DefaultClassPath. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InProcessCompilerDaemonFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CompilerDaemon getDaemon(File workingDir, final DaemonForkOptions forkOptions) {
    return new CompilerDaemon() {
        public <T extends CompileSpec> CompileResult execute(Compiler<T> compiler, T spec) {
            ClassLoader groovyClassLoader = classLoaderFactory.createIsolatedClassLoader(new DefaultClassPath(forkOptions.getClasspath()));
            FilteringClassLoader filteredGroovy = classLoaderFactory.createFilteringClassLoader(groovyClassLoader);
            for (String packageName : forkOptions.getSharedPackages()) {
                filteredGroovy.allowPackage(packageName);
            }

            ClassLoader workerClassLoader = new MutableURLClassLoader(filteredGroovy, ClasspathUtil.getClasspath(compiler.getClass().getClassLoader()));

            try {
                byte[] serializedWorker = GUtil.serialize(new Worker<T>(compiler, spec));
                ClassLoaderObjectInputStream inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedWorker), workerClassLoader);
                Callable<?> worker = (Callable<?>) inputStream.readObject();
                Object result = worker.call();
                byte[] serializedResult = GUtil.serialize(result);
                inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedResult), getClass().getClassLoader());
                return (CompileResult) inputStream.readObject();
            } catch (Exception e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    };
}
 
Example #2
Source File: DistributionFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ClassPath getToolingImpl() {
    if (!gradleHomeDir.exists()) {
        throw new IllegalArgumentException(String.format("The specified %s does not exist.", locationDisplayName));
    }
    if (!gradleHomeDir.isDirectory()) {
        throw new IllegalArgumentException(String.format("The specified %s is not a directory.", locationDisplayName));
    }
    File libDir = new File(gradleHomeDir, "lib");
    if (!libDir.isDirectory()) {
        throw new IllegalArgumentException(String.format("The specified %s does not appear to contain a Gradle distribution.", locationDisplayName));
    }
    Set<File> files = new LinkedHashSet<File>();
    for (File file : libDir.listFiles()) {
        if (file.getName().endsWith(".jar")) {
            files.add(file);
        }
    }
    return new DefaultClassPath(files);
}
 
Example #3
Source File: InProcessCompilerDaemonFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CompilerDaemon getDaemon(File workingDir, final DaemonForkOptions forkOptions) {
    return new CompilerDaemon() {
        public <T extends CompileSpec> CompileResult execute(Compiler<T> compiler, T spec) {
            ClassLoader groovyClassLoader = classLoaderFactory.createIsolatedClassLoader(new DefaultClassPath(forkOptions.getClasspath()));
            FilteringClassLoader filteredGroovy = classLoaderFactory.createFilteringClassLoader(groovyClassLoader);
            for (String packageName : forkOptions.getSharedPackages()) {
                filteredGroovy.allowPackage(packageName);
            }

            ClassLoader workerClassLoader = new MutableURLClassLoader(filteredGroovy, ClasspathUtil.getClasspath(compiler.getClass().getClassLoader()));

            try {
                byte[] serializedWorker = GUtil.serialize(new Worker<T>(compiler, spec));
                ClassLoaderObjectInputStream inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedWorker), workerClassLoader);
                Callable<?> worker = (Callable<?>) inputStream.readObject();
                Object result = worker.call();
                byte[] serializedResult = GUtil.serialize(result);
                inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedResult), getClass().getClassLoader());
                return (CompileResult) inputStream.readObject();
            } catch (Exception e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    };
}
 
Example #4
Source File: PluginResolutionServiceResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ClassPath resolvePluginDependencies(final PluginUseMetaData metadata) {
    DependencyResolutionServices resolution = dependencyResolutionServicesFactory.create();

    RepositoryHandler repositories = resolution.getResolveRepositoryHandler();
    final String repoUrl = metadata.implementation.get("repo");
    repositories.maven(new Action<MavenArtifactRepository>() {
        public void execute(MavenArtifactRepository mavenArtifactRepository) {
            mavenArtifactRepository.setUrl(repoUrl);
        }
    });

    Dependency dependency = resolution.getDependencyHandler().create(metadata.implementation.get("gav"));

    ConfigurationContainerInternal configurations = (ConfigurationContainerInternal) resolution.getConfigurationContainer();
    ConfigurationInternal configuration = configurations.detachedConfiguration(dependency);

    try {
        Set<File> files = configuration.getResolvedConfiguration().getFiles(Specs.satisfyAll());
        return new DefaultClassPath(files);
    } catch (ResolveException e) {
        throw new DependencyResolutionException("Failed to resolve all plugin dependencies from " + repoUrl, e.getCause());
    }
}
 
Example #5
Source File: PlayWorkerServer.java    From playframework with Apache License 2.0 6 votes vote down vote up
private InetSocketAddress startServer() {
    ClassLoaderUtils.disableUrlConnectionCaching();
    final Thread thread = Thread.currentThread();
    final ClassLoader previousContextClassLoader = thread.getContextClassLoader();
    final ClassLoader classLoader = new URLClassLoader(DefaultClassPath.of(runSpec.getClasspath()).getAsURLArray(), ClassLoader.getSystemClassLoader());
    thread.setContextClassLoader(classLoader);
    try {
        Object buildDocHandler = runAdapter.getBuildDocHandler(classLoader, runSpec.getClasspath());
        Object buildLink = runAdapter.getBuildLink(classLoader, this, runSpec.getProjectPath(), runSpec.getApplicationJar(), runSpec.getChangingClasspath(), runSpec.getAssetsJar(), runSpec.getAssetsDirs());
        return runAdapter.runDevHttpServer(classLoader, classLoader, buildLink, buildDocHandler, runSpec.getHttpPort());
    } catch (Exception e) {
        throw UncheckedException.throwAsUncheckedException(e);
    } finally {
        thread.setContextClassLoader(previousContextClassLoader);
    }
}
 
Example #6
Source File: DependencyClassPathProvider.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ClassPath findClassPath(String name) {
    if (name.equals(GRADLE_API.name())) {
        ClassPath classpath = new DefaultClassPath();
        for (String moduleName : Arrays.asList("gradle-core", "gradle-dependency-management", "gradle-plugin-use", "gradle-tooling-api")) {
            for (Module module : moduleRegistry.getModule(moduleName).getAllRequiredModules()) {
                classpath = classpath.plus(module.getClasspath());
            }
        }
        for (Module pluginModule : pluginModuleRegistry.getPluginModules()) {
            classpath = classpath.plus(pluginModule.getClasspath());
        }
        return classpath;
    }
    if (name.equals(LOCAL_GROOVY.name())) {
        return moduleRegistry.getExternalModule("groovy-all").getClasspath();
    }

    return null;
}
 
Example #7
Source File: InProcessCompilerDaemonFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CompilerDaemon getDaemon(File workingDir, final DaemonForkOptions forkOptions) {
    return new CompilerDaemon() {
        public <T extends CompileSpec> CompileResult execute(Compiler<T> compiler, T spec) {
            ClassLoader groovyClassLoader = classLoaderFactory.createIsolatedClassLoader(new DefaultClassPath(forkOptions.getClasspath()));
            FilteringClassLoader filteredGroovy = classLoaderFactory.createFilteringClassLoader(groovyClassLoader);
            for (String packageName : forkOptions.getSharedPackages()) {
                filteredGroovy.allowPackage(packageName);
            }

            ClassLoader workerClassLoader = new MutableURLClassLoader(filteredGroovy, ClasspathUtil.getClasspath(compiler.getClass().getClassLoader()));

            try {
                byte[] serializedWorker = GUtil.serialize(new Worker<T>(compiler, spec));
                ClassLoaderObjectInputStream inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedWorker), workerClassLoader);
                Callable<?> worker = (Callable<?>) inputStream.readObject();
                Object result = worker.call();
                byte[] serializedResult = GUtil.serialize(result);
                inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedResult), getClass().getClassLoader());
                return (CompileResult) inputStream.readObject();
            } catch (Exception e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    };
}
 
Example #8
Source File: DynamicModulesClassPathProvider.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ClassPath findClassPath(String name) {
    if (name.equals("GRADLE_EXTENSIONS")) {
        Set<Module> coreModules = moduleRegistry.getModule("gradle-core").getAllRequiredModules();
        ClassPath classpath = new DefaultClassPath();
        for (String moduleName : Arrays.asList("gradle-dependency-management", "gradle-plugin-use")) {
            for (Module module : moduleRegistry.getModule(moduleName).getAllRequiredModules()) {
                if (!coreModules.contains(module)) {
                    classpath = classpath.plus(module.getClasspath());
                }
            }
        }
        for (Module pluginModule : pluginModuleRegistry.getPluginModules()) {
            classpath = classpath.plus(pluginModule.getClasspath());
        }
        return classpath;
    }

    return null;
}
 
Example #9
Source File: BuildSrcUpdateFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DefaultClassPath create() {
    File markerFile = new File(cache.getBaseDir(), "built.bin");
    final boolean rebuild = !markerFile.exists();

    BuildSrcBuildListenerFactory.Listener listener = listenerFactory.create(rebuild);
    gradleLauncher.addListener(listener);
    gradleLauncher.run().rethrowFailure();

    Collection<File> classpath = listener.getRuntimeClasspath();
    LOGGER.debug("Gradle source classpath is: {}", classpath);
    LOGGER.info("================================================" + " Finished building buildSrc");
    try {
        markerFile.createNewFile();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return new DefaultClassPath(classpath);
}
 
Example #10
Source File: BuildSrcUpdateFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DefaultClassPath create() {
    File markerFile = new File(cache.getBaseDir(), "built.bin");
    final boolean rebuild = !markerFile.exists();

    BuildSrcBuildListenerFactory.Listener listener = listenerFactory.create(rebuild);
    gradleLauncher.addListener(listener);
    gradleLauncher.run().rethrowFailure();

    Collection<File> classpath = listener.getRuntimeClasspath();
    LOGGER.debug("Gradle source classpath is: {}", classpath);
    LOGGER.info("================================================" + " Finished building buildSrc");
    try {
        markerFile.createNewFile();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return new DefaultClassPath(classpath);
}
 
Example #11
Source File: DependencyClassPathProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ClassPath findClassPath(String name) {
    if (name.equals(GRADLE_API.name())) {
        ClassPath classpath = new DefaultClassPath();
        Module core = moduleRegistry.getModule("gradle-core");
        for (Module module : core.getAllRequiredModules()) {
            classpath = classpath.plus(module.getClasspath());
        }
        classpath = classpath.plus(moduleRegistry.getModule("gradle-core-impl").getClasspath());
        try {
            classpath = classpath.plus(moduleRegistry.getModule("gradle-tooling-api").getImplementationClasspath());
        } catch (UnknownModuleException e) {
            // Ignore
        }
        for (Module pluginModule : pluginModuleRegistry.getPluginModules()) {
            classpath = classpath.plus(pluginModule.getClasspath());
        }
        return classpath;
    }
    if (name.equals(LOCAL_GROOVY.name())) {
        return moduleRegistry.getExternalModule("groovy-all").getClasspath();
    }

    return null;
}
 
Example #12
Source File: BuildSrcUpdateFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DefaultClassPath create() {
    File markerFile = new File(cache.getBaseDir(), "built.bin");
    final boolean rebuild = !markerFile.exists();

    BuildSrcBuildListenerFactory.Listener listener = listenerFactory.create(rebuild);
    gradleLauncher.addListener(listener);
    gradleLauncher.run().rethrowFailure();

    Collection<File> classpath = listener.getRuntimeClasspath();
    LOGGER.debug("Gradle source classpath is: {}", classpath);
    LOGGER.info("================================================" + " Finished building buildSrc");
    try {
        markerFile.createNewFile();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return new DefaultClassPath(classpath);
}
 
Example #13
Source File: PluginResolutionServiceResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ClassPath resolvePluginDependencies(final PluginUseMetaData metadata) {
    DependencyResolutionServices resolution = dependencyResolutionServicesFactory.create();

    RepositoryHandler repositories = resolution.getResolveRepositoryHandler();
    final String repoUrl = metadata.implementation.get("repo");
    repositories.maven(new Action<MavenArtifactRepository>() {
        public void execute(MavenArtifactRepository mavenArtifactRepository) {
            mavenArtifactRepository.setUrl(repoUrl);
        }
    });

    Dependency dependency = resolution.getDependencyHandler().create(metadata.implementation.get("gav"));

    ConfigurationContainerInternal configurations = (ConfigurationContainerInternal) resolution.getConfigurationContainer();
    ConfigurationInternal configuration = configurations.detachedConfiguration(dependency);

    try {
        Set<File> files = configuration.getResolvedConfiguration().getFiles(Specs.satisfyAll());
        return new DefaultClassPath(files);
    } catch (ResolveException e) {
        throw new DependencyResolutionException("Failed to resolve all plugin dependencies from " + repoUrl, e.getCause());
    }
}
 
Example #14
Source File: DistributionFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ClassPath getToolingImpl() {
    if (!gradleHomeDir.exists()) {
        throw new IllegalArgumentException(String.format("The specified %s does not exist.", locationDisplayName));
    }
    if (!gradleHomeDir.isDirectory()) {
        throw new IllegalArgumentException(String.format("The specified %s is not a directory.", locationDisplayName));
    }
    File libDir = new File(gradleHomeDir, "lib");
    if (!libDir.isDirectory()) {
        throw new IllegalArgumentException(String.format("The specified %s does not appear to contain a Gradle distribution.", locationDisplayName));
    }
    Set<File> files = new LinkedHashSet<File>();
    for (File file : libDir.listFiles()) {
        if (file.getName().endsWith(".jar")) {
            files.add(file);
        }
    }
    return new DefaultClassPath(files);
}
 
Example #15
Source File: DistributionFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ClassPath getToolingImpl() {
    if (!gradleHomeDir.exists()) {
        throw new IllegalArgumentException(String.format("The specified %s does not exist.", locationDisplayName));
    }
    if (!gradleHomeDir.isDirectory()) {
        throw new IllegalArgumentException(String.format("The specified %s is not a directory.", locationDisplayName));
    }
    File libDir = new File(gradleHomeDir, "lib");
    if (!libDir.isDirectory()) {
        throw new IllegalArgumentException(String.format("The specified %s does not appear to contain a Gradle distribution.", locationDisplayName));
    }
    Set<File> files = new LinkedHashSet<File>();
    for (File file : libDir.listFiles()) {
        if (file.getName().endsWith(".jar")) {
            files.add(file);
        }
    }
    return new DefaultClassPath(files);
}
 
Example #16
Source File: DistributionFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ClassPath getToolingImpl() {
    if (!gradleHomeDir.exists()) {
        throw new IllegalArgumentException(String.format("The specified %s does not exist.", locationDisplayName));
    }
    if (!gradleHomeDir.isDirectory()) {
        throw new IllegalArgumentException(String.format("The specified %s is not a directory.", locationDisplayName));
    }
    File libDir = new File(gradleHomeDir, "lib");
    if (!libDir.isDirectory()) {
        throw new IllegalArgumentException(String.format("The specified %s does not appear to contain a Gradle distribution.", locationDisplayName));
    }
    Set<File> files = new LinkedHashSet<File>();
    for (File file : libDir.listFiles()) {
        if (file.getName().endsWith(".jar")) {
            files.add(file);
        }
    }
    return new DefaultClassPath(files);
}
 
Example #17
Source File: InProcessCompilerDaemonFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public CompilerDaemon getDaemon(File workingDir, final DaemonForkOptions forkOptions) {
    return new CompilerDaemon() {
        public <T extends CompileSpec> CompileResult execute(Compiler<T> compiler, T spec) {
            ClassLoader groovyClassLoader = classLoaderFactory.createIsolatedClassLoader(new DefaultClassPath(forkOptions.getClasspath()));
            FilteringClassLoader filteredGroovy = classLoaderFactory.createFilteringClassLoader(groovyClassLoader);
            for (String packageName : forkOptions.getSharedPackages()) {
                filteredGroovy.allowPackage(packageName);
            }

            ClassLoader workerClassLoader = new MutableURLClassLoader(filteredGroovy, ClasspathUtil.getClasspath(compiler.getClass().getClassLoader()));

            try {
                byte[] serializedWorker = GUtil.serialize(new Worker<T>(compiler, spec));
                ClassLoaderObjectInputStream inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedWorker), workerClassLoader);
                Callable<?> worker = (Callable<?>) inputStream.readObject();
                Object result = worker.call();
                byte[] serializedResult = GUtil.serialize(result);
                inputStream = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedResult), getClass().getClassLoader());
                return (CompileResult) inputStream.readObject();
            } catch (Exception e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    };
}
 
Example #18
Source File: BuildSrcUpdateFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DefaultClassPath create() {
    File markerFile = new File(cache.getBaseDir(), "built.bin");
    final boolean rebuild = !markerFile.exists();

    BuildSrcBuildListenerFactory.Listener listener = listenerFactory.create(rebuild);
    gradleLauncher.addListener(listener);
    gradleLauncher.run().rethrowFailure();

    Collection<File> classpath = listener.getRuntimeClasspath();
    LOGGER.debug("Gradle source classpath is: {}", classpath);
    LOGGER.info("================================================" + " Finished building buildSrc");
    try {
        markerFile.createNewFile();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return new DefaultClassPath(classpath);
}
 
Example #19
Source File: DependencyClassPathProvider.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ClassPath findClassPath(String name) {
    if (name.equals(GRADLE_API.name())) {
        ClassPath classpath = new DefaultClassPath();
        Module core = moduleRegistry.getModule("gradle-core");
        for (Module module : core.getAllRequiredModules()) {
            classpath = classpath.plus(module.getClasspath());
        }
        classpath = classpath.plus(moduleRegistry.getModule("gradle-core-impl").getClasspath());
        try {
            classpath = classpath.plus(moduleRegistry.getModule("gradle-tooling-api").getImplementationClasspath());
        } catch (UnknownModuleException e) {
            // Ignore
        }
        for (Module pluginModule : pluginModuleRegistry.getPluginModules()) {
            classpath = classpath.plus(pluginModule.getClasspath());
        }
        return classpath;
    }
    if (name.equals(LOCAL_GROOVY.name())) {
        return moduleRegistry.getExternalModule("groovy-all").getClasspath();
    }

    return null;
}
 
Example #20
Source File: DependencyClassPathProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ClassPath findClassPath(String name) {
    if (name.equals(GRADLE_API.name())) {
        ClassPath classpath = new DefaultClassPath();
        for (String moduleName : Arrays.asList("gradle-core", "gradle-dependency-management", "gradle-plugin-use", "gradle-tooling-api")) {
            for (Module module : moduleRegistry.getModule(moduleName).getAllRequiredModules()) {
                classpath = classpath.plus(module.getClasspath());
            }
        }
        for (Module pluginModule : pluginModuleRegistry.getPluginModules()) {
            classpath = classpath.plus(pluginModule.getClasspath());
        }
        return classpath;
    }
    if (name.equals(LOCAL_GROOVY.name())) {
        return moduleRegistry.getExternalModule("groovy-all").getClasspath();
    }

    return null;
}
 
Example #21
Source File: DynamicModulesClassPathProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ClassPath findClassPath(String name) {
    if (name.equals("GRADLE_EXTENSIONS")) {
        Set<Module> coreModules = moduleRegistry.getModule("gradle-core").getAllRequiredModules();
        ClassPath classpath = new DefaultClassPath();
        for (String moduleName : Arrays.asList("gradle-dependency-management", "gradle-plugin-use")) {
            for (Module module : moduleRegistry.getModule(moduleName).getAllRequiredModules()) {
                if (!coreModules.contains(module)) {
                    classpath = classpath.plus(module.getClasspath());
                }
            }
        }
        for (Module pluginModule : pluginModuleRegistry.getPluginModules()) {
            classpath = classpath.plus(pluginModule.getClasspath());
        }
        return classpath;
    }

    return null;
}
 
Example #22
Source File: DynamicModulesClassPathProvider.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ClassPath findClassPath(String name) {
    if (name.equals("GRADLE_PLUGINS")) {
        ClassPath classpath = new DefaultClassPath();
        for (Module pluginModule : pluginModuleRegistry.getPluginModules()) {
            classpath = classpath.plus(pluginModule.getClasspath());
        }
        return classpath;
    }
    if (name.equals("GRADLE_CORE_IMPL")) {
        return moduleRegistry.getModule("gradle-core-impl").getClasspath();
    }

    return null;
}
 
Example #23
Source File: AbstractJettyRunTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
protected void start() {
    ClassLoader originalClassloader = Server.class.getClassLoader();
    List<File> additionalClasspath = new ArrayList<File>();
    for (File additionalRuntimeJar : getAdditionalRuntimeJars()) {
        additionalClasspath.add(additionalRuntimeJar);
    }
    URLClassLoader jettyClassloader = new URLClassLoader(new DefaultClassPath(additionalClasspath).getAsURLArray(), originalClassloader);
    try {
        Thread.currentThread().setContextClassLoader(jettyClassloader);
        startJetty();
    } finally {
        Thread.currentThread().setContextClassLoader(originalClassloader);
    }
}
 
Example #24
Source File: DefaultModuleRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultModule(String name, Set<File> implementationClasspath, Set<File> runtimeClasspath, Set<Module> modules) {
    this.name = name;
    this.implementationClasspath = new DefaultClassPath(implementationClasspath);
    this.runtimeClasspath = new DefaultClassPath(runtimeClasspath);
    this.modules = modules;
    Set<File> classpath = new LinkedHashSet<File>();
    classpath.addAll(implementationClasspath);
    classpath.addAll(runtimeClasspath);
    this.classpath = new DefaultClassPath(classpath);
}
 
Example #25
Source File: DefaultModuleRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultModule(String name, Set<File> implementationClasspath, Set<File> runtimeClasspath, Set<Module> modules) {
    this.name = name;
    this.implementationClasspath = new DefaultClassPath(implementationClasspath);
    this.runtimeClasspath = new DefaultClassPath(runtimeClasspath);
    this.modules = modules;
    Set<File> classpath = new LinkedHashSet<File>();
    classpath.addAll(implementationClasspath);
    classpath.addAll(runtimeClasspath);
    this.classpath = new DefaultClassPath(classpath);
}
 
Example #26
Source File: AbstractJettyRunTask.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
protected void start() {
    ClassLoader originalClassloader = Server.class.getClassLoader();
    List<File> additionalClasspath = new ArrayList<File>();
    for (File additionalRuntimeJar : getAdditionalRuntimeJars()) {
        additionalClasspath.add(additionalRuntimeJar);
    }
    URLClassLoader jettyClassloader = new URLClassLoader(new DefaultClassPath(additionalClasspath).getAsURLArray(), originalClassloader);
    try {
        Thread.currentThread().setContextClassLoader(jettyClassloader);
        startJetty();
    } finally {
        Thread.currentThread().setContextClassLoader(originalClassloader);
    }
}
 
Example #27
Source File: DefaultClassLoaderRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void initializeJdkTools() {
    // Add in tools.jar to the systemClassloader parent
    File toolsJar = Jvm.current().getToolsJar();
    if (toolsJar != null) {
        final ClassLoader systemClassLoaderParent = ClassLoader.getSystemClassLoader().getParent();
        ClasspathUtil.addUrl((URLClassLoader) systemClassLoaderParent, new DefaultClassPath(toolsJar).getAsURLs());
    }
}
 
Example #28
Source File: ApplicationClassesInIsolatedClassLoaderWorkerFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Callable<?> create() {
    Collection<URI> applicationClassPath = new DefaultClassPath(processBuilder.getApplicationClasspath()).getAsURIs();
    ActionExecutionWorker injectedWorker = new ActionExecutionWorker(processBuilder.getWorker(), workerId,
            displayName, serverAddress);
    ImplementationClassLoaderWorker worker = new ImplementationClassLoaderWorker(processBuilder.getLogLevel(),
            processBuilder.getSharedPackages(), implementationClassPath, injectedWorker);
    return new IsolatedApplicationClassLoaderWorker(applicationClassPath, worker);
}
 
Example #29
Source File: DefaultPluginRequestApplicator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void defineScriptHandlerClassScope(ScriptHandler scriptHandler, ClassLoaderScope classLoaderScope) {
    Configuration classpathConfiguration = scriptHandler.getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION);
    Set<File> files = classpathConfiguration.getFiles();
    ClassPath classPath = new DefaultClassPath(files);
    classLoaderScope.export(classPath);
    classLoaderScope.lock();
}
 
Example #30
Source File: DefaultPluginRequestApplicator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void defineScriptHandlerClassScope(ScriptHandler scriptHandler, ClassLoaderScope classLoaderScope) {
    Configuration classpathConfiguration = scriptHandler.getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION);
    Set<File> files = classpathConfiguration.getFiles();
    ClassPath classPath = new DefaultClassPath(files);
    classLoaderScope.export(classPath);
    classLoaderScope.lock();
}