use of org.gradle.launcher.cli.Parameters in project gradle by gradle.
the class InProcessGradleExecuter method executeBuild.
private BuildResult executeBuild(GradleInvocation invocation, StandardOutputListener outputListener, StandardOutputListener errorListener, 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);
resetTempDirLocation();
// TODO: Fix tests that rely on this being set before we process arguments like this...
StartParameter startParameter = new StartParameter();
startParameter.setCurrentDir(getWorkingDir());
startParameter.setShowStacktrace(ShowStacktrace.ALWAYS);
CommandLineParser parser = new CommandLineParser();
ParametersConverter parametersConverter = new ParametersConverter();
parametersConverter.configure(parser);
final Parameters parameters = new Parameters(startParameter);
parametersConverter.convert(parser.parse(getAllArgs()), parameters);
BuildActionExecuter<BuildActionParameters> actionExecuter = GLOBAL_SERVICES.get(BuildActionExecuter.class);
ListenerManager listenerManager = GLOBAL_SERVICES.get(ListenerManager.class);
listenerManager.addListener(listener);
try {
// TODO: Reuse more of BuildActionsFactory
BuildAction action = new ExecuteBuildAction(startParameter);
BuildActionParameters buildActionParameters = createBuildActionParameters(startParameter);
BuildRequestContext buildRequestContext = createBuildRequestContext(outputListener, errorListener);
startMeasurement();
actionExecuter.execute(action, buildRequestContext, buildActionParameters, GLOBAL_SERVICES);
return new BuildResult(null, null);
} catch (ReportedException e) {
return new BuildResult(null, e.getCause());
} finally {
stopMeasurement();
listenerManager.removeListener(listener);
}
}
Aggregations