Search in sources :

Example 26 with GradleInternal

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

the class IncludedBuildDependencyMetadataBuilder method build.

public LocalComponentMetadata build(CompositeBuildParticipantBuildState build, ProjectComponentIdentifier projectIdentifier) {
    GradleInternal gradle = build.getMutableModel();
    LocalComponentRegistry localComponentRegistry = gradle.getServices().get(LocalComponentRegistry.class);
    DefaultLocalComponentMetadata originalComponent = (DefaultLocalComponentMetadata) localComponentRegistry.getComponent(projectIdentifier);
    ProjectComponentIdentifier foreignIdentifier = build.idToReferenceProjectFromAnotherBuild(projectIdentifier);
    return createCompositeCopy(foreignIdentifier, originalComponent);
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) DefaultLocalComponentMetadata(org.gradle.internal.component.local.model.DefaultLocalComponentMetadata) LocalComponentRegistry(org.gradle.api.internal.artifacts.ivyservice.projectmodule.LocalComponentRegistry) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier)

Example 27 with GradleInternal

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

the class DefaultRootBuildState method run.

@Override
public <T> T run(Function<? super BuildTreeLifecycleController, T> action) {
    if (completed) {
        throw new IllegalStateException("Cannot run more than one action for a build.");
    }
    try {
        RootBuildLifecycleListener buildLifecycleListener = listenerManager.getBroadcaster(RootBuildLifecycleListener.class);
        buildLifecycleListener.afterStart();
        try {
            GradleInternal gradle = getBuildController().getGradle();
            DefaultDeploymentRegistry deploymentRegistry = gradle.getServices().get(DefaultDeploymentRegistry.class);
            gradle.addBuildListener(new InternalBuildAdapter() {

                @Override
                public void buildFinished(BuildResult result) {
                    deploymentRegistry.buildFinished(result);
                }
            });
            return action.apply(buildTreeLifecycleController);
        } finally {
            buildLifecycleListener.beforeComplete();
        }
    } finally {
        completed = true;
    }
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) BuildResult(org.gradle.BuildResult) DefaultDeploymentRegistry(org.gradle.deployment.internal.DefaultDeploymentRegistry) RootBuildLifecycleListener(org.gradle.initialization.RootBuildLifecycleListener) InternalBuildAdapter(org.gradle.internal.InternalBuildAdapter)

Example 28 with GradleInternal

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

the class RootOfNestedBuildTree method run.

@Override
public <T> T run(Function<? super BuildTreeLifecycleController, T> action) {
    final GradleInternal gradle = getBuildController().getGradle();
    ServiceRegistry services = gradle.getServices();
    BuildOperationExecutor executor = services.get(BuildOperationExecutor.class);
    return executor.call(new CallableBuildOperation<T>() {

        @Override
        public T call(BuildOperationContext context) {
            gradle.addBuildListener(new InternalBuildAdapter() {

                @Override
                public void settingsEvaluated(Settings settings) {
                    buildName = settings.getRootProject().getName();
                }
            });
            T result = action.apply(buildTreeLifecycleController);
            context.setResult(new RunNestedBuildBuildOperationType.Result() {
            });
            return result;
        }

        @Override
        public BuildOperationDescriptor.Builder description() {
            return BuildOperationDescriptor.displayName("Run nested build").details(new RunNestedBuildBuildOperationType.Details() {

                @Override
                public String getBuildPath() {
                    return gradle.getIdentityPath().getPath();
                }
            });
        }
    });
}
Also used : BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) GradleInternal(org.gradle.api.internal.GradleInternal) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) InternalBuildAdapter(org.gradle.internal.InternalBuildAdapter) Settings(org.gradle.api.initialization.Settings) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor)

Example 29 with GradleInternal

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

the class DefaultIncludedBuildRegistry method ensureConfigured.

@Override
public void ensureConfigured(IncludedBuildState buildToConfigure) {
    if (currentlyConfiguring.contains(buildToConfigure)) {
        return;
    }
    currentlyConfiguring.add(buildToConfigure);
    buildToConfigure.ensureProjectsConfigured();
    GradleInternal gradle = buildToConfigure.getMutableModel();
    for (IncludedBuildInternal reference : gradle.includedBuilds()) {
        BuildState target = reference.getTarget();
        if (target instanceof IncludedBuildState) {
            dependencySubstitutionsBuilder.build((IncludedBuildState) target);
        }
    }
    currentlyConfiguring.remove(buildToConfigure);
}
Also used : IncludedBuildInternal(org.gradle.internal.composite.IncludedBuildInternal) GradleInternal(org.gradle.api.internal.GradleInternal) IncludedBuildState(org.gradle.internal.build.IncludedBuildState) BuildState(org.gradle.internal.build.BuildState) RootBuildState(org.gradle.internal.build.RootBuildState) IncludedBuildState(org.gradle.internal.build.IncludedBuildState)

Example 30 with GradleInternal

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

the class TaskNameResolvingBuildConfigurationAction method configure.

@Override
public void configure(BuildExecutionContext context) {
    GradleInternal gradle = context.getGradle();
    List<TaskExecutionRequest> taskParameters = gradle.getStartParameter().getTaskRequests();
    for (TaskExecutionRequest taskParameter : taskParameters) {
        List<TaskSelection> taskSelections = commandLineTaskParser.parseTasks(taskParameter);
        for (TaskSelection taskSelection : taskSelections) {
            LOGGER.info("Selected primary task '{}' from project {}", taskSelection.getTaskName(), taskSelection.getProjectPath());
            context.getExecutionPlan().addEntryTasks(taskSelection.getTasks());
        }
    }
    context.proceed();
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) TaskExecutionRequest(org.gradle.TaskExecutionRequest)

Aggregations

GradleInternal (org.gradle.api.internal.GradleInternal)30 StartParameter (org.gradle.StartParameter)4 ShowStacktrace (org.gradle.api.logging.configuration.ShowStacktrace)3 BuildState (org.gradle.internal.build.BuildState)3 IncludedBuildState (org.gradle.internal.build.IncludedBuildState)3 IncludedBuildInternal (org.gradle.internal.composite.IncludedBuildInternal)3 ListenerManager (org.gradle.internal.event.ListenerManager)3 ScriptUsageLocationReporter (org.gradle.internal.featurelifecycle.ScriptUsageLocationReporter)3 BuildOperationExecutor (org.gradle.internal.operations.BuildOperationExecutor)3 BuildScopeServices (org.gradle.internal.service.scopes.BuildScopeServices)3 File (java.io.File)2 BuildResult (org.gradle.BuildResult)2 Project (org.gradle.api.Project)2 Task (org.gradle.api.Task)2 ExceptionAnalyser (org.gradle.api.internal.ExceptionAnalyser)2 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)2 BuildConfigurer (org.gradle.configuration.BuildConfigurer)2 BuildConfigurationActionExecuter (org.gradle.execution.BuildConfigurationActionExecuter)2 BuildExecuter (org.gradle.execution.BuildExecuter)2 InternalBuildAdapter (org.gradle.internal.InternalBuildAdapter)2