use of org.gradle.internal.invocation.BuildAction 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;
}
use of org.gradle.internal.invocation.BuildAction in project gradle by gradle.
the class ProviderConnection method runPhasedAction.
public Object runPhasedAction(InternalPhasedAction clientPhasedAction, PhasedActionResultListener resultListener, BuildCancellationToken cancellationToken, ProviderOperationParameters providerParameters) {
List<String> tasks = providerParameters.getTasks();
SerializedPayload serializedAction = payloadSerializer.serialize(clientPhasedAction);
Parameters params = initParams(providerParameters);
StartParameterInternal startParameter = new ProviderStartParameterConverter().toStartParameter(providerParameters, params.buildLayout, params.properties);
FailsafePhasedActionResultListener failsafePhasedActionResultListener = new FailsafePhasedActionResultListener(resultListener);
ProgressListenerConfiguration listenerConfig = ProgressListenerConfiguration.from(providerParameters, consumerVersion);
BuildAction action = new ClientProvidedPhasedAction(startParameter, serializedAction, tasks != null, listenerConfig.clientSubscriptions);
try {
return run(action, cancellationToken, listenerConfig, new PhasedActionEventConsumer(failsafePhasedActionResultListener, payloadSerializer, listenerConfig.buildEventConsumer), providerParameters, params);
} finally {
failsafePhasedActionResultListener.rethrowErrors();
}
}
use of org.gradle.internal.invocation.BuildAction in project gradle by gradle.
the class ProviderConnection method run.
public Object run(String modelName, BuildCancellationToken cancellationToken, ProviderOperationParameters providerParameters) {
List<String> tasks = providerParameters.getTasks();
if (modelName.equals(ModelIdentifier.NULL_MODEL) && tasks == null) {
throw new IllegalArgumentException("No model type or tasks specified.");
}
Parameters params = initParams(providerParameters);
if (BuildEnvironment.class.getName().equals(modelName)) {
// we don't really need to launch the daemon to acquire information needed for BuildEnvironment
if (tasks != null) {
throw new IllegalArgumentException("Cannot run tasks and fetch the build environment model.");
}
return new DefaultBuildEnvironment(new DefaultBuildIdentifier(providerParameters.getProjectDir()), params.buildLayout.getGradleUserHomeDir(), GradleVersion.current().getVersion(), params.daemonParams.getEffectiveJvm().getJavaHome(), params.daemonParams.getEffectiveJvmArgs());
}
StartParameterInternal startParameter = new ProviderStartParameterConverter().toStartParameter(providerParameters, params.buildLayout, params.properties);
ProgressListenerConfiguration listenerConfig = ProgressListenerConfiguration.from(providerParameters, consumerVersion);
BuildAction action = new BuildModelAction(startParameter, modelName, tasks != null, listenerConfig.clientSubscriptions);
return run(action, cancellationToken, listenerConfig, listenerConfig.buildEventConsumer, providerParameters, params);
}
Aggregations