use of org.gradle.deployment.internal.PendingChangesListener in project gradle by gradle.
the class ContinuousBuildActionExecutor method executeMultipleBuilds.
private BuildActionRunner.Result executeMultipleBuilds(BuildAction action, BuildRequestMetaData requestContext, BuildSessionContext buildSession, BuildCancellationToken cancellationToken, CancellableOperationManager cancellableOperationManager, ContinuousExecutionGate continuousExecutionGate) {
BuildActionRunner.Result lastResult;
PendingChangesListener pendingChangesListener = listenerManager.getBroadcaster(PendingChangesListener.class);
while (true) {
BuildInputHierarchy buildInputs = new BuildInputHierarchy(caseSensitivity, stat);
ContinuousBuildTriggerHandler continuousBuildTriggerHandler = new ContinuousBuildTriggerHandler(cancellationToken, continuousExecutionGate, action.getStartParameter().getContinuousBuildQuietPeriod());
SingleFirePendingChangesListener singleFirePendingChangesListener = new SingleFirePendingChangesListener(pendingChangesListener);
FileEventCollector fileEventCollector = new FileEventCollector(buildInputs, () -> {
continuousBuildTriggerHandler.notifyFileChangeArrived();
singleFirePendingChangesListener.onPendingChanges();
});
try {
fileChangeListeners.addListener(fileEventCollector);
lastResult = executeBuildAndAccumulateInputs(action, new AccumulateBuildInputsListener(buildInputs), buildSession);
if (buildInputs.isEmpty()) {
logger.println().withStyle(StyledTextOutput.Style.Failure).println("Exiting continuous build as Gradle did not detect any file system inputs.");
return lastResult;
} else if (!continuousBuildTriggerHandler.hasBeenTriggered() && !fileSystemWatchingInformation.isWatchingAnyLocations()) {
logger.println().withStyle(StyledTextOutput.Style.Failure).println("Exiting continuous build as Gradle does not watch any file system locations.");
return lastResult;
} else {
cancellableOperationManager.monitorInput(operationToken -> {
continuousBuildTriggerHandler.wait(() -> logger.println().println("Waiting for changes to input files..." + determineExitHint(requestContext)));
if (!operationToken.isCancellationRequested()) {
fileEventCollector.reportChanges(logger);
}
});
}
} finally {
fileChangeListeners.removeListener(fileEventCollector);
}
if (cancellationToken.isCancellationRequested()) {
break;
} else {
logger.println("Change detected, executing build...").println();
resetBuildStartedTime();
}
}
logger.println("Build cancelled.");
return lastResult;
}
Aggregations