Search in sources :

Example 1 with BasicGradleProject

use of org.gradle.tooling.internal.gradle.BasicGradleProject in project gradle by gradle.

the class GradleBuildBuilder method convert.

private DefaultGradleBuild convert(Gradle gradle) {
    DefaultGradleBuild model = new DefaultGradleBuild();
    Map<Project, BasicGradleProject> convertedProjects = new LinkedHashMap<Project, BasicGradleProject>();
    Project rootProject = gradle.getRootProject();
    BasicGradleProject convertedRootProject = convert(rootProject, convertedProjects);
    model.setRootProject(convertedRootProject);
    for (Project project : rootProject.getAllprojects()) {
        model.addProject(convertedProjects.get(project));
    }
    for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
        Gradle includedGradle = ((IncludedBuildInternal) includedBuild).getConfiguredBuild();
        DefaultGradleBuild convertedIncludedBuild = convert(includedGradle);
        model.addIncludedBuild(convertedIncludedBuild);
    }
    return model;
}
Also used : Project(org.gradle.api.Project) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) IncludedBuildInternal(org.gradle.composite.internal.IncludedBuildInternal) DefaultGradleBuild(org.gradle.tooling.internal.gradle.DefaultGradleBuild) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) Gradle(org.gradle.api.invocation.Gradle) LinkedHashMap(java.util.LinkedHashMap) IncludedBuild(org.gradle.api.initialization.IncludedBuild)

Example 2 with BasicGradleProject

use of org.gradle.tooling.internal.gradle.BasicGradleProject in project gradle by gradle.

the class GradleBuildBuilder method convert.

private BasicGradleProject convert(Project project, Map<Project, BasicGradleProject> convertedProjects) {
    DefaultProjectIdentifier id = new DefaultProjectIdentifier(project.getRootDir(), project.getPath());
    BasicGradleProject converted = new BasicGradleProject().setName(project.getName()).setProjectIdentifier(id);
    converted.setProjectDirectory(project.getProjectDir());
    if (project.getParent() != null) {
        converted.setParent(convertedProjects.get(project.getParent()));
    }
    convertedProjects.put(project, converted);
    for (Project child : project.getChildProjects().values()) {
        converted.addChild(convert(child, convertedProjects));
    }
    return converted;
}
Also used : Project(org.gradle.api.Project) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Aggregations

Project (org.gradle.api.Project)2 BasicGradleProject (org.gradle.tooling.internal.gradle.BasicGradleProject)2 LinkedHashMap (java.util.LinkedHashMap)1 IncludedBuild (org.gradle.api.initialization.IncludedBuild)1 Gradle (org.gradle.api.invocation.Gradle)1 IncludedBuildInternal (org.gradle.composite.internal.IncludedBuildInternal)1 DefaultGradleBuild (org.gradle.tooling.internal.gradle.DefaultGradleBuild)1 DefaultProjectIdentifier (org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)1