Search in sources :

Example 6 with IncludedBuildState

use of org.gradle.internal.build.IncludedBuildState 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)

Example 7 with IncludedBuildState

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

the class EclipseModelBuilder method applyEclipsePlugin.

private void applyEclipsePlugin(ProjectInternal root, List<GradleInternal> alreadyProcessed) {
    Set<Project> allProjects = root.getAllprojects();
    for (Project p : allProjects) {
        p.getPluginManager().apply(EclipsePlugin.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);
                applyEclipsePlugin(build.getRootProject(), alreadyProcessed);
            }
        }
    }
}
Also used : Project(org.gradle.api.Project) EclipseWorkspaceProject(org.gradle.tooling.model.eclipse.EclipseWorkspaceProject) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) DefaultEclipseProject(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject) 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 8 with IncludedBuildState

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

the class ChildBuildRegisteringSettingsLoader method findAndLoadSettings.

@Override
public SettingsInternal findAndLoadSettings(GradleInternal gradle) {
    SettingsInternal settings = delegate.findAndLoadSettings(gradle);
    // Add included builds defined in settings
    List<IncludedBuildSpec> includedBuilds = settings.getIncludedBuilds();
    if (!includedBuilds.isEmpty()) {
        Set<IncludedBuildInternal> children = new LinkedHashSet<>(includedBuilds.size());
        RootBuildState rootBuild = buildRegistry.getRootBuild();
        for (IncludedBuildSpec includedBuildSpec : includedBuilds) {
            if (!includedBuildSpec.rootDir.equals(rootBuild.getBuildRootDir())) {
                IncludedBuildState includedBuild = buildIncluder.includeBuild(includedBuildSpec);
                children.add(includedBuild.getModel());
            } else {
                buildRegistry.registerSubstitutionsForRootBuild();
                children.add(buildRegistry.getRootBuild().getModel());
            }
        }
        // Set the visible included builds
        gradle.setIncludedBuilds(children);
    } else {
        gradle.setIncludedBuilds(Collections.emptyList());
    }
    return settings;
}
Also used : SettingsInternal(org.gradle.api.internal.SettingsInternal) LinkedHashSet(java.util.LinkedHashSet) RootBuildState(org.gradle.internal.build.RootBuildState) IncludedBuildSpec(org.gradle.initialization.IncludedBuildSpec) IncludedBuildState(org.gradle.internal.build.IncludedBuildState)

Example 9 with IncludedBuildState

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

the class ProjectReportTask method generate.

@Override
protected void generate(Project project) {
    BuildClientMetaData metaData = getClientMetaData();
    StyledTextOutput textOutput = getRenderer().getTextOutput();
    render(project, new GraphRenderer(textOutput), true, textOutput);
    if (project.getChildProjects().isEmpty()) {
        textOutput.withStyle(Info).text("No sub-projects");
        textOutput.println();
    }
    if (project == project.getRootProject()) {
        int i = 0;
        Collection<? extends IncludedBuildState> includedBuilds = getBuildStateRegistry().getIncludedBuilds();
        if (!includedBuilds.isEmpty()) {
            GraphRenderer renderer = new GraphRenderer(textOutput);
            textOutput.println();
            textOutput.text("Included builds");
            textOutput.println();
            renderer.startChildren();
            for (IncludedBuildState includedBuildState : includedBuilds) {
                renderer.visit(text -> {
                    textOutput.text("Included build '" + includedBuildState.getIdentityPath() + "'");
                }, (i + 1) == includedBuilds.size());
                i++;
            }
            renderer.completeChildren();
        }
    }
    textOutput.println();
    textOutput.text("To see a list of the tasks of a project, run ");
    metaData.describeCommand(textOutput.withStyle(UserInput), "<project-path>:" + ProjectInternal.TASKS_TASK);
    textOutput.println();
    textOutput.text("For example, try running ");
    Project exampleProject = project.getChildProjects().isEmpty() ? project : getChildren(project).get(0);
    metaData.describeCommand(textOutput.withStyle(UserInput), exampleProject.absoluteProjectPath(ProjectInternal.TASKS_TASK));
    textOutput.println();
    if (project != project.getRootProject()) {
        textOutput.println();
        textOutput.text("To see a list of all the projects in this build, run ");
        metaData.describeCommand(textOutput.withStyle(UserInput), project.getRootProject().absoluteProjectPath(ProjectInternal.PROJECTS_TASK));
        textOutput.println();
    }
}
Also used : BuildClientMetaData(org.gradle.initialization.BuildClientMetaData) Project(org.gradle.api.Project) GraphRenderer(org.gradle.internal.graph.GraphRenderer) IncludedBuildState(org.gradle.internal.build.IncludedBuildState) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput)

Example 10 with IncludedBuildState

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

the class DefaultIncludedBuildRegistry method finalizeIncludedBuilds.

@Override
public void finalizeIncludedBuilds() {
    while (!pendingIncludedBuilds.isEmpty()) {
        IncludedBuildState build = pendingIncludedBuilds.removeFirst();
        assertNameDoesNotClashWithRootSubproject(build);
    }
}
Also used : IncludedBuildState(org.gradle.internal.build.IncludedBuildState)

Aggregations

IncludedBuildState (org.gradle.internal.build.IncludedBuildState)11 BuildState (org.gradle.internal.build.BuildState)5 IncludedBuildInternal (org.gradle.internal.composite.IncludedBuildInternal)5 GradleInternal (org.gradle.api.internal.GradleInternal)4 Project (org.gradle.api.Project)3 RootBuildState (org.gradle.internal.build.RootBuildState)3 File (java.io.File)2 BuildDefinition (org.gradle.api.internal.BuildDefinition)2 DefaultGradleProject (org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject)2 LinkedHashSet (java.util.LinkedHashSet)1 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)1 BuildIdentifier (org.gradle.api.artifacts.component.BuildIdentifier)1 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)1 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)1 SettingsInternal (org.gradle.api.internal.SettingsInternal)1 DefaultBuildIdentifier (org.gradle.api.internal.artifacts.DefaultBuildIdentifier)1 BuildClientMetaData (org.gradle.initialization.BuildClientMetaData)1 IncludedBuildSpec (org.gradle.initialization.IncludedBuildSpec)1 Pair (org.gradle.internal.Pair)1 LocalComponentMetadata (org.gradle.internal.component.local.model.LocalComponentMetadata)1