protected void checkStartParameter(StartParameter startParameter) {
   assertEquals(expectedBuildFile, startParameter.getBuildFile());
   assertEquals(expectedTaskNames, startParameter.getTaskNames());
   assertEquals(buildProjectDependencies, startParameter.isBuildProjectDependencies());
   if (expectedCurrentDir != null) {
     assertEquals(
         expectedCurrentDir.getAbsoluteFile(), startParameter.getCurrentDir().getAbsoluteFile());
   }
   assertEquals(expectedProjectDir, startParameter.getProjectDir());
   assertEquals(expectedSearchUpwards, startParameter.isSearchUpwards());
   assertEquals(expectedProjectProperties, startParameter.getProjectProperties());
   assertEquals(expectedSystemProperties, startParameter.getSystemPropertiesArgs());
   assertEquals(
       expectedGradleUserHome.getAbsoluteFile(),
       startParameter.getGradleUserHomeDir().getAbsoluteFile());
   assertEquals(expectedLogLevel, startParameter.getLogLevel());
   assertEquals(expectedColorOutput, startParameter.isColorOutput());
   assertEquals(expectedConsoleOutput, startParameter.getConsoleOutput());
   assertEquals(expectedDryRun, startParameter.isDryRun());
   assertEquals(expectedShowStackTrace, startParameter.getShowStacktrace());
   assertEquals(expectedExcludedTasks, startParameter.getExcludedTaskNames());
   assertEquals(expectedInitScripts, startParameter.getInitScripts());
   assertEquals(expectedProfile, startParameter.isProfile());
   assertEquals(expectedContinue, startParameter.isContinueOnFailure());
   assertEquals(expectedOffline, startParameter.isOffline());
   assertEquals(expectedRecompileScripts, startParameter.isRecompileScripts());
   assertEquals(expectedRerunTasks, startParameter.isRerunTasks());
   assertEquals(expectedRefreshDependencies, startParameter.isRefreshDependencies());
   assertEquals(expectedProjectCacheDir, startParameter.getProjectCacheDir());
   assertEquals(expectedParallelExecutorCount, startParameter.getParallelThreadCount());
   assertEquals(expectedConfigureOnDemand, startParameter.isConfigureOnDemand());
   assertEquals(expectedMaxWorkersCount, startParameter.getMaxWorkerCount());
   assertEquals(expectedContinuous, startParameter.isContinuous());
 }
 protected Factory<WorkerProcessBuilder> createWorkerProcessFactory() {
   ClassPathRegistry classPathRegistry = get(ClassPathRegistry.class);
   return new DefaultWorkerProcessFactory(
       startParameter.getLogLevel(),
       get(MessagingServer.class),
       classPathRegistry,
       new IdentityFileResolver(),
       new LongIdGenerator());
 }
 WorkerProcessFactory createWorkerProcessFactory(
     StartParameter startParameter,
     MessagingServer messagingServer,
     ClassPathRegistry classPathRegistry,
     TemporaryFileProvider temporaryFileProvider,
     ExecHandleFactory execHandleFactory) {
   return new DefaultWorkerProcessFactory(
       startParameter.getLogLevel(),
       messagingServer,
       classPathRegistry,
       new LongIdGenerator(),
       startParameter.getGradleUserHomeDir(),
       temporaryFileProvider,
       execHandleFactory);
 }
示例#4
0
 private Runnable runBuild(
     StartParameter startParameter,
     DaemonParameters daemonParameters,
     BuildActionExecuter<BuildActionParameters> executer,
     ServiceRegistry sharedServices) {
   BuildActionParameters parameters =
       new DefaultBuildActionParameters(
           daemonParameters.getEffectiveSystemProperties(),
           System.getenv(),
           SystemProperties.getInstance().getCurrentDir(),
           startParameter.getLogLevel(),
           daemonParameters.getDaemonUsage(),
           startParameter.isContinuous(),
           daemonParameters.isInteractive(),
           ClassPath.EMPTY);
   return new RunBuildAction(
       executer,
       startParameter,
       clientMetaData(),
       getBuildStartTime(),
       parameters,
       sharedServices);
 }
  private DefaultGradleLauncher doNewInstance(
      StartParameter startParameter, BuildRequestMetaData requestMetaData) {
    final BuildScopeServices serviceRegistry =
        new BuildScopeServices(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());

    // 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));

    listenerManager.addListener(serviceRegistry.get(ProfileEventAdapter.class));
    if (startParameter.isProfile()) {
      listenerManager.addListener(new ReportGeneratingProfileListener());
    }
    ScriptUsageLocationReporter usageLocationReporter = new ScriptUsageLocationReporter();
    listenerManager.addListener(usageLocationReporter);
    DeprecationLogger.useLocationReporter(usageLocationReporter);

    GradleInternal gradle =
        serviceRegistry
            .get(Instantiator.class)
            .newInstance(
                DefaultGradle.class, tracker.getCurrentBuild(), startParameter, serviceRegistry);
    return new DefaultGradleLauncher(
        gradle,
        serviceRegistry.get(InitScriptHandler.class),
        new SettingsHandler(
            new DefaultSettingsFinder(new BuildLayoutFactory()),
            serviceRegistry.get(SettingsProcessor.class),
            new BuildSourceBuilder(
                this,
                serviceRegistry.get(ClassLoaderRegistry.class),
                serviceRegistry.get(CacheRepository.class))),
        serviceRegistry.get(BuildLoader.class),
        serviceRegistry.get(BuildConfigurer.class),
        gradle.getBuildListenerBroadcaster(),
        serviceRegistry.get(ExceptionAnalyser.class),
        loggingManager,
        listenerManager.getBroadcaster(ModelConfigurationListener.class),
        listenerManager.getBroadcaster(TasksCompletionListener.class),
        gradle.getServices().get(BuildExecuter.class));
  }