Search in sources :

Example 16 with StartParameter

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

the class BuildCacheTaskServices method doCreateBuildCacheController.

private BuildCacheController doCreateBuildCacheController(ServiceRegistry serviceRegistry, BuildCacheConfigurationInternal buildCacheConfiguration, BuildOperationExecutor buildOperationExecutor, InstantiatorFactory instantiatorFactory, GradleInternal gradle) {
    StartParameter startParameter = gradle.getStartParameter();
    Path buildIdentityPath = gradle.getIdentityPath();
    File gradleUserHomeDir = gradle.getGradleUserHomeDir();
    BuildCacheMode buildCacheMode = startParameter.isBuildCacheEnabled() ? ENABLED : DISABLED;
    RemoteAccessMode remoteAccessMode = startParameter.isOffline() ? OFFLINE : ONLINE;
    boolean logStackTraces = startParameter.getShowStacktrace() != ShowStacktrace.INTERNAL_EXCEPTIONS;
    return BuildCacheControllerFactory.create(buildOperationExecutor, buildIdentityPath, gradleUserHomeDir, buildCacheConfiguration, buildCacheMode, remoteAccessMode, logStackTraces, instantiatorFactory.inject(serviceRegistry));
}
Also used : Path(org.gradle.util.Path) StartParameter(org.gradle.StartParameter) RemoteAccessMode(org.gradle.caching.internal.controller.BuildCacheControllerFactory.RemoteAccessMode) File(java.io.File) BuildCacheMode(org.gradle.caching.internal.controller.BuildCacheControllerFactory.BuildCacheMode)

Example 17 with StartParameter

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

the class ParallelismConfigurationBuildActionExecuter method execute.

@Override
public Object execute(BuildAction action, BuildRequestContext requestContext, BuildActionParameters actionParameters, ServiceRegistry contextServices) {
    StartParameter startParameter = action.getStartParameter();
    parallelismConfigurationManager.setParallelismConfiguration(new DefaultParallelismConfiguration(startParameter.isParallelProjectExecutionEnabled(), startParameter.getMaxWorkerCount()));
    try {
        return delegate.execute(action, requestContext, actionParameters, contextServices);
    } finally {
        parallelismConfigurationManager.setParallelismConfiguration(DefaultParallelismConfiguration.DEFAULT);
    }
}
Also used : DefaultParallelismConfiguration(org.gradle.internal.concurrent.DefaultParallelismConfiguration) StartParameter(org.gradle.StartParameter)

Example 18 with StartParameter

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

the class ServicesSetupBuildActionExecuter method execute.

@Override
public Object execute(BuildAction action, BuildRequestContext requestContext, BuildActionParameters actionParameters, ServiceRegistry contextServices) {
    StartParameter startParameter = action.getStartParameter();
    final ServiceRegistry userHomeServices = userHomeServiceRegistry.getServicesFor(startParameter.getGradleUserHomeDir());
    CrossBuildSessionScopeServices crossBuildSessionScopeServices = new CrossBuildSessionScopeServices(contextServices, startParameter);
    try {
        ServiceRegistry buildSessionScopeServices = new BuildSessionScopeServices(userHomeServices, crossBuildSessionScopeServices, startParameter, requestContext, actionParameters.getInjectedPluginClasspath());
        try {
            SessionLifecycleListener sessionLifecycleListener = buildSessionScopeServices.get(ListenerManager.class).getBroadcaster(SessionLifecycleListener.class);
            try {
                sessionLifecycleListener.afterStart();
                return delegate.execute(action, requestContext, actionParameters, buildSessionScopeServices);
            } finally {
                sessionLifecycleListener.beforeComplete();
            }
        } finally {
            CompositeStoppable.stoppable(buildSessionScopeServices).stop();
        }
    } finally {
        new CompositeStoppable().add(new Stoppable() {

            @Override
            public void stop() {
                userHomeServiceRegistry.release(userHomeServices);
            }
        }, crossBuildSessionScopeServices).stop();
    }
}
Also used : StartParameter(org.gradle.StartParameter) CrossBuildSessionScopeServices(org.gradle.internal.service.scopes.CrossBuildSessionScopeServices) SessionLifecycleListener(org.gradle.initialization.SessionLifecycleListener) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) GradleUserHomeScopeServiceRegistry(org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry) BuildSessionScopeServices(org.gradle.internal.service.scopes.BuildSessionScopeServices) CrossBuildSessionScopeServices(org.gradle.internal.service.scopes.CrossBuildSessionScopeServices) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) ListenerManager(org.gradle.internal.event.ListenerManager)

Example 19 with StartParameter

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

the class DefaultAutoAppliedPluginRegistry method shouldApplyGradleEnterprisePlugin.

private boolean shouldApplyGradleEnterprisePlugin(Settings settings) {
    Gradle gradle = settings.getGradle();
    StartParameter startParameter = gradle.getStartParameter();
    return startParameter.isBuildScan() && gradle.getParent() == null;
}
Also used : StartParameter(org.gradle.StartParameter) Gradle(org.gradle.api.invocation.Gradle)

Example 20 with StartParameter

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

the class StartParamsValidatingActionExecuter method execute.

@Override
public BuildActionResult execute(BuildAction action, BuildActionParameters actionParameters, BuildRequestContext requestContext) {
    StartParameter startParameter = action.getStartParameter();
    @SuppressWarnings("deprecation") File customBuildFile = startParameter.getBuildFile();
    if (customBuildFile != null) {
        validateIsFileAndExists(customBuildFile, "build file");
    }
    if (startParameter.getProjectDir() != null) {
        if (!startParameter.getProjectDir().isDirectory()) {
            if (!startParameter.getProjectDir().exists()) {
                throw new IllegalArgumentException(String.format("The specified project directory '%s' does not exist.", startParameter.getProjectDir()));
            }
            throw new IllegalArgumentException(String.format("The specified project directory '%s' is not a directory.", startParameter.getProjectDir()));
        }
    }
    @SuppressWarnings("deprecation") File customSettingsFile = startParameter.getSettingsFile();
    if (customSettingsFile != null) {
        validateIsFileAndExists(customSettingsFile, "settings file");
    }
    for (File initScript : startParameter.getInitScripts()) {
        validateIsFileAndExists(initScript, "initialization script");
    }
    return delegate.execute(action, actionParameters, requestContext);
}
Also used : StartParameter(org.gradle.StartParameter) File(java.io.File)

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