Search in sources :

Example 1 with DefaultGradleBuild

use of org.gradle.plugins.ide.internal.tooling.model.DefaultGradleBuild 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 2 with DefaultGradleBuild

use of org.gradle.plugins.ide.internal.tooling.model.DefaultGradleBuild in project gradle by gradle.

the class GradleBuildBuilder method convert.

private DefaultGradleBuild convert(BuildState targetBuild, Map<BuildState, DefaultGradleBuild> all) {
    DefaultGradleBuild model = all.get(targetBuild);
    if (model != null) {
        return model;
    }
    model = new DefaultGradleBuild();
    all.put(targetBuild, model);
    // Make sure the project tree has been loaded and can be queried (but not necessarily configured)
    targetBuild.ensureProjectsLoaded();
    GradleInternal gradle = targetBuild.getMutableModel();
    addProjects(targetBuild, model);
    addIncludedBuilds(gradle, model, all);
    if (gradle.getParent() == null) {
        List<DefaultGradleBuild> allBuilds = new ArrayList<>();
        buildStateRegistry.visitBuilds(buildState -> {
            // Do not include the root build and only include builds that are intended to be imported into an IDE
            if (buildState != targetBuild && buildState.isImportableBuild()) {
                allBuilds.add(convert(buildState, all));
            }
        });
        model.addBuilds(allBuilds);
    }
    return model;
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) DefaultGradleBuild(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleBuild) ArrayList(java.util.ArrayList)

Aggregations

DefaultGradleBuild (org.gradle.plugins.ide.internal.tooling.model.DefaultGradleBuild)2 ArrayList (java.util.ArrayList)1 GradleInternal (org.gradle.api.internal.GradleInternal)1 BuildState (org.gradle.internal.build.BuildState)1 IncludedBuildState (org.gradle.internal.build.IncludedBuildState)1 RootBuildState (org.gradle.internal.build.RootBuildState)1 IncludedBuildInternal (org.gradle.internal.composite.IncludedBuildInternal)1