private void build(Build build, ExecutionListener executionListener) {
DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
StartParameter startParameter = new StartParameter();
startParameter.setCurrentDir(build.getCurrentDir());
converter.convert(build.getArgs(), startParameter);
LoggingManagerInternal loggingManager = loggingServices.getFactory(LoggingManagerInternal.class).create();
loggingManager.setLevel(startParameter.getLogLevel());
loggingManager.start();
Properties sysProperties = new Properties();
sysProperties.putAll(System.getProperties());
try {
RunBuildAction action = new RunBuildAction(startParameter, loggingServices, new DefaultBuildRequestMetaData(build.getClientMetaData(), build.getStartTime())) {
@Override
GradleLauncherFactory createGradleLauncherFactory(ServiceRegistry loggingServices) {
return launcherFactory;
}
};
action.execute(executionListener);
} catch (Throwable throwable) {
BuildExceptionReporter exceptionReporter = new BuildExceptionReporter(loggingServices.get(StyledTextOutputFactory.class), new StartParameter(), build.getClientMetaData());
exceptionReporter.reportException(throwable);
executionListener.onFailure(throwable);
}
loggingManager.stop();
System.setProperties(sysProperties);
}