Search in sources :

Example 1 with BuildState

use of org.gradle.internal.build.BuildState in project gradle by gradle.

the class CompositeBuildClassPathInitializer method execute.

@Override
public void execute(Configuration classpath) {
    List<TaskIdentifier> tasksToBuild = new ArrayList<>();
    for (Task task : classpath.getBuildDependencies().getDependencies(null)) {
        if (!task.getState().getExecuted()) {
            // This check should live lower down, and should have some kind of synchronization around it, as other threads may be
            // running tasks at the same time
            BuildState targetBuild = ((ProjectInternal) task.getProject()).getOwner().getOwner();
            assert targetBuild != currentBuild;
            tasksToBuild.add(TaskIdentifier.of(targetBuild.getBuildIdentifier(), (TaskInternal) task));
        }
    }
    if (!tasksToBuild.isEmpty()) {
        buildTreeWorkGraphController.withNewWorkGraph(graph -> {
            graph.scheduleWork(builder -> {
                for (TaskIdentifier taskIdentifier : tasksToBuild) {
                    buildTreeWorkGraphController.locateTask(taskIdentifier).queueForExecution();
                }
            });
            graph.runWork().rethrow();
            return null;
        });
    }
}
Also used : Task(org.gradle.api.Task) TaskInternal(org.gradle.api.internal.TaskInternal) ArrayList(java.util.ArrayList) BuildState(org.gradle.internal.build.BuildState)

Example 2 with BuildState

use of org.gradle.internal.build.BuildState in project gradle by gradle.

the class DefaultIncludedBuildTaskGraph method locateTask.

@Override
public IncludedBuildTaskResource locateTask(TaskIdentifier taskIdentifier) {
    return withState(workGraph -> {
        BuildState build = buildRegistry.getBuild(taskIdentifier.getBuildIdentifier());
        ExportedTaskNode taskNode = build.getWorkGraph().locateTask(taskIdentifier);
        return new TaskBackedResource(workGraph, build, taskNode);
    });
}
Also used : ExportedTaskNode(org.gradle.internal.build.ExportedTaskNode) BuildState(org.gradle.internal.build.BuildState)

Example 3 with BuildState

use of org.gradle.internal.build.BuildState in project gradle by gradle.

the class GradleBuildBuilder method addIncludedBuilds.

private void addIncludedBuilds(GradleInternal gradle, DefaultGradleBuild model, Map<BuildState, DefaultGradleBuild> all) {
    for (IncludedBuildInternal reference : gradle.includedBuilds()) {
        BuildState target = reference.getTarget();
        if (target instanceof IncludedBuildState) {
            IncludedBuildState includedBuildState = (IncludedBuildState) target;
            DefaultGradleBuild convertedIncludedBuild = convert(includedBuildState, all);
            model.addIncludedBuild(convertedIncludedBuild);
        } else if (target instanceof RootBuildState) {
            DefaultGradleBuild rootBuild = convert(target, all);
            model.addIncludedBuild(rootBuild);
        } else {
            throw new IllegalStateException("Unknown build type: " + reference.getClass().getName());
        }
    }
}
Also used : IncludedBuildInternal(org.gradle.internal.composite.IncludedBuildInternal) RootBuildState(org.gradle.internal.build.RootBuildState) DefaultGradleBuild(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleBuild) 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 4 with BuildState

use of org.gradle.internal.build.BuildState in project gradle by gradle.

the class IdeaModelBuilder method applyIdeaPlugin.

private void applyIdeaPlugin(ProjectInternal root, List<GradleInternal> alreadyProcessed) {
    Set<Project> allProjects = root.getAllprojects();
    for (Project p : allProjects) {
        p.getPluginManager().apply(IdeaPlugin.class);
    }
    for (IncludedBuildInternal reference : root.getGradle().includedBuilds()) {
        BuildState target = reference.getTarget();
        if (target instanceof IncludedBuildState) {
            target.ensureProjectsConfigured();
            GradleInternal build = target.getMutableModel();
            if (!alreadyProcessed.contains(build)) {
                alreadyProcessed.add(build);
                applyIdeaPlugin(build.getRootProject(), alreadyProcessed);
            }
        }
    }
}
Also used : IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) Project(org.gradle.api.Project) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) IncludedBuildInternal(org.gradle.internal.composite.IncludedBuildInternal) GradleInternal(org.gradle.api.internal.GradleInternal) IncludedBuildState(org.gradle.internal.build.IncludedBuildState) BuildState(org.gradle.internal.build.BuildState) IncludedBuildState(org.gradle.internal.build.IncludedBuildState)

Example 5 with BuildState

use of org.gradle.internal.build.BuildState in project gradle by gradle.

the class EclipseModelBuilder method collectAllProjects.

private List<Project> collectAllProjects(List<Project> all, GradleInternal gradle, Set<Gradle> allBuilds) {
    all.addAll(gradle.getRootProject().getAllprojects());
    for (IncludedBuildInternal reference : gradle.includedBuilds()) {
        BuildState target = reference.getTarget();
        if (target instanceof IncludedBuildState) {
            target.ensureProjectsConfigured();
            GradleInternal build = target.getMutableModel();
            if (!allBuilds.contains(build)) {
                allBuilds.add(build);
                collectAllProjects(all, build, allBuilds);
            }
        }
    }
    return all;
}
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) IncludedBuildState(org.gradle.internal.build.IncludedBuildState)

Aggregations

BuildState (org.gradle.internal.build.BuildState)11 IncludedBuildState (org.gradle.internal.build.IncludedBuildState)8 IncludedBuildInternal (org.gradle.internal.composite.IncludedBuildInternal)5 GradleInternal (org.gradle.api.internal.GradleInternal)4 RootBuildState (org.gradle.internal.build.RootBuildState)4 ArrayList (java.util.ArrayList)2 Project (org.gradle.api.Project)2 DefaultGradleProject (org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject)2 Task (org.gradle.api.Task)1 TaskInternal (org.gradle.api.internal.TaskInternal)1 ProjectState (org.gradle.api.internal.project.ProjectState)1 ExportedTaskNode (org.gradle.internal.build.ExportedTaskNode)1 IdeaProject (org.gradle.plugins.ide.idea.model.IdeaProject)1 DefaultEclipseProject (org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject)1 DefaultIdeaProject (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject)1 DefaultGradleBuild (org.gradle.plugins.ide.internal.tooling.model.DefaultGradleBuild)1 GradleBuildIdentity (org.gradle.tooling.internal.gradle.GradleBuildIdentity)1 GradleProjectIdentity (org.gradle.tooling.internal.gradle.GradleProjectIdentity)1 EclipseWorkspaceProject (org.gradle.tooling.model.eclipse.EclipseWorkspaceProject)1 Path (org.gradle.util.Path)1