use of org.gradle.initialization.ReportedException in project gradle by gradle.
the class ContinuousBuildActionExecuter method executeMultipleBuilds.
private Object executeMultipleBuilds(BuildAction action, BuildRequestContext requestContext, final BuildActionParameters actionParameters, final ServiceRegistry buildSessionScopeServices, CancellableOperationManager cancellableOperationManager, ContinuousExecutionGate continuousExecutionGate) {
BuildCancellationToken cancellationToken = requestContext.getCancellationToken();
BuildStartedTime buildStartedTime = buildSessionScopeServices.get(BuildStartedTime.class);
Clock clock = buildSessionScopeServices.get(Clock.class);
Object lastResult;
while (true) {
PendingChangesListener pendingChangesListener = buildSessionScopeServices.get(ListenerManager.class).getBroadcaster(PendingChangesListener.class);
final FileSystemChangeWaiter waiter = changeWaiterFactory.createChangeWaiter(new SingleFirePendingChangesListener(pendingChangesListener), cancellationToken, continuousExecutionGate);
try {
try {
lastResult = executeBuildAndAccumulateInputs(action, requestContext, actionParameters, waiter, buildSessionScopeServices);
} catch (ReportedException t) {
lastResult = t;
}
if (!waiter.isWatching()) {
logger.println().withStyle(StyledTextOutput.Style.Failure).println("Exiting continuous build as no executed tasks declared file system inputs.");
if (lastResult instanceof ReportedException) {
throw (ReportedException) lastResult;
}
return lastResult;
} else {
cancellableOperationManager.monitorInput(new Action<BuildCancellationToken>() {
@Override
public void execute(BuildCancellationToken cancellationToken) {
FileWatcherEventListener reporter = new DefaultFileWatcherEventListener();
waiter.wait(new Runnable() {
@Override
public void run() {
logger.println().println("Waiting for changes to input files of tasks..." + determineExitHint(actionParameters));
}
}, reporter);
if (!cancellationToken.isCancellationRequested()) {
reporter.reportChanges(logger);
}
}
});
}
} finally {
waiter.stop();
}
if (cancellationToken.isCancellationRequested()) {
break;
} else {
logger.println("Change detected, executing build...").println();
buildStartedTime.reset(clock.getCurrentTime());
}
}
logger.println("Build cancelled.");
if (lastResult instanceof ReportedException) {
throw (ReportedException) lastResult;
}
return lastResult;
}
use of org.gradle.initialization.ReportedException in project gradle by gradle.
the class DaemonBuildActionExecuter method execute.
public Object execute(BuildAction action, BuildRequestContext buildRequestContext, ProviderOperationParameters parameters, ServiceRegistry contextServices) {
boolean continuous = action.getStartParameter() != null && action.getStartParameter().isContinuous() && isNotBuildingModel(action);
if (continuous && !doesConsumerSupportCancellation(buildRequestContext)) {
throw new UnsupportedVersionException("Continuous build requires Tooling API client version 2.1 or later.");
}
ClassPath classPath = DefaultClassPath.of(parameters.getInjectedPluginClasspath(Collections.<File>emptyList()));
BuildActionParameters actionParameters = new DefaultBuildActionParameters(daemonParameters.getEffectiveSystemProperties(), daemonParameters.getEnvironmentVariables(), SystemProperties.getInstance().getCurrentDir(), parameters.getBuildLogLevel(), daemonParameters.isEnabled(), continuous, false, classPath);
try {
return executer.execute(action, buildRequestContext, actionParameters, contextServices);
} catch (ReportedException e) {
Throwable t = e.getCause();
// Unpack tunnelled test request failure
if (t instanceof InternalTestExecutionException) {
throw (InternalTestExecutionException) t;
}
while (t != null) {
if (t instanceof BuildCancelledException) {
throw new InternalBuildCancelledException(e.getCause());
}
t = t.getCause();
}
throw new BuildExceptionVersion1(e.getCause());
}
}
Aggregations