Search in sources :

Example 1 with ProcessWorkerSpec

use of org.gradle.workers.ProcessWorkerSpec in project gradle by gradle.

the class DefaultWorkerConfiguration method adaptTo.

void adaptTo(WorkerSpec workerSpec) {
    if (workerSpec instanceof ClassLoaderWorkerSpec) {
        ClassLoaderWorkerSpec classLoaderWorkerSpec = (ClassLoaderWorkerSpec) workerSpec;
        classLoaderWorkerSpec.getClasspath().from(getClasspath());
    }
    if (workerSpec instanceof ProcessWorkerSpec) {
        ProcessWorkerSpec processWorkerSpec = (ProcessWorkerSpec) workerSpec;
        processWorkerSpec.getClasspath().from(getClasspath());
        getForkOptions().copyTo(processWorkerSpec.getForkOptions());
    }
}
Also used : ClassLoaderWorkerSpec(org.gradle.workers.ClassLoaderWorkerSpec) ProcessWorkerSpec(org.gradle.workers.ProcessWorkerSpec)

Example 2 with ProcessWorkerSpec

use of org.gradle.workers.ProcessWorkerSpec in project gradle by gradle.

the class DefaultWorkerExecutor method getWorkerRequirement.

WorkerRequirement getWorkerRequirement(Class<?> executionClass, WorkerSpec configuration, WorkParameters parameters) {
    if (configuration instanceof ProcessWorkerSpec) {
        DaemonForkOptionsBuilder builder = new DaemonForkOptionsBuilder(forkOptionsFactory).keepAliveMode(KeepAliveMode.DAEMON);
        ProcessWorkerSpec processConfiguration = (ProcessWorkerSpec) configuration;
        JavaForkOptions forkOptions = forkOptionsFactory.newJavaForkOptions();
        processConfiguration.getForkOptions().copyTo(forkOptions);
        forkOptions.setWorkingDir(workerDirectoryProvider.getWorkingDirectory());
        builder.javaForkOptions(forkOptions).withClassLoaderStructure(classLoaderStructureProvider.getWorkerProcessClassLoaderStructure(processConfiguration.getClasspath(), getParamClasses(executionClass, parameters)));
        return new ForkedWorkerRequirement(baseDir, builder.build());
    } else if (configuration instanceof ClassLoaderWorkerSpec) {
        ClassLoaderWorkerSpec classLoaderConfiguration = (ClassLoaderWorkerSpec) configuration;
        return new IsolatedClassLoaderWorkerRequirement(baseDir, classLoaderStructureProvider.getInProcessClassLoaderStructure(classLoaderConfiguration.getClasspath(), getParamClasses(executionClass, parameters)));
    } else {
        return new FixedClassLoaderWorkerRequirement(baseDir, Thread.currentThread().getContextClassLoader());
    }
}
Also used : ClassLoaderWorkerSpec(org.gradle.workers.ClassLoaderWorkerSpec) JavaForkOptions(org.gradle.process.JavaForkOptions) ProcessWorkerSpec(org.gradle.workers.ProcessWorkerSpec)

Aggregations

ClassLoaderWorkerSpec (org.gradle.workers.ClassLoaderWorkerSpec)2 ProcessWorkerSpec (org.gradle.workers.ProcessWorkerSpec)2 JavaForkOptions (org.gradle.process.JavaForkOptions)1