use of org.gradle.workers.WorkerExecutor in project gradle by gradle.
the class NoIsolationWorkerFactory method getWorker.
@Override
public BuildOperationAwareWorker getWorker(WorkerRequirement workerRequirement) {
final WorkerExecutor workerExecutor = this.workerExecutor;
final ClassLoader contextClassLoader = ((FixedClassLoaderWorkerRequirement) workerRequirement).getContextClassLoader();
return new AbstractWorker(buildOperationExecutor) {
@Override
public DefaultWorkResult execute(IsolatedParametersActionExecutionSpec<?> spec, BuildOperationRef parentBuildOperation) {
return executeWrappedInBuildOperation(spec, parentBuildOperation, workSpec -> {
DefaultWorkResult result;
try {
result = ClassLoaderUtils.executeInClassloader(contextClassLoader, new Factory<DefaultWorkResult>() {
@Nullable
@Override
public DefaultWorkResult create() {
return workerServer.execute(specFactory.newSimpleSpec(workSpec));
}
});
} finally {
// TODO the async work tracker should wait for children of an operation to finish first.
// It should not be necessary to call it here.
workerExecutor.await();
}
return result;
});
}
};
}
use of org.gradle.workers.WorkerExecutor in project gradle by gradle.
the class Download method run.
@TaskAction
void run() {
WorkerExecutor workerExecutor = getWorkerExecutor();
ObjectFactory objectFactory = getObjectFactory();
// Use the executor and factory ...
}
use of org.gradle.workers.WorkerExecutor in project curiostack by curioswitch.
the class UploadCodeCovCacheTask method exec.
@TaskAction
public void exec() {
if (!getCodeCovReportFile().exists()) {
// UploadToCodeCovTask failed, skip uploading the cache.
return;
}
ExternalExecUtil.exec(getProject(), workerExecutor, exec -> {
final List<String> coverageFiles;
try (var lines = Files.lines(getCodeCovReportFile().toPath())) {
coverageFiles = lines.filter(line -> line.startsWith("# path=")).map(line -> line.substring("# path=".length())).filter(filename -> Files.exists(getProject().file(filename).toPath())).map(line -> "./" + line).collect(toImmutableList());
} catch (IOException e) {
throw new UncheckedIOException("Could not read coverage report dump", e);
}
var toolManager = DownloadedToolManager.get(getProject());
String gsutil = new PlatformHelper().getOs() == OperatingSystem.WINDOWS ? "gsutil.cmd" : "gsutil";
exec.executable("bash");
exec.args("-c", "tar -cpzf - " + String.join(" ", coverageFiles) + " | " + gsutil + " cp - " + dest.get());
toolManager.addAllToPath(exec);
});
}
Aggregations