Search in sources :

Example 1 with WorkQueue

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

the class PrefixHeaderFileGenerateTask method generatePrefixHeaderFile.

@TaskAction
void generatePrefixHeaderFile() {
    WorkQueue workQueue = workerExecutor.noIsolation();
    workQueue.submit(GeneratePrefixHeaderFile.class, new Action<PrefixHeaderFileParameters>() {

        @Override
        public void execute(@Nonnull PrefixHeaderFileParameters parameters) {
            parameters.getHeader().set(header);
            parameters.getPrefixHeaderFile().set(prefixHeaderFile);
        }
    });
}
Also used : WorkQueue(org.gradle.workers.WorkQueue) TaskAction(org.gradle.api.tasks.TaskAction)

Example 2 with WorkQueue

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

the class ScalaDoc method generate.

@TaskAction
protected void generate() {
    ScalaDocOptions options = getScalaDocOptions();
    if (!GUtil.isTrue(options.getDocTitle())) {
        options.setDocTitle(getTitle());
    }
    WorkQueue queue = getWorkerExecutor().processIsolation(worker -> {
        worker.getClasspath().from(getScalaClasspath());
        JavaForkOptions forkOptions = worker.getForkOptions();
        if (getMaxMemory().isPresent()) {
            forkOptions.setMaxHeapSize(getMaxMemory().get());
        }
        if (javaLauncher.isPresent()) {
            forkOptions.setExecutable(javaLauncher.get().getExecutablePath().getAsFile().getAbsolutePath());
        }
    });
    queue.submit(GenerateScaladoc.class, parameters -> {
        @Nullable File optionsFile = createOptionsFile();
        parameters.getOptionsFile().set(optionsFile);
        parameters.getClasspath().from(getClasspath());
        parameters.getOutputDirectory().set(getDestinationDir());
        boolean isScala3 = ScalaRuntimeHelper.findScalaJar(getScalaClasspath(), "library_3") != null;
        parameters.getIsScala3().set(isScala3);
        if (isScala3) {
            parameters.getSources().from(getFilteredCompilationOutputs());
        } else {
            parameters.getSources().from(getSource());
            if (options.isDeprecation()) {
                parameters.getOptions().add("-deprecation");
            }
            if (options.isUnchecked()) {
                parameters.getOptions().add("-unchecked");
            }
        }
        String footer = options.getFooter();
        if (footer != null) {
            parameters.getOptions().add("-doc-footer");
            parameters.getOptions().add(footer);
        }
        String docTitle = options.getDocTitle();
        if (docTitle != null) {
            parameters.getOptions().add("-doc-title");
            parameters.getOptions().add(docTitle);
        }
        // None of these options work for Scala >=2.8
        // options.getBottom();;
        // options.getTop();
        // options.getHeader();
        // options.getWindowTitle();
        List<String> additionalParameters = options.getAdditionalParameters();
        if (additionalParameters != null) {
            parameters.getOptions().addAll(additionalParameters);
        }
    });
}
Also used : JavaForkOptions(org.gradle.process.JavaForkOptions) WorkQueue(org.gradle.workers.WorkQueue) File(java.io.File) Nullable(javax.annotation.Nullable) TaskAction(org.gradle.api.tasks.TaskAction)

Example 3 with WorkQueue

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

the class DefaultWorkerExecutor method submit.

@Override
@SuppressWarnings("deprecation")
public void submit(Class<? extends Runnable> actionClass, Action<? super org.gradle.workers.WorkerConfiguration> configAction) {
    DeprecationLogger.deprecateMethod(WorkerExecutor.class, "submit()").replaceWith("noIsolation(), classLoaderIsolation() or processIsolation()").willBeRemovedInGradle8().withUserManual("upgrading_version_5", "method_workerexecutor_submit_is_deprecated").nagUser();
    DefaultWorkerConfiguration configuration = new DefaultWorkerConfiguration(forkOptionsFactory);
    configAction.execute(configuration);
    Action<AdapterWorkParameters> parametersAction = parameters -> {
        parameters.setImplementationClassName(actionClass.getName());
        parameters.setParams(configuration.getParams());
        parameters.setDisplayName(configuration.getDisplayName());
    };
    WorkQueue workQueue;
    switch(configuration.getIsolationMode()) {
        case NONE:
        case AUTO:
            workQueue = noIsolation(getWorkerSpecAdapterAction(configuration));
            break;
        case CLASSLOADER:
            workQueue = classLoaderIsolation(getWorkerSpecAdapterAction(configuration));
            break;
        case PROCESS:
            workQueue = processIsolation(getWorkerSpecAdapterAction(configuration));
            break;
        default:
            throw new IllegalArgumentException("Unknown isolation mode: " + configuration.getIsolationMode());
    }
    workQueue.submit(AdapterWorkAction.class, parametersAction);
}
Also used : CollectionUtils(org.gradle.util.internal.CollectionUtils) DefaultMultiCauseException(org.gradle.internal.exceptions.DefaultMultiCauseException) Callable(java.util.concurrent.Callable) BuildOperationRef(org.gradle.internal.operations.BuildOperationRef) WorkerExecutionException(org.gradle.workers.WorkerExecutionException) DefaultConditionalExecutionQueue(org.gradle.internal.work.DefaultConditionalExecutionQueue) Lists(com.google.common.collect.Lists) AbstractConditionalExecution(org.gradle.internal.work.AbstractConditionalExecution) DeprecationLogger(org.gradle.internal.deprecation.DeprecationLogger) IsolationScheme(org.gradle.internal.isolated.IsolationScheme) WorkerSpec(org.gradle.workers.WorkerSpec) Action(org.gradle.api.Action) AsyncWorkCompletion(org.gradle.internal.work.AsyncWorkCompletion) ConditionalExecutionQueue(org.gradle.internal.work.ConditionalExecutionQueue) ClassLoaderWorkerSpec(org.gradle.workers.ClassLoaderWorkerSpec) Cast(org.gradle.internal.Cast) JavaForkOptions(org.gradle.process.JavaForkOptions) RETAIN_PROJECT_LOCKS(org.gradle.internal.work.AsyncWorkTracker.ProjectLockRetention.RETAIN_PROJECT_LOCKS) WorkerThreadRegistry(org.gradle.internal.work.WorkerThreadRegistry) File(java.io.File) AsyncWorkTracker(org.gradle.internal.work.AsyncWorkTracker) Contextual(org.gradle.internal.exceptions.Contextual) Instantiator(org.gradle.internal.reflect.Instantiator) WorkerDirectoryProvider(org.gradle.process.internal.worker.child.WorkerDirectoryProvider) List(java.util.List) ClassLoaderUtils.classFromContextLoader(org.gradle.internal.classloader.ClassLoaderUtils.classFromContextLoader) WorkQueue(org.gradle.workers.WorkQueue) WorkerExecutor(org.gradle.workers.WorkerExecutor) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor) ProcessWorkerSpec(org.gradle.workers.ProcessWorkerSpec) WorkParameters(org.gradle.workers.WorkParameters) JavaForkOptionsFactory(org.gradle.process.internal.JavaForkOptionsFactory) Actions(org.gradle.internal.Actions) WorkAction(org.gradle.workers.WorkAction) NotThreadSafe(javax.annotation.concurrent.NotThreadSafe) WorkQueue(org.gradle.workers.WorkQueue)

Aggregations

WorkQueue (org.gradle.workers.WorkQueue)3 File (java.io.File)2 TaskAction (org.gradle.api.tasks.TaskAction)2 JavaForkOptions (org.gradle.process.JavaForkOptions)2 Lists (com.google.common.collect.Lists)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 Nullable (javax.annotation.Nullable)1 NotThreadSafe (javax.annotation.concurrent.NotThreadSafe)1 Action (org.gradle.api.Action)1 Actions (org.gradle.internal.Actions)1 Cast (org.gradle.internal.Cast)1 ClassLoaderUtils.classFromContextLoader (org.gradle.internal.classloader.ClassLoaderUtils.classFromContextLoader)1 DeprecationLogger (org.gradle.internal.deprecation.DeprecationLogger)1 Contextual (org.gradle.internal.exceptions.Contextual)1 DefaultMultiCauseException (org.gradle.internal.exceptions.DefaultMultiCauseException)1 IsolationScheme (org.gradle.internal.isolated.IsolationScheme)1 BuildOperationExecutor (org.gradle.internal.operations.BuildOperationExecutor)1 BuildOperationRef (org.gradle.internal.operations.BuildOperationRef)1 Instantiator (org.gradle.internal.reflect.Instantiator)1