Search in sources :

Example 11 with StartParameterInternal

use of org.gradle.api.internal.StartParameterInternal in project gradle by gradle.

the class ProviderConnection method runTests.

public Object runTests(ProviderInternalTestExecutionRequest testExecutionRequest, BuildCancellationToken cancellationToken, ProviderOperationParameters providerParameters) {
    Parameters params = initParams(providerParameters);
    StartParameterInternal startParameter = new ProviderStartParameterConverter().toStartParameter(providerParameters, params.buildLayout, params.properties);
    ProgressListenerConfiguration listenerConfig = ProgressListenerConfiguration.from(providerParameters, consumerVersion);
    TestExecutionRequestAction action = TestExecutionRequestAction.create(listenerConfig.clientSubscriptions, startParameter, testExecutionRequest);
    return run(action, cancellationToken, listenerConfig, listenerConfig.buildEventConsumer, providerParameters, params);
}
Also used : TestExecutionRequestAction(org.gradle.tooling.internal.provider.action.TestExecutionRequestAction) ProviderConnectionParameters(org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters) ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) StartParameterInternal(org.gradle.api.internal.StartParameterInternal)

Example 12 with StartParameterInternal

use of org.gradle.api.internal.StartParameterInternal in project gradle by gradle.

the class ProviderConnection method runPhasedAction.

public Object runPhasedAction(InternalPhasedAction clientPhasedAction, PhasedActionResultListener resultListener, BuildCancellationToken cancellationToken, ProviderOperationParameters providerParameters) {
    List<String> tasks = providerParameters.getTasks();
    SerializedPayload serializedAction = payloadSerializer.serialize(clientPhasedAction);
    Parameters params = initParams(providerParameters);
    StartParameterInternal startParameter = new ProviderStartParameterConverter().toStartParameter(providerParameters, params.buildLayout, params.properties);
    FailsafePhasedActionResultListener failsafePhasedActionResultListener = new FailsafePhasedActionResultListener(resultListener);
    ProgressListenerConfiguration listenerConfig = ProgressListenerConfiguration.from(providerParameters, consumerVersion);
    BuildAction action = new ClientProvidedPhasedAction(startParameter, serializedAction, tasks != null, listenerConfig.clientSubscriptions);
    try {
        return run(action, cancellationToken, listenerConfig, new PhasedActionEventConsumer(failsafePhasedActionResultListener, payloadSerializer, listenerConfig.buildEventConsumer), providerParameters, params);
    } finally {
        failsafePhasedActionResultListener.rethrowErrors();
    }
}
Also used : SerializedPayload(org.gradle.tooling.internal.provider.serialization.SerializedPayload) ClientProvidedPhasedAction(org.gradle.tooling.internal.provider.action.ClientProvidedPhasedAction) ProviderConnectionParameters(org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters) ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) ClientProvidedBuildAction(org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction) BuildAction(org.gradle.internal.invocation.BuildAction)

Example 13 with StartParameterInternal

use of org.gradle.api.internal.StartParameterInternal in project gradle by gradle.

the class ProviderConnection method run.

public Object run(String modelName, BuildCancellationToken cancellationToken, ProviderOperationParameters providerParameters) {
    List<String> tasks = providerParameters.getTasks();
    if (modelName.equals(ModelIdentifier.NULL_MODEL) && tasks == null) {
        throw new IllegalArgumentException("No model type or tasks specified.");
    }
    Parameters params = initParams(providerParameters);
    if (BuildEnvironment.class.getName().equals(modelName)) {
        // we don't really need to launch the daemon to acquire information needed for BuildEnvironment
        if (tasks != null) {
            throw new IllegalArgumentException("Cannot run tasks and fetch the build environment model.");
        }
        return new DefaultBuildEnvironment(new DefaultBuildIdentifier(providerParameters.getProjectDir()), params.buildLayout.getGradleUserHomeDir(), GradleVersion.current().getVersion(), params.daemonParams.getEffectiveJvm().getJavaHome(), params.daemonParams.getEffectiveJvmArgs());
    }
    StartParameterInternal startParameter = new ProviderStartParameterConverter().toStartParameter(providerParameters, params.buildLayout, params.properties);
    ProgressListenerConfiguration listenerConfig = ProgressListenerConfiguration.from(providerParameters, consumerVersion);
    BuildAction action = new BuildModelAction(startParameter, modelName, tasks != null, listenerConfig.clientSubscriptions);
    return run(action, cancellationToken, listenerConfig, listenerConfig.buildEventConsumer, providerParameters, params);
}
Also used : DefaultBuildEnvironment(org.gradle.tooling.internal.build.DefaultBuildEnvironment) ProviderConnectionParameters(org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters) ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildIdentifier(org.gradle.tooling.internal.gradle.DefaultBuildIdentifier) BuildEnvironment(org.gradle.tooling.model.build.BuildEnvironment) DefaultBuildEnvironment(org.gradle.tooling.internal.build.DefaultBuildEnvironment) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) ClientProvidedBuildAction(org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction) BuildAction(org.gradle.internal.invocation.BuildAction) BuildModelAction(org.gradle.tooling.internal.provider.action.BuildModelAction)

Example 14 with StartParameterInternal

use of org.gradle.api.internal.StartParameterInternal in project gradle by gradle.

the class ProjectBuilderImpl method createProject.

public ProjectInternal createProject(String name, File inputProjectDir, File gradleUserHomeDir) {
    final File projectDir = prepareProjectDir(inputProjectDir);
    File userHomeDir = gradleUserHomeDir == null ? new File(projectDir, "userHome") : FileUtils.canonicalize(gradleUserHomeDir);
    StartParameterInternal startParameter = new StartParameterInternal();
    startParameter.setGradleUserHomeDir(userHomeDir);
    NativeServices.initializeOnDaemon(userHomeDir);
    final ServiceRegistry globalServices = getGlobalServices();
    BuildRequestMetaData buildRequestMetaData = new DefaultBuildRequestMetaData(Time.currentTimeMillis());
    CrossBuildSessionState crossBuildSessionState = new CrossBuildSessionState(globalServices, startParameter);
    GradleUserHomeScopeServiceRegistry userHomeServices = userHomeServicesOf(globalServices);
    BuildSessionState buildSessionState = new BuildSessionState(userHomeServices, crossBuildSessionState, startParameter, buildRequestMetaData, ClassPath.EMPTY, new DefaultBuildCancellationToken(), buildRequestMetaData.getClient(), new NoOpBuildEventConsumer());
    BuildTreeModelControllerServices.Supplier modelServices = buildSessionState.getServices().get(BuildTreeModelControllerServices.class).servicesForBuildTree(new RunTasksRequirements(startParameter));
    BuildTreeState buildTreeState = new BuildTreeState(buildSessionState.getServices(), modelServices);
    TestRootBuild build = new TestRootBuild(projectDir, startParameter, buildTreeState);
    BuildScopeServices buildServices = build.getBuildServices();
    buildServices.get(BuildStateRegistry.class).attachRootBuild(build);
    // Take a root worker lease; this won't ever be released as ProjectBuilder has no lifecycle
    ResourceLockCoordinationService coordinationService = buildServices.get(ResourceLockCoordinationService.class);
    WorkerLeaseService workerLeaseService = buildServices.get(WorkerLeaseService.class);
    WorkerLeaseRegistry.WorkerLeaseCompletion workerLease = workerLeaseService.maybeStartWorker();
    GradleInternal gradle = build.getMutableModel();
    gradle.setIncludedBuilds(Collections.emptyList());
    ProjectDescriptorRegistry projectDescriptorRegistry = buildServices.get(ProjectDescriptorRegistry.class);
    DefaultProjectDescriptor projectDescriptor = new DefaultProjectDescriptor(null, name, projectDir, projectDescriptorRegistry, buildServices.get(FileResolver.class));
    projectDescriptorRegistry.addProject(projectDescriptor);
    ClassLoaderScope baseScope = gradle.getClassLoaderScope();
    ClassLoaderScope rootProjectScope = baseScope.createChild("root-project");
    ProjectStateRegistry projectStateRegistry = buildServices.get(ProjectStateRegistry.class);
    ProjectState projectState = projectStateRegistry.registerProject(build, projectDescriptor);
    projectState.createMutableModel(rootProjectScope, baseScope);
    ProjectInternal project = projectState.getMutableModel();
    gradle.setRootProject(project);
    gradle.setDefaultProject(project);
    // Lock root project; this won't ever be released as ProjectBuilder has no lifecycle
    coordinationService.withStateLock(DefaultResourceLockCoordinationService.lock(project.getOwner().getAccessLock()));
    project.getExtensions().getExtraProperties().set("ProjectBuilder.stoppable", stoppable((Stoppable) workerLeaseService::runAsIsolatedTask, (Stoppable) workerLease::leaseFinish, buildServices, buildTreeState, buildSessionState, crossBuildSessionState));
    return project;
}
Also used : BuildRequestMetaData(org.gradle.initialization.BuildRequestMetaData) DefaultBuildRequestMetaData(org.gradle.initialization.DefaultBuildRequestMetaData) WorkerLeaseRegistry(org.gradle.internal.work.WorkerLeaseRegistry) GradleUserHomeScopeServiceRegistry(org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry) GradleInternal(org.gradle.api.internal.GradleInternal) BuildTreeModelControllerServices(org.gradle.internal.buildtree.BuildTreeModelControllerServices) RunTasksRequirements(org.gradle.internal.buildtree.RunTasksRequirements) ResourceLockCoordinationService(org.gradle.internal.resources.ResourceLockCoordinationService) DefaultResourceLockCoordinationService(org.gradle.internal.resources.DefaultResourceLockCoordinationService) FileResolver(org.gradle.api.internal.file.FileResolver) WorkerLeaseService(org.gradle.internal.work.WorkerLeaseService) CrossBuildSessionState(org.gradle.internal.session.CrossBuildSessionState) BuildStateRegistry(org.gradle.internal.build.BuildStateRegistry) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) DefaultBuildRequestMetaData(org.gradle.initialization.DefaultBuildRequestMetaData) CrossBuildSessionState(org.gradle.internal.session.CrossBuildSessionState) BuildSessionState(org.gradle.internal.session.BuildSessionState) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) BuildScopeServices(org.gradle.internal.service.scopes.BuildScopeServices) Stoppable(org.gradle.internal.concurrent.Stoppable) BuildTreeState(org.gradle.internal.buildtree.BuildTreeState) DefaultProjectDescriptor(org.gradle.initialization.DefaultProjectDescriptor) NoOpBuildEventConsumer(org.gradle.initialization.NoOpBuildEventConsumer) ProjectDescriptorRegistry(org.gradle.initialization.ProjectDescriptorRegistry) DefaultBuildCancellationToken(org.gradle.initialization.DefaultBuildCancellationToken) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) ProjectState(org.gradle.api.internal.project.ProjectState) GradleUserHomeScopeServiceRegistry(org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry) LoggingServiceRegistry(org.gradle.internal.logging.services.LoggingServiceRegistry) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) ProjectStateRegistry(org.gradle.api.internal.project.ProjectStateRegistry) File(java.io.File)

Example 15 with StartParameterInternal

use of org.gradle.api.internal.StartParameterInternal in project gradle by gradle.

the class DefaultNestedBuildTree method run.

@Override
public <T> T run(Function<? super BuildTreeLifecycleController, T> buildAction) {
    StartParameterInternal startParameter = buildDefinition.getStartParameter();
    BuildRequestMetaData buildRequestMetaData = new DefaultBuildRequestMetaData(Time.currentTimeMillis());
    BuildSessionState session = new BuildSessionState(userHomeDirServiceRegistry, crossBuildSessionState, startParameter, buildRequestMetaData, ClassPath.EMPTY, buildCancellationToken, buildRequestMetaData.getClient(), new NoOpBuildEventConsumer());
    try {
        session.getServices().get(BuildLayoutValidator.class).validate(startParameter);
        BuildTreeModelControllerServices.Supplier modelServices = session.getServices().get(BuildTreeModelControllerServices.class).servicesForNestedBuildTree(startParameter);
        BuildTreeState buildTree = new BuildTreeState(session.getServices(), modelServices);
        try {
            RootOfNestedBuildTree rootBuild = new RootOfNestedBuildTree(buildDefinition, buildIdentifier, identityPath, owner, buildTree);
            rootBuild.attach();
            return rootBuild.run(buildAction);
        } finally {
            buildTree.close();
        }
    } finally {
        session.close();
    }
}
Also used : NoOpBuildEventConsumer(org.gradle.initialization.NoOpBuildEventConsumer) BuildRequestMetaData(org.gradle.initialization.BuildRequestMetaData) DefaultBuildRequestMetaData(org.gradle.initialization.DefaultBuildRequestMetaData) BuildLayoutValidator(org.gradle.internal.build.BuildLayoutValidator) BuildTreeModelControllerServices(org.gradle.internal.buildtree.BuildTreeModelControllerServices) DefaultBuildRequestMetaData(org.gradle.initialization.DefaultBuildRequestMetaData) CrossBuildSessionState(org.gradle.internal.session.CrossBuildSessionState) BuildSessionState(org.gradle.internal.session.BuildSessionState) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) BuildTreeState(org.gradle.internal.buildtree.BuildTreeState)

Aggregations

StartParameterInternal (org.gradle.api.internal.StartParameterInternal)17 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)6 BuildAction (org.gradle.internal.invocation.BuildAction)5 DaemonParameters (org.gradle.launcher.daemon.configuration.DaemonParameters)5 ProviderConnectionParameters (org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters)4 ProviderOperationParameters (org.gradle.tooling.internal.provider.connection.ProviderOperationParameters)4 File (java.io.File)3 CommandLineParser (org.gradle.cli.CommandLineParser)3 BuildSessionState (org.gradle.internal.session.BuildSessionState)3 CrossBuildSessionState (org.gradle.internal.session.CrossBuildSessionState)3 ClientProvidedBuildAction (org.gradle.tooling.internal.provider.action.ClientProvidedBuildAction)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 BuildResult (org.gradle.BuildResult)2 CommandLineArgumentException (org.gradle.cli.CommandLineArgumentException)2 BuildRequestContext (org.gradle.initialization.BuildRequestContext)2 BuildRequestMetaData (org.gradle.initialization.BuildRequestMetaData)2 DefaultBuildRequestContext (org.gradle.initialization.DefaultBuildRequestContext)2 DefaultBuildRequestMetaData (org.gradle.initialization.DefaultBuildRequestMetaData)2 NoOpBuildEventConsumer (org.gradle.initialization.NoOpBuildEventConsumer)2