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());
}
}
}
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;
}
Aggregations