Search in sources :

Example 21 with StartParameter

use of org.gradle.StartParameter in project gradle by gradle.

the class BuildOutcomeReportingBuildActionRunner method run.

@Override
public Result run(BuildAction action, BuildTreeLifecycleController buildController) {
    StartParameter startParameter = action.getStartParameter();
    TaskExecutionStatisticsEventAdapter taskStatisticsCollector = new TaskExecutionStatisticsEventAdapter();
    listenerManager.addListener(taskStatisticsCollector);
    BuildLogger buildLogger = buildLoggerFactory.create(Logging.getLogger(BuildLogger.class), startParameter, buildStartedTime, buildRequestMetaData);
    // Register as a 'logger' to support this being replaced by build logic.
    buildController.beforeBuild(gradle -> gradle.useLogger(buildLogger));
    Result result = delegate.run(action, buildController);
    buildLogger.logResult(result.getBuildFailure());
    new TaskExecutionStatisticsReporter(styledTextOutputFactory).buildFinished(taskStatisticsCollector.getStatistics());
    return result;
}
Also used : StartParameter(org.gradle.StartParameter) TaskExecutionStatisticsReporter(org.gradle.internal.buildevents.TaskExecutionStatisticsReporter) TaskExecutionStatisticsEventAdapter(org.gradle.api.internal.tasks.execution.statistics.TaskExecutionStatisticsEventAdapter) BuildLogger(org.gradle.internal.buildevents.BuildLogger)

Example 22 with StartParameter

use of org.gradle.StartParameter in project gradle by gradle.

the class DefaultBuildLifecycleControllerFactory method newInstance.

@Override
public BuildLifecycleController newInstance(BuildDefinition buildDefinition, BuildScopeServices buildScopeServices) {
    StartParameter startParameter = buildDefinition.getStartParameter();
    final ListenerManager listenerManager = buildScopeServices.get(ListenerManager.class);
    for (Action<ListenerManager> action : buildScopeServices.getAll(BuildScopeListenerManagerAction.class)) {
        action.execute(listenerManager);
    }
    ScriptUsageLocationReporter usageLocationReporter = new ScriptUsageLocationReporter();
    listenerManager.addListener(usageLocationReporter);
    ShowStacktrace showStacktrace = startParameter.getShowStacktrace();
    switch(showStacktrace) {
        case ALWAYS:
        case ALWAYS_FULL:
            LoggingDeprecatedFeatureHandler.setTraceLoggingEnabled(true);
            break;
        default:
            LoggingDeprecatedFeatureHandler.setTraceLoggingEnabled(false);
    }
    DeprecationLogger.init(usageLocationReporter, startParameter.getWarningMode(), buildScopeServices.get(BuildOperationProgressEventEmitter.class));
    @SuppressWarnings("deprecation") File customSettingsFile = startParameter.getSettingsFile();
    if (customSettingsFile != null) {
        DeprecationLogger.deprecateAction("Specifying custom settings file location").willBeRemovedInGradle8().withUpgradeGuideSection(7, "configuring_custom_build_layout").nagUser();
    }
    @SuppressWarnings("deprecation") File customBuildFile = startParameter.getBuildFile();
    if (customBuildFile != null) {
        DeprecationLogger.deprecateAction("Specifying custom build file location").willBeRemovedInGradle8().withUpgradeGuideSection(7, "configuring_custom_build_layout").nagUser();
    }
    GradleInternal gradle = buildScopeServices.get(GradleInternal.class);
    BuildModelController buildModelController = buildScopeServices.get(BuildModelController.class);
    return new DefaultBuildLifecycleController(gradle, buildModelController, exceptionAnalyser, gradle.getBuildListenerBroadcaster(), listenerManager.getBroadcaster(InternalBuildFinishedListener.class), gradle.getServices().get(BuildWorkPreparer.class), gradle.getServices().get(BuildWorkExecutor.class), buildScopeServices, buildToolingModelControllerFactory, stateTransitionControllerFactory);
}
Also used : StartParameter(org.gradle.StartParameter) BuildOperationProgressEventEmitter(org.gradle.internal.operations.BuildOperationProgressEventEmitter) InternalBuildFinishedListener(org.gradle.initialization.internal.InternalBuildFinishedListener) ShowStacktrace(org.gradle.api.logging.configuration.ShowStacktrace) GradleInternal(org.gradle.api.internal.GradleInternal) ScriptUsageLocationReporter(org.gradle.internal.featurelifecycle.ScriptUsageLocationReporter) BuildWorkExecutor(org.gradle.execution.BuildWorkExecutor) File(java.io.File) ListenerManager(org.gradle.internal.event.ListenerManager)

Example 23 with StartParameter

use of org.gradle.StartParameter in project gradle by gradle.

the class BuildLogger method beforeSettings.

// StartParameter.getSettingsFile() and StartParameter.getBuildFile()
@SuppressWarnings("deprecation")
@Override
public void beforeSettings(Settings settings) {
    StartParameter startParameter = settings.getStartParameter();
    logger.info("Starting Build");
    if (logger.isDebugEnabled()) {
        logger.debug("Gradle user home: {}", startParameter.getGradleUserHomeDir());
        logger.debug("Current dir: {}", startParameter.getCurrentDir());
        logger.debug("Settings file: {}", startParameter.getSettingsFile());
        logger.debug("Build file: {}", startParameter.getBuildFile());
    }
}
Also used : StartParameter(org.gradle.StartParameter)

Example 24 with StartParameter

use of org.gradle.StartParameter in project gradle by gradle.

the class GradleEnterprisePluginManager method registerMissingPluginWarning.

/**
 * This should never happen due to the auto apply behavior.
 * It's only here as a kind of safeguard or fallback.
 */
public void registerMissingPluginWarning(GradleInternal gradle) {
    if (gradle.isRootBuild()) {
        StartParameter startParameter = gradle.getStartParameter();
        boolean requested = !startParameter.isNoBuildScan() && startParameter.isBuildScan();
        if (requested) {
            gradle.addListener(new InternalBuildAdapter() {

                @Override
                public void settingsEvaluated(@Nonnull Settings settings) {
                    if (!isPresent() && !unsupported) {
                        LOGGER.warn(NO_SCAN_PLUGIN_MSG);
                    }
                }
            });
        }
    }
}
Also used : StartParameter(org.gradle.StartParameter) InternalBuildAdapter(org.gradle.internal.InternalBuildAdapter) Settings(org.gradle.api.initialization.Settings)

Example 25 with StartParameter

use of org.gradle.StartParameter in project gradle by gradle.

the class DefaultSettingsLoader method findAndLoadSettings.

@Override
public SettingsInternal findAndLoadSettings(GradleInternal gradle) {
    StartParameter startParameter = gradle.getStartParameter();
    SettingsLocation settingsLocation = buildLayoutFactory.getLayoutFor(new BuildLayoutConfiguration(startParameter));
    SettingsInternal settings = findSettingsAndLoadIfAppropriate(gradle, startParameter, settingsLocation, gradle.getClassLoaderScope());
    ProjectSpec spec = ProjectSpecs.forStartParameter(startParameter, settings);
    if (useEmptySettings(spec, settings, startParameter)) {
        settings = createEmptySettings(gradle, startParameter, settings.getClassLoaderScope());
    }
    setDefaultProject(spec, settings);
    return settings;
}
Also used : SettingsInternal(org.gradle.api.internal.SettingsInternal) StartParameter(org.gradle.StartParameter) BuildLayoutConfiguration(org.gradle.initialization.layout.BuildLayoutConfiguration)

Aggregations

StartParameter (org.gradle.StartParameter)25 GradleInternal (org.gradle.api.internal.GradleInternal)4 File (java.io.File)3 ClassPath (org.gradle.internal.classpath.ClassPath)3 ListenerManager (org.gradle.internal.event.ListenerManager)3 Path (org.gradle.util.Path)3 ArrayList (java.util.ArrayList)2 Project (org.gradle.api.Project)2 Task (org.gradle.api.Task)2 TaskExecutionStatisticsEventAdapter (org.gradle.api.internal.tasks.execution.statistics.TaskExecutionStatisticsEventAdapter)2 Gradle (org.gradle.api.invocation.Gradle)2 ShowStacktrace (org.gradle.api.logging.configuration.ShowStacktrace)2 GradleLauncher (org.gradle.initialization.GradleLauncher)2 BuildLogger (org.gradle.internal.buildevents.BuildLogger)2 TaskExecutionStatisticsReporter (org.gradle.internal.buildevents.TaskExecutionStatisticsReporter)2 ScriptUsageLocationReporter (org.gradle.internal.featurelifecycle.ScriptUsageLocationReporter)2 Properties (java.util.Properties)1 TaskExecutionRequest (org.gradle.TaskExecutionRequest)1 Settings (org.gradle.api.initialization.Settings)1 BuildDefinition (org.gradle.api.internal.BuildDefinition)1