Java Code Examples for org.gradle.api.logging.Logging

The following examples show how to use org.gradle.api.logging.Logging. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Maps a Logback log level and optional marker to a Gradle log level.
 * Returns null if there is no equivalent Gradle log level (such as for TRACE).
 */
@Nullable
public static LogLevel toGradleLogLevel(Level level, @Nullable Marker marker) {
    switch(level.toInt()) {
        case Level.TRACE_INT:
            return null;
        case Level.DEBUG_INT:
            return LogLevel.DEBUG;
        case Level.INFO_INT:
            if (marker == Logging.LIFECYCLE) {
                return LogLevel.LIFECYCLE;
            }
            if (marker == Logging.QUIET) {
                return LogLevel.QUIET;
            }
            return LogLevel.INFO;
        case Level.WARN_INT:
            return LogLevel.WARN;
        case Level.ERROR_INT:
            return LogLevel.ERROR;
        default:
            throw new IllegalArgumentException("Don't know how to map Logback log level '" + level + "' to a Gradle log level");
    }
}
 
Example 2
public void messageLogged(BuildEvent event) {
    final StringBuffer message = new StringBuffer();
    if (event.getTask() != null) {
        String taskName = event.getTask().getTaskName();
        message.append("[ant:").append(taskName).append("] ");
    }
    final String messageText = event.getMessage();
    message.append(messageText);

    LogLevel level = Logging.ANT_IVY_2_SLF4J_LEVEL_MAPPER.get(event.getPriority());

    if (event.getException() != null) {
        logger.log(level, message.toString(), event.getException());
    } else {
        logger.log(level, message.toString());
    }
}
 
Example 3
/**
 * Maps a Logback log level and optional marker to a Gradle log level.
 * Returns null if there is no equivalent Gradle log level (such as for TRACE).
 */
@Nullable
public static LogLevel toGradleLogLevel(Level level, @Nullable Marker marker) {
    switch(level.toInt()) {
        case Level.TRACE_INT:
            return null;
        case Level.DEBUG_INT:
            return LogLevel.DEBUG;
        case Level.INFO_INT:
            if (marker == Logging.LIFECYCLE) {
                return LogLevel.LIFECYCLE;
            }
            if (marker == Logging.QUIET) {
                return LogLevel.QUIET;
            }
            return LogLevel.INFO;
        case Level.WARN_INT:
            return LogLevel.WARN;
        case Level.ERROR_INT:
            return LogLevel.ERROR;
        default:
            throw new IllegalArgumentException("Don't know how to map Logback log level '" + level + "' to a Gradle log level");
    }
}
 
Example 4
public void messageLogged(BuildEvent event) {
    final StringBuffer message = new StringBuffer();
    if (event.getTask() != null) {
        String taskName = event.getTask().getTaskName();
        message.append("[ant:").append(taskName).append("] ");
    }
    final String messageText = event.getMessage();
    message.append(messageText);

    LogLevel level = Logging.ANT_IVY_2_SLF4J_LEVEL_MAPPER.get(event.getPriority());

    if (event.getException() != null) {
        logger.log(level, message.toString(), event.getException());
    } else {
        logger.log(level, message.toString());
    }
}
 
Example 5
Source Project: atlas   Source File: AtlasExtension.java    License: Apache License 2.0 6 votes vote down vote up
public AtlasExtension(@NonNull final ProjectInternal project,
                      @NonNull Instantiator instantiator,
                      @NonNull NamedDomainObjectContainer<T> buildTypes,
                      @NonNull NamedDomainObjectContainer<PatchConfig> patchConfigs,
                      @NonNull NamedDomainObjectContainer<DexConfig> dexConfigs) {

    logger = Logging.getLogger(this.getClass());
    this.project = project;

    this.patchConfigs = patchConfigs;
    this.dexConfigs = dexConfigs;
    this.buildTypes = buildTypes;
    this.multiDexConfigs = project.container(MultiDexConfig.class, new MultiDexConfigFactory(

        instantiator,project, project.getLogger()));
    this.atlasChannelConfigs = project.container(DefaultChannelConfig.class, new DefaultChannelConfigFactory(instantiator, project, project.getLogger()));
    this.enhanceConfigs = project.container(EnhanceConfig.class, new EnhanceConfigFactory(instantiator, project, project.getLogger()));
    tBuildConfig = (Z) instantiator.newInstance(TBuildConfig.class);
    manifestOptions = instantiator.newInstance(ManifestOptions.class);
    bundleConfig = instantiator.newInstance(BundleConfig.class);
}
 
Example 6
Source Project: azure-gradle-plugins   Source File: WebAppUtils.java    License: MIT License 6 votes vote down vote up
public static DockerImageType getDockerImageTypeFromName(final AppService appService) {
    if (appService == null || StringUtils.isEmpty(appService.getImageName())) {
        return DockerImageType.NONE;
    }
    final boolean isCustomRegistry = isNotEmpty(appService.getRegistryUrl());
    final boolean isPrivate = isNotEmpty(appService.getServerId());

    Logging.getLogger(WebAppUtils.class)
            .quiet("ServerId: " + appService.getServerId() + " : " + System.getenv("SERVER_ID"));

    if (isCustomRegistry) {
        return isPrivate ? DockerImageType.PRIVATE_REGISTRY : DockerImageType.UNKNOWN;
    } else {
        return isPrivate ? DockerImageType.PRIVATE_DOCKER_HUB : DockerImageType.PUBLIC_DOCKER_HUB;
    }
}
 
Example 7
Source Project: javaide   Source File: BaseVariantData.java    License: GNU General Public License v3.0 6 votes vote down vote up
public BaseVariantData(
        @NonNull AndroidConfig androidConfig,
        @NonNull TaskManager taskManager,
        @NonNull GradleVariantConfiguration variantConfiguration) {
    this.androidConfig = androidConfig;
    this.variantConfiguration = variantConfiguration;
    this.taskManager = taskManager;

    // eventually, this will require a more open ended comparison.
    mSplitHandlingPolicy =
            androidConfig.getGeneratePureSplits()
                    && variantConfiguration.getMinSdkVersion().getApiLevel() >= 21
                    ? SplitHandlingPolicy.RELEASE_21_AND_AFTER_POLICY
                    : SplitHandlingPolicy.PRE_21_POLICY;

    // warn the user in case we are forced to ignore the generatePureSplits flag.
    if (androidConfig.getGeneratePureSplits()
            && mSplitHandlingPolicy != SplitHandlingPolicy.RELEASE_21_AND_AFTER_POLICY) {
        Logging.getLogger(BaseVariantData.class).warn(
                String.format("Variant %s, MinSdkVersion %s is too low (<21) "
                                + "to support pure splits, reverting to full APKs",
                        variantConfiguration.getFullName(),
                        variantConfiguration.getMinSdkVersion().getApiLevel()));
    }
    scope = new VariantScope(taskManager.getGlobalScope(), this);
}
 
Example 8
Source Project: javaide   Source File: TaskManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
public TaskManager(
        Project project,
        AndroidBuilder androidBuilder,
        AndroidConfig extension,
        SdkHandler sdkHandler,
        DependencyManager dependencyManager,
        ToolingModelBuilderRegistry toolingRegistry) {
    this.project = project;
    this.androidBuilder = androidBuilder;
    this.sdkHandler = sdkHandler;
    this.extension = extension;
    this.toolingRegistry = toolingRegistry;
    this.dependencyManager = dependencyManager;
    logger = Logging.getLogger(this.getClass());

    globalScope = new GlobalScope(
            project,
            androidBuilder,
            checkNotNull((String) project.getProperties().get("archivesBaseName")),
            extension,
            sdkHandler,
            toolingRegistry);
}
 
Example 9
/**
 * Maps a Logback log level and optional marker to a Gradle log level.
 * Returns null if there is no equivalent Gradle log level (such as for TRACE).
 */
@Nullable
public static LogLevel toGradleLogLevel(Level level, @Nullable Marker marker) {
    switch(level.toInt()) {
        case Level.TRACE_INT:
            return null;
        case Level.DEBUG_INT:
            return LogLevel.DEBUG;
        case Level.INFO_INT:
            if (marker == Logging.LIFECYCLE) {
                return LogLevel.LIFECYCLE;
            }
            if (marker == Logging.QUIET) {
                return LogLevel.QUIET;
            }
            return LogLevel.INFO;
        case Level.WARN_INT:
            return LogLevel.WARN;
        case Level.ERROR_INT:
            return LogLevel.ERROR;
        default:
            throw new IllegalArgumentException("Don't know how to map Logback log level '" + level + "' to a Gradle log level");
    }
}
 
Example 10
public void messageLogged(BuildEvent event) {
    final StringBuffer message = new StringBuffer();
    if (event.getTask() != null) {
        String taskName = event.getTask().getTaskName();
        message.append("[ant:").append(taskName).append("] ");
    }
    final String messageText = event.getMessage();
    message.append(messageText);

    LogLevel level = Logging.ANT_IVY_2_SLF4J_LEVEL_MAPPER.get(event.getPriority());

    if (event.getException() != null) {
        logger.log(level, message.toString(), event.getException());
    } else {
        logger.log(level, message.toString());
    }
}
 
Example 11
/**
 * Maps a Logback log level and optional marker to a Gradle log level.
 * Returns null if there is no equivalent Gradle log level (such as for TRACE).
 */
@Nullable
public static LogLevel toGradleLogLevel(Level level, @Nullable Marker marker) {
    switch(level.toInt()) {
        case Level.TRACE_INT:
            return null;
        case Level.DEBUG_INT:
            return LogLevel.DEBUG;
        case Level.INFO_INT:
            if (marker == Logging.LIFECYCLE) {
                return LogLevel.LIFECYCLE;
            }
            if (marker == Logging.QUIET) {
                return LogLevel.QUIET;
            }
            return LogLevel.INFO;
        case Level.WARN_INT:
            return LogLevel.WARN;
        case Level.ERROR_INT:
            return LogLevel.ERROR;
        default:
            throw new IllegalArgumentException("Don't know how to map Logback log level '" + level + "' to a Gradle log level");
    }
}
 
Example 12
public void messageLogged(BuildEvent event) {
    final StringBuffer message = new StringBuffer();
    if (event.getTask() != null) {
        String taskName = event.getTask().getTaskName();
        message.append("[ant:").append(taskName).append("] ");
    }
    final String messageText = event.getMessage();
    message.append(messageText);

    LogLevel level = Logging.ANT_IVY_2_SLF4J_LEVEL_MAPPER.get(event.getPriority());

    if (event.getException() != null) {
        logger.log(level, message.toString(), event.getException());
    } else {
        logger.log(level, message.toString());
    }
}
 
Example 13
Source Project: atlas   Source File: TransformReplacer.java    License: Apache License 2.0 5 votes vote down vote up
public void replaceDataBindingMergeArtifactsTransform() {
    List<TransformTask> list = TransformManager.findTransformTaskByTransformType(variantContext,
            DataBindingMergeArtifactsTransform.class);
    for (TransformTask transformTask : list) {
        File outFolder =
                new File(
                        variantContext.getScope().getBuildFolderForDataBindingCompiler(),
                        DataBindingBuilder.ARTIFACT_FILES_DIR_FROM_LIBS);
        AtlasDataBindingMergeArtifactsTransform dataBindingMergeArtifactsTransform = new AtlasDataBindingMergeArtifactsTransform(variantContext, Logging.getLogger(AtlasDataBindingMergeArtifactsTransform.class), outFolder);
        ReflectUtils.updateField(transformTask, "transform", dataBindingMergeArtifactsTransform);
    }

}
 
Example 14
Source Project: atlas   Source File: AtlasBaseTaskManager.java    License: Apache License 2.0 5 votes vote down vote up
public AtlasBaseTaskManager(AtlasBuilder androidBuilder, T androidExtension, Project project,
                            AtlasExtension atlasExtension) {
    this.tAndroidBuilder = androidBuilder;
    this.androidExtension = androidExtension;
    this.project = project;
    this.tasks = new TaskContainerAdaptor(project.getTasks());
    this.atlasExtension = atlasExtension;
    this.logger = new LoggerWrapper(Logging.getLogger(AtlasBaseTaskManager.class));
    this.extraModelInfo = new ExtraModelInfo(new ProjectOptions(project), Logging.getLogger(AtlasBaseTaskManager.class));

    //this.dependencyManager = new DependencyManager(androidExtension, project, atlasExtension);
}
 
Example 15
Source Project: pygradle   Source File: ThinPexGenerator.java    License: Apache License 2.0 5 votes vote down vote up
public ThinPexGenerator(
    Project project,
    List<String> pexOptions,
    EntryPointTemplateProvider templateProvider,
    Map<String, String> extraProperties) {

    super(project, pexOptions, templateProvider, extraProperties);
    logger = Logging.getLogger(ThinPexGenerator.class);
}
 
Example 16
protected AbstractGradleExecuter(GradleDistribution distribution, TestDirectoryProvider testDirectoryProvider) {
    this.distribution = distribution;
    this.testDirectoryProvider = testDirectoryProvider;
    logger = Logging.getLogger(getClass());
}
 
Example 17
public void log(String msg, int level) {
    logger.log(Logging.ANT_IVY_2_SLF4J_LEVEL_MAPPER.get(level), msg);
}
 
Example 18
private DefaultGradleLauncher doNewInstance(StartParameter startParameter, BuildCancellationToken cancellationToken, BuildRequestMetaData requestMetaData) {
    final BuildScopeServices serviceRegistry = new BuildScopeServices(sharedServices, startParameter);
    serviceRegistry.add(BuildRequestMetaData.class, requestMetaData);
    serviceRegistry.add(BuildClientMetaData.class, requestMetaData.getClient());
    serviceRegistry.add(BuildCancellationToken.class, cancellationToken);
    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));

    LoggerProvider loggerProvider = (tracker.getCurrentBuild() == null) ? buildProgressLogger : LoggerProvider.NO_OP;
    listenerManager.useLogger(new TaskExecutionLogger(serviceRegistry.get(ProgressLoggerFactory.class), loggerProvider));
    if (tracker.getCurrentBuild() == null) {
        listenerManager.useLogger(new BuildLogger(Logging.getLogger(BuildLogger.class), serviceRegistry.get(StyledTextOutputFactory.class), startParameter, requestMetaData));
    }
    listenerManager.addListener(tracker);

    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.get(ServiceRegistryFactory.class));
    return new DefaultGradleLauncher(
            gradle,
            serviceRegistry.get(InitScriptHandler.class),
            new SettingsHandler(
                    new DefaultSettingsFinder(
                            new BuildLayoutFactory()),
                    serviceRegistry.get(SettingsProcessor.class),
                    new BuildSourceBuilder(
                            this,
                            cancellationToken,
                            serviceRegistry.get(ClassLoaderScopeRegistry.class).getCoreAndPluginsScope(),
                            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),
            listenerManager.getBroadcaster(BuildCompletionListener.class),
            serviceRegistry
    );
}
 
Example 19
protected AbstractGradleExecuter(GradleDistribution distribution, TestDirectoryProvider testDirectoryProvider) {
    this.distribution = distribution;
    this.testDirectoryProvider = testDirectoryProvider;
    logger = Logging.getLogger(getClass());
}
 
Example 20
public void log(String msg, int level) {
    logger.log(Logging.ANT_IVY_2_SLF4J_LEVEL_MAPPER.get(level), msg);
}
 
Example 21
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));

    LoggerProvider loggerProvider = (tracker.getCurrentBuild() == null)? buildProgressLogger: LoggerProvider.NO_OP;
    listenerManager.useLogger(new TaskExecutionLogger(serviceRegistry.get(ProgressLoggerFactory.class), loggerProvider));
    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.get(ServiceRegistryFactory.class));
    return new DefaultGradleLauncher(
            gradle,
            serviceRegistry.get(InitScriptHandler.class),
            new SettingsHandler(
                    new DefaultSettingsFinder(
                            new BuildLayoutFactory()),
                    serviceRegistry.get(SettingsProcessor.class),
                    new BuildSourceBuilder(
                            this,
                            serviceRegistry.get(ClassLoaderScope.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));
}
 
Example 22
Source Project: android-perftracking   Source File: DummyRewriter.java    License: MIT License 4 votes vote down vote up
public DummyRewriter() {
  _log = Logging.getLogger(DummyRewriter.class.getSimpleName());
}
 
Example 23
Source Project: android-perftracking   Source File: PerformanceTrackingRewriter.java    License: MIT License 4 votes vote down vote up
public PerformanceTrackingRewriter() {
  _log = Logging.getLogger(PerformanceTrackingRewriter.class.getSimpleName());
}
 
Example 24
Source Project: javaide   Source File: DependencyManager.java    License: GNU General Public License v3.0 4 votes vote down vote up
public DependencyManager(Project project, ExtraModelInfo extraModelInfo) {
    this.project = project;
    this.extraModelInfo = extraModelInfo;
    logger = new LoggerWrapper(Logging.getLogger(DependencyManager.class));
}
 
Example 25
Source Project: javaide   Source File: BaseExtension.java    License: GNU General Public License v3.0 4 votes vote down vote up
BaseExtension(
        @NonNull final ProjectInternal project,
        @NonNull Instantiator instantiator,
        @NonNull AndroidBuilder androidBuilder,
        @NonNull SdkHandler sdkHandler,
        @NonNull NamedDomainObjectContainer<BuildType> buildTypes,
        @NonNull NamedDomainObjectContainer<ProductFlavor> productFlavors,
        @NonNull NamedDomainObjectContainer<SigningConfig> signingConfigs,
        @NonNull ExtraModelInfo extraModelInfo,
        final boolean isLibrary) {
    this.androidBuilder = androidBuilder;
    this.sdkHandler = sdkHandler;
    this.buildTypes = buildTypes;
    //noinspection unchecked
    this.productFlavors = (NamedDomainObjectContainer) productFlavors;
    this.signingConfigs = signingConfigs;
    this.extraModelInfo = extraModelInfo;
    this.project = project;

    logger = Logging.getLogger(this.getClass());

    defaultConfig = instantiator.newInstance(ProductFlavor.class, BuilderConstants.MAIN,
            project, instantiator, project.getLogger());

    aaptOptions = instantiator.newInstance(AaptOptions.class);
    dexOptions = instantiator.newInstance(DexOptions.class);
    lintOptions = instantiator.newInstance(LintOptions.class);
    compileOptions = instantiator.newInstance(CompileOptions.class);
    packagingOptions = instantiator.newInstance(PackagingOptions.class);
    preprocessingOptions = instantiator.newInstance(PreprocessingOptions.class);
    splits = instantiator.newInstance(Splits.class, instantiator);

    sourceSetsContainer = project.container(AndroidSourceSet.class,
            new AndroidSourceSetFactory(instantiator, project, isLibrary));

    sourceSetsContainer.whenObjectAdded(new Action<AndroidSourceSet>() {
        @Override
        public void execute(AndroidSourceSet sourceSet) {
            ConfigurationContainer configurations = project.getConfigurations();

            createConfiguration(
                    configurations,
                    sourceSet.getCompileConfigurationName(),
                    "Classpath for compiling the " + sourceSet.getName() + " sources.");

            String packageConfigDescription;
            if (isLibrary) {
                packageConfigDescription
                        = "Classpath only used when publishing '" + sourceSet.getName() + "'.";
            } else {
                packageConfigDescription
                        = "Classpath packaged with the compiled '" + sourceSet.getName() + "' classes.";
            }
            createConfiguration(
                    configurations,
                    sourceSet.getPackageConfigurationName(),
                    packageConfigDescription);

            createConfiguration(
                    configurations,
                    sourceSet.getProvidedConfigurationName(),
                    "Classpath for only compiling the " + sourceSet.getName() + " sources.");

            createConfiguration(
                    configurations,
                    sourceSet.getWearAppConfigurationName(),
                    "Link to a wear app to embed for object '" + sourceSet.getName() + "'.");

            sourceSet.setRoot(String.format("src/%s", sourceSet.getName()));
        }
    });

    sourceSetsContainer.create(defaultConfig.getName());
}
 
Example 26
protected AbstractGradleExecuter(GradleDistribution distribution, TestDirectoryProvider testDirectoryProvider) {
    this.distribution = distribution;
    this.testDirectoryProvider = testDirectoryProvider;
    logger = Logging.getLogger(getClass());
}
 
Example 27
public void log(String msg, int level) {
    logger.log(Logging.ANT_IVY_2_SLF4J_LEVEL_MAPPER.get(level), msg);
}
 
Example 28
private DefaultGradleLauncher doNewInstance(StartParameter startParameter, BuildCancellationToken cancellationToken, BuildRequestMetaData requestMetaData) {
    final BuildScopeServices serviceRegistry = new BuildScopeServices(sharedServices, startParameter);
    serviceRegistry.add(BuildRequestMetaData.class, requestMetaData);
    serviceRegistry.add(BuildClientMetaData.class, requestMetaData.getClient());
    serviceRegistry.add(BuildCancellationToken.class, cancellationToken);
    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));

    LoggerProvider loggerProvider = (tracker.getCurrentBuild() == null) ? buildProgressLogger : LoggerProvider.NO_OP;
    listenerManager.useLogger(new TaskExecutionLogger(serviceRegistry.get(ProgressLoggerFactory.class), loggerProvider));
    if (tracker.getCurrentBuild() == null) {
        listenerManager.useLogger(new BuildLogger(Logging.getLogger(BuildLogger.class), serviceRegistry.get(StyledTextOutputFactory.class), startParameter, requestMetaData));
    }
    listenerManager.addListener(tracker);

    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.get(ServiceRegistryFactory.class));
    return new DefaultGradleLauncher(
            gradle,
            serviceRegistry.get(InitScriptHandler.class),
            new SettingsHandler(
                    new DefaultSettingsFinder(
                            new BuildLayoutFactory()),
                    serviceRegistry.get(SettingsProcessor.class),
                    new BuildSourceBuilder(
                            this,
                            cancellationToken,
                            serviceRegistry.get(ClassLoaderScopeRegistry.class).getCoreAndPluginsScope(),
                            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),
            listenerManager.getBroadcaster(BuildCompletionListener.class),
            serviceRegistry
    );
}
 
Example 29
protected AbstractGradleExecuter(GradleDistribution distribution, TestDirectoryProvider testDirectoryProvider) {
    this.distribution = distribution;
    this.testDirectoryProvider = testDirectoryProvider;
    logger = Logging.getLogger(getClass());
}
 
Example 30
public void log(String msg, int level) {
    logger.log(Logging.ANT_IVY_2_SLF4J_LEVEL_MAPPER.get(level), msg);
}