assert tracker.getCurrentBuild() == null;
return doNewInstance(startParameter, requestMetaData);
}
private DefaultGradleLauncher doNewInstance(StartParameter startParameter, BuildRequestMetaData requestMetaData) {
TopLevelBuildServiceRegistry serviceRegistry = new TopLevelBuildServiceRegistry(sharedServices, startParameter);
serviceRegistry.add(BuildRequestMetaData.class, requestMetaData);
serviceRegistry.add(BuildClientMetaData.class, requestMetaData.getClient());
ListenerManager listenerManager = serviceRegistry.get(ListenerManager.class);
LoggingManagerInternal loggingManager = serviceRegistry.newInstance(LoggingManagerInternal.class);
loggingManager.setLevel(startParameter.getLogLevel());
loggingManager.colorStdOutAndStdErr(startParameter.isColorOutput());
//this hooks up the ListenerManager and LoggingConfigurer so you can call Gradle.addListener() with a StandardOutputListener.
loggingManager.addStandardOutputListener(listenerManager.getBroadcaster(StandardOutputListener.class));
loggingManager.addStandardErrorListener(listenerManager.getBroadcaster(StandardOutputListener.class));
listenerManager.useLogger(new TaskExecutionLogger(serviceRegistry.get(ProgressLoggerFactory.class)));
if (tracker.getCurrentBuild() == null) {
listenerManager.useLogger(new BuildLogger(Logging.getLogger(BuildLogger.class), serviceRegistry.get(StyledTextOutputFactory.class), startParameter, requestMetaData));
}
listenerManager.addListener(tracker);
listenerManager.addListener(new BuildCleanupListener(serviceRegistry));
if (startParameter.isProfile()) {
listenerManager.addListener(new ProfileListener(requestMetaData.getBuildTimeClock().getStartTime()));
}
DefaultGradle gradle = new DefaultGradle(
tracker.getCurrentBuild(),
startParameter, serviceRegistry);
return new DefaultGradleLauncher(
gradle,
serviceRegistry.get(InitScriptHandler.class),
new SettingsHandler(
new EmbeddedScriptSettingsFinder(
new DefaultSettingsFinder(WrapUtil.<ISettingsFileSearchStrategy>toList(
new MasterDirSettingsFinderStrategy(),
new ParentDirSettingsFinderStrategy()))),
serviceRegistry.get(SettingsProcessor.class),
new BuildSourceBuilder(
this,
serviceRegistry.get(ClassLoaderFactory.class),
serviceRegistry.get(CacheRepository.class))),
new DefaultGradlePropertiesLoader(),
new BuildLoader(
serviceRegistry.get(IProjectFactory.class)
),
serviceRegistry.get(BuildConfigurer.class),
gradle.getBuildListenerBroadcaster(),
serviceRegistry.get(ExceptionAnalyser.class),
loggingManager);
}