public void execute(WorkerContext workerContext) {
    LoggingManagerInternal loggingManager = createLoggingManager();
    loggingManager.setLevel(logLevel).start();

    FilteringClassLoader filteredWorkerClassLoader =
        new FilteringClassLoader(getClass().getClassLoader());
    filteredWorkerClassLoader.allowPackage("org.slf4j");
    filteredWorkerClassLoader.allowClass(Action.class);
    filteredWorkerClassLoader.allowClass(WorkerContext.class);

    ClassLoader applicationClassLoader = workerContext.getApplicationClassLoader();
    FilteringClassLoader filteredApplication = new FilteringClassLoader(applicationClassLoader);
    ObservableUrlClassLoader implementationClassLoader =
        createImplementationClassLoader(filteredWorkerClassLoader, filteredApplication);

    // Configure classpaths
    for (String sharedPackage : sharedPackages) {
      filteredApplication.allowPackage(sharedPackage);
    }
    implementationClassLoader.addURLs(implementationClassPath);

    // Deserialize the worker action
    Action<WorkerContext> action;
    try {
      ObjectInputStream instr =
          new ClassLoaderObjectInputStream(
              new ByteArrayInputStream(serializedWorkerAction), implementationClassLoader);
      action = (Action<WorkerContext>) instr.readObject();
    } catch (Exception e) {
      throw UncheckedException.asUncheckedException(e);
    }
    action.execute(workerContext);
  }
 public void execute(ExecutionListener executionListener) {
   LoggingManagerInternal loggingManager =
       loggingServices.getFactory(LoggingManagerInternal.class).create();
   loggingManager.setLevel(loggingConfiguration.getLogLevel());
   loggingManager.colorStdOutAndStdErr(loggingConfiguration.isColorOutput());
   loggingManager.start();
   action.execute(executionListener);
 }
Пример #3
0
 public void configure(ProviderConnectionParameters parameters) {
   LogLevel providerLogLevel = parameters.getVerboseLogging() ? LogLevel.DEBUG : LogLevel.INFO;
   LOGGER.debug("Configuring logging to level: {}", providerLogLevel);
   LoggingManagerInternal loggingManager =
       loggingServices.newInstance(LoggingManagerInternal.class);
   loggingManager.setLevel(providerLogLevel);
   loggingManager.start();
 }
  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));
  }