use of org.gradle.api.internal.StartParameterInternal in project gradle by gradle.
the class BuildStateFactory method buildSrcStartParameterFor.
private StartParameterInternal buildSrcStartParameterFor(File buildSrcDir, StartParameter containingBuildParameters) {
final StartParameterInternal buildSrcStartParameter = (StartParameterInternal) containingBuildParameters.newBuild();
buildSrcStartParameter.setCurrentDir(buildSrcDir);
buildSrcStartParameter.setProjectProperties(containingBuildParameters.getProjectProperties());
buildSrcStartParameter.doNotSearchUpwards();
buildSrcStartParameter.setProfile(containingBuildParameters.isProfile());
return buildSrcStartParameter;
}
use of org.gradle.api.internal.StartParameterInternal in project gradle by gradle.
the class InProcessGradleExecuter method executeBuild.
private BuildResult executeBuild(GradleInvocation invocation, OutputStream outputStream, OutputStream errorStream, BuildListenerImpl listener) {
// Augment the environment for the execution
System.setIn(connectStdIn());
processEnvironment.maybeSetProcessDir(getWorkingDir());
for (Map.Entry<String, String> entry : invocation.environmentVars.entrySet()) {
processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
}
Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
System.getProperties().putAll(implicitJvmSystemProperties);
// TODO: Reuse more of CommandlineActionFactory
CommandLineParser parser = new CommandLineParser();
FileCollectionFactory fileCollectionFactory = TestFiles.fileCollectionFactory();
ParametersConverter parametersConverter = new ParametersConverter(new BuildLayoutFactory(), fileCollectionFactory);
parametersConverter.configure(parser);
Parameters parameters = parametersConverter.convert(parser.parse(getAllArgs()), getWorkingDir());
BuildActionExecuter<BuildActionParameters, BuildRequestContext> actionExecuter = GLOBAL_SERVICES.get(BuildActionExecuter.class);
ListenerManager listenerManager = GLOBAL_SERVICES.get(ListenerManager.class);
listenerManager.addListener(listener);
try {
// TODO: Reuse more of BuildActionsFactory
StartParameterInternal startParameter = parameters.getStartParameter();
BuildAction action = new ExecuteBuildAction(startParameter);
BuildActionParameters buildActionParameters = createBuildActionParameters(startParameter);
BuildRequestContext buildRequestContext = createBuildRequestContext();
LoggingManagerInternal loggingManager = createLoggingManager(startParameter, outputStream, errorStream);
loggingManager.start();
try {
startMeasurement();
try {
BuildActionResult result = actionExecuter.execute(action, buildActionParameters, buildRequestContext);
if (result.getException() != null) {
return new BuildResult(null, result.getException());
}
if (result.getFailure() != null) {
PayloadSerializer payloadSerializer = new PayloadSerializer(new TestClassLoaderRegistry());
return new BuildResult(null, (RuntimeException) payloadSerializer.deserialize(result.getFailure()));
}
return new BuildResult(null, null);
} finally {
stopMeasurement();
}
} finally {
loggingManager.stop();
}
} finally {
listenerManager.removeListener(listener);
}
}
use of org.gradle.api.internal.StartParameterInternal in project gradle by gradle.
the class BuildSessionLifecycleBuildActionExecuter method execute.
@Override
public BuildActionResult execute(BuildAction action, BuildActionParameters actionParameters, BuildRequestContext requestContext) {
StartParameterInternal startParameter = action.getStartParameter();
if (action.isCreateModel()) {
// When creating a model, do not use continuous mode
startParameter.setContinuous(false);
}
ActionImpl actionWrapper = new ActionImpl(action, requestContext);
try {
try (CrossBuildSessionState crossBuildSessionState = new CrossBuildSessionState(globalServices, startParameter)) {
try (BuildSessionState buildSessionState = new BuildSessionState(userHomeServiceRegistry, crossBuildSessionState, startParameter, requestContext, actionParameters.getInjectedPluginClasspath(), requestContext.getCancellationToken(), requestContext.getClient(), requestContext.getEventConsumer())) {
return buildSessionState.run(actionWrapper);
}
}
} catch (Throwable t) {
if (actionWrapper.result == null) {
// whereas console failure logging based on the _thrown exception_ happens up outside session scope. It would be better to refactor so that a result can be returned from here
throw UncheckedException.throwAsUncheckedException(t);
} else {
// whereas console failure logging based on the _thrown exception_ happens up outside session scope. It would be better to refactor so that a result can be returned from here
throw UncheckedException.throwAsUncheckedException(actionWrapper.result.addFailure(t).getBuildFailure());
}
}
}
use of org.gradle.api.internal.StartParameterInternal in project gradle by gradle.
the class FileSystemWatchingBuildActionRunner method run.
@Override
public Result run(BuildAction action, BuildTreeLifecycleController buildController) {
StartParameterInternal startParameter = action.getStartParameter();
WatchMode watchFileSystemMode = startParameter.getWatchFileSystemMode();
VfsLogging verboseVfsLogging = startParameter.isVfsVerboseLogging() ? VfsLogging.VERBOSE : VfsLogging.NORMAL;
WatchLogging debugWatchLogging = startParameter.isWatchFileSystemDebugLogging() ? WatchLogging.DEBUG : WatchLogging.NORMAL;
LOGGER.info("Watching the file system is configured to be {}", watchFileSystemMode.getDescription());
boolean continuousBuild = startParameter.isContinuous() || !deploymentRegistry.getRunningDeployments().isEmpty();
if (continuousBuild && watchFileSystemMode == WatchMode.DEFAULT) {
// Try to watch as much as possible when using continuous build.
watchFileSystemMode = WatchMode.ENABLED;
}
if (watchFileSystemMode.isEnabled()) {
dropVirtualFileSystemIfRequested(startParameter, virtualFileSystem);
}
if (verboseVfsLogging == VfsLogging.VERBOSE) {
logVfsStatistics("since last build", statStatisticsCollector, fileHasherStatisticsCollector, directorySnapshotterStatisticsCollector);
}
if (action.getStartParameter().getProjectCacheDir() != null) {
// See https://github.com/gradle/gradle/issues/17262
switch(watchFileSystemMode) {
case ENABLED:
throw new IllegalStateException("Enabling file system watching via --watch-fs (or via the " + StartParameterBuildOptions.WatchFileSystemOption.GRADLE_PROPERTY + " property) with --project-cache-dir also specified is not supported; remove either option to fix this problem");
case DEFAULT:
LOGGER.info("File system watching is disabled because --project-cache-dir is specified");
watchFileSystemMode = WatchMode.DISABLED;
break;
default:
break;
}
}
LOGGER.debug("Watching the file system computed to be {}", watchFileSystemMode.getDescription());
boolean actuallyWatching = virtualFileSystem.afterBuildStarted(watchFileSystemMode, verboseVfsLogging, debugWatchLogging, buildOperationRunner);
LOGGER.info("File system watching is {}", actuallyWatching ? "active" : "inactive");
// noinspection Convert2Lambda
eventEmitter.emitNowForCurrent(new FileSystemWatchingSettingsFinalizedProgressDetails() {
@Override
public boolean isEnabled() {
return actuallyWatching;
}
});
if (continuousBuild) {
if (!actuallyWatching) {
throw new IllegalStateException("Continuous build does not work when file system watching is disabled");
}
}
try {
return delegate.run(action, buildController);
} finally {
int maximumNumberOfWatchedHierarchies = VirtualFileSystemServices.getMaximumNumberOfWatchedHierarchies(startParameter);
virtualFileSystem.beforeBuildFinished(watchFileSystemMode, verboseVfsLogging, debugWatchLogging, buildOperationRunner, maximumNumberOfWatchedHierarchies);
if (verboseVfsLogging == VfsLogging.VERBOSE) {
logVfsStatistics("during current build", statStatisticsCollector, fileHasherStatisticsCollector, directorySnapshotterStatisticsCollector);
}
}
}
use of org.gradle.api.internal.StartParameterInternal in project gradle by gradle.
the class ProviderConnection method runClientAction.
public Object runClientAction(Object clientAction, BuildCancellationToken cancellationToken, ProviderOperationParameters providerParameters) {
List<String> tasks = providerParameters.getTasks();
SerializedPayload serializedAction = payloadSerializer.serialize(clientAction);
Parameters params = initParams(providerParameters);
StartParameterInternal startParameter = new ProviderStartParameterConverter().toStartParameter(providerParameters, params.buildLayout, params.properties);
ProgressListenerConfiguration listenerConfig = ProgressListenerConfiguration.from(providerParameters, consumerVersion);
BuildAction action = new ClientProvidedBuildAction(startParameter, serializedAction, tasks != null, listenerConfig.clientSubscriptions);
return run(action, cancellationToken, listenerConfig, listenerConfig.buildEventConsumer, providerParameters, params);
}
Aggregations