use of org.gradle.internal.operations.BuildOperationContext in project gradle by gradle.
the class InitScriptHandler method executeScripts.
public void executeScripts(final GradleInternal gradle) {
final List<File> initScripts = gradle.getStartParameter().getAllInitScripts();
if (initScripts.isEmpty()) {
return;
}
buildOperationExecutor.run(new RunnableBuildOperation() {
@Override
public void run(BuildOperationContext context) {
for (File script : initScripts) {
TextResource resource = resourceLoader.loadFile("initialization script", script);
processor.process(new TextResourceScriptSource(resource), gradle);
}
}
@Override
public BuildOperationDescriptor.Builder description() {
return BuildOperationDescriptor.displayName("Run init scripts").progressDisplayName("Running init scripts");
}
});
}
use of org.gradle.internal.operations.BuildOperationContext in project gradle by gradle.
the class TaskExecution method markLegacySnapshottingInputsStarted.
@Override
public void markLegacySnapshottingInputsStarted() {
// expects it to be added also when the build cache is enabled (but not the scan plugin)
if (emitLegacySnapshottingOperations) {
BuildOperationContext operationContext = buildOperationExecutor.start(BuildOperationDescriptor.displayName("Snapshot task inputs for " + task.getIdentityPath()).name("Snapshot task inputs").details(SNAPSHOT_TASK_INPUTS_DETAILS));
context.setSnapshotTaskInputsBuildOperationContext(operationContext);
}
}
use of org.gradle.internal.operations.BuildOperationContext in project gradle by gradle.
the class WatchingVirtualFileSystem method beforeBuildFinished.
@Override
public void beforeBuildFinished(WatchMode watchMode, VfsLogging vfsLogging, WatchLogging watchLogging, BuildOperationRunner buildOperationRunner, int maximumNumberOfWatchedHierarchies) {
rootReference.update(currentRoot -> buildOperationRunner.call(new CallableBuildOperation<SnapshotHierarchy>() {
@Override
public SnapshotHierarchy call(BuildOperationContext context) {
watchableHierarchiesRegisteredEarly.clear();
if (watchMode.isEnabled()) {
if (reasonForNotWatchingFiles != null) {
// Log exception again so it doesn't get lost.
logWatchingError(reasonForNotWatchingFiles, FILE_WATCHING_ERROR_MESSAGE_AT_END_OF_BUILD, watchMode);
reasonForNotWatchingFiles = null;
}
SnapshotHierarchy newRoot;
FileSystemWatchingStatistics statisticsDuringBuild;
if (watchRegistry == null) {
statisticsDuringBuild = null;
newRoot = currentRoot.empty();
} else {
FileWatcherRegistry.FileWatchingStatistics statistics = watchRegistry.getAndResetStatistics();
if (hasDroppedStateBecauseOfErrorsReceivedWhileWatching(statistics)) {
newRoot = stopWatchingAndInvalidateHierarchyAfterError(currentRoot);
} else {
newRoot = withWatcherChangeErrorHandling(currentRoot, () -> watchRegistry.updateVfsOnBuildFinished(currentRoot, watchMode, maximumNumberOfWatchedHierarchies, unsupportedFileSystems));
}
statisticsDuringBuild = new DefaultFileSystemWatchingStatistics(statistics, newRoot);
if (vfsLogging == VfsLogging.VERBOSE) {
LOGGER.warn("Received {} file system events during the current build while watching {} locations", statisticsDuringBuild.getNumberOfReceivedEvents(), statisticsDuringBuild.getNumberOfWatchedHierarchies());
LOGGER.warn("Virtual file system retains information about {} files, {} directories and {} missing files until next build", statisticsDuringBuild.getRetainedRegularFiles(), statisticsDuringBuild.getRetainedDirectories(), statisticsDuringBuild.getRetainedMissingFiles());
if (stateInvalidatedAtStartOfBuild) {
LOGGER.warn("Parts of the virtual file system have been removed at the start of the build since they didn't support watching");
}
}
}
boolean stoppedWatchingDuringTheBuild = watchRegistry == null;
context.setResult(new BuildFinishedFileSystemWatchingBuildOperationType.Result() {
private final boolean stateInvalidatedAtStartOfBuild = WatchingVirtualFileSystem.this.stateInvalidatedAtStartOfBuild;
@Override
public boolean isWatchingEnabled() {
return true;
}
@Override
public boolean isStoppedWatchingDuringTheBuild() {
return stoppedWatchingDuringTheBuild;
}
@Override
public boolean isStateInvalidatedAtStartOfBuild() {
return stateInvalidatedAtStartOfBuild;
}
@Override
public FileSystemWatchingStatistics getStatistics() {
return statisticsDuringBuild;
}
});
return newRoot;
} else {
context.setResult(BuildFinishedFileSystemWatchingBuildOperationType.Result.WATCHING_DISABLED);
return currentRoot.empty();
}
}
@Override
public BuildOperationDescriptor.Builder description() {
return BuildOperationDescriptor.displayName(BuildFinishedFileSystemWatchingBuildOperationType.DISPLAY_NAME).details(BuildFinishedFileSystemWatchingBuildOperationType.Details.INSTANCE);
}
}));
// Log problems to daemon log
warningLogger = LOGGER;
}
use of org.gradle.internal.operations.BuildOperationContext in project gradle by gradle.
the class DefaultTestReport method generateFiles.
private void generateFiles(AllTestResults model, final TestResultsProvider resultsProvider, final File reportDir) {
try {
HtmlReportRenderer htmlRenderer = new HtmlReportRenderer();
buildOperationExecutor.run(new RunnableBuildOperation() {
@Override
public void run(BuildOperationContext context) {
// Clean-up old HTML report directories
GFileUtils.deleteQuietly(new File(reportDir, "packages"));
GFileUtils.deleteQuietly(new File(reportDir, "classes"));
}
@Override
public BuildOperationDescriptor.Builder description() {
return BuildOperationDescriptor.displayName("Delete old HTML results");
}
});
htmlRenderer.render(model, new ReportRenderer<AllTestResults, HtmlReportBuilder>() {
@Override
public void render(final AllTestResults model, final HtmlReportBuilder output) throws IOException {
buildOperationExecutor.runAll(new Action<BuildOperationQueue<HtmlReportFileGenerator<? extends CompositeTestResults>>>() {
@Override
public void execute(BuildOperationQueue<HtmlReportFileGenerator<? extends CompositeTestResults>> queue) {
queue.add(generator("index.html", model, new OverviewPageRenderer(), output));
for (PackageTestResults packageResults : model.getPackages()) {
queue.add(generator(packageResults.getBaseUrl(), packageResults, new PackagePageRenderer(), output));
for (ClassTestResults classResults : packageResults.getClasses()) {
queue.add(generator(classResults.getBaseUrl(), classResults, new ClassPageRenderer(resultsProvider), output));
}
}
}
});
}
}, reportDir);
} catch (Exception e) {
throw new GradleException(String.format("Could not generate test report to '%s'.", reportDir), e);
}
}
use of org.gradle.internal.operations.BuildOperationContext in project gradle by gradle.
the class BuildSourceBuilder method createBuildSourceClasspath.
private ClassPath createBuildSourceClasspath(final GradleInternal gradle, File buildSrcDir, final StartParameter containingBuildParameters) {
if (!buildSrcDir.isDirectory()) {
LOGGER.debug("Gradle source dir does not exist. We leave.");
return ClassPath.EMPTY;
}
final StartParameter buildSrcStartParameter = containingBuildParameters.newBuild();
buildSrcStartParameter.setCurrentDir(buildSrcDir);
buildSrcStartParameter.setProjectProperties(containingBuildParameters.getProjectProperties());
buildSrcStartParameter.setSearchUpwards(false);
buildSrcStartParameter.setProfile(containingBuildParameters.isProfile());
final BuildDefinition buildDefinition = BuildDefinition.fromStartParameterForBuild(buildSrcStartParameter, buildSrcDir, DefaultPluginRequests.EMPTY);
assert buildSrcStartParameter.getBuildFile() == null;
return buildOperationExecutor.call(new CallableBuildOperation<ClassPath>() {
@Override
public ClassPath call(BuildOperationContext context) {
ClassPath classPath = buildBuildSrc(buildDefinition);
context.setResult(BUILD_BUILDSRC_RESULT);
return classPath;
}
@Override
public BuildOperationDescriptor.Builder description() {
return BuildOperationDescriptor.displayName("Build buildSrc").progressDisplayName("Building buildSrc").details(new BuildBuildSrcBuildOperationType.Details() {
@Override
public String getBuildPath() {
return gradle.getIdentityPath().toString();
}
});
}
});
}
Aggregations