Search in sources :

Example 16 with GradleBuild

use of org.gradle.tooling.model.gradle.GradleBuild in project intellij-community by JetBrains.

the class ProjectImportAction method execute.

@Nullable
@Override
public AllModels execute(final BuildController controller) {
    configureAdditionalTypes(controller);
    //outer conditional is needed to be compatible with 1.8
    final IdeaProject ideaProject = myIsPreviewMode ? controller.getModel(BasicIdeaProject.class) : controller.getModel(IdeaProject.class);
    if (ideaProject == null || ideaProject.getModules().isEmpty()) {
        return null;
    }
    AllModels allModels = new AllModels(ideaProject);
    allModels.setGradleProjectDirSupported(myIsGradleProjectDirSupported);
    BuildEnvironment buildEnvironment = controller.findModel(BuildEnvironment.class);
    allModels.setBuildEnvironment(buildEnvironment);
    addExtraProject(controller, allModels, null);
    for (IdeaModule module : ideaProject.getModules()) {
        addExtraProject(controller, allModels, module);
    }
    if (myIsCompositeBuildsSupported) {
        GradleBuild gradleBuild = controller.getModel(GradleBuild.class);
        for (GradleBuild build : gradleBuild.getIncludedBuilds()) {
            IdeaProject ideaIncludedProject = controller.findModel(build, IdeaProject.class);
            allModels.getIncludedBuilds().add(ideaIncludedProject);
            for (IdeaModule module : ideaIncludedProject.getModules()) {
                addExtraProject(controller, allModels, module);
            }
        }
    }
    return allModels;
}
Also used : IdeaProject(org.gradle.tooling.model.idea.IdeaProject) BasicIdeaProject(org.gradle.tooling.model.idea.BasicIdeaProject) IdeaModule(org.gradle.tooling.model.idea.IdeaModule) BuildEnvironment(org.gradle.tooling.model.build.BuildEnvironment) BasicIdeaProject(org.gradle.tooling.model.idea.BasicIdeaProject) GradleBuild(org.gradle.tooling.model.gradle.GradleBuild) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with GradleBuild

use of org.gradle.tooling.model.gradle.GradleBuild in project gradle by gradle.

the class GetModel method execute.

@Override
public Map<String, AndroidProject> execute(BuildController controller) {
    System.out.println("* Building models");
    Timer timer = new Timer();
    GradleBuild build = controller.getBuildModel();
    Map<String, AndroidProject> result = new TreeMap<String, AndroidProject>();
    for (BasicGradleProject project : build.getProjects()) {
        AndroidProject androidProject = controller.findModel(project, AndroidProject.class);
        result.put(project.getPath(), androidProject);
    }
    timer.stop();
    System.out.println("building models took " + timer.duration());
    // new Inspector().inspectModel(result);
    return result;
}
Also used : BasicGradleProject(org.gradle.tooling.model.gradle.BasicGradleProject) AndroidProject(com.android.builder.model.AndroidProject) TreeMap(java.util.TreeMap) GradleBuild(org.gradle.tooling.model.gradle.GradleBuild)

Example 18 with GradleBuild

use of org.gradle.tooling.model.gradle.GradleBuild in project gradle by gradle.

the class AccessIncludedBuildProjectBuildAction method execute.

public List<String> execute(BuildController controller) {
    List<String> model = new ArrayList<String>();
    for (GradleBuild included : controller.getBuildModel().getIncludedBuilds()) {
        EclipseProject project = controller.getModel(included.getRootProject(), EclipseProject.class);
        model.add(project.getName());
    }
    return model;
}
Also used : EclipseProject(org.gradle.tooling.model.eclipse.EclipseProject) ArrayList(java.util.ArrayList) GradleBuild(org.gradle.tooling.model.gradle.GradleBuild)

Example 19 with GradleBuild

use of org.gradle.tooling.model.gradle.GradleBuild in project gradle by gradle.

the class ActionRunsMultipleLevelsOfNestedActions method execute.

@Override
public List<Models> execute(BuildController controller) {
    GradleBuild buildModel = controller.getBuildModel();
    List<GetModelViaNestedAction> projectActions = new ArrayList<GetModelViaNestedAction>();
    for (BasicGradleProject project : buildModel.getProjects()) {
        projectActions.add(new GetModelViaNestedAction(project));
    }
    return controller.run(projectActions);
}
Also used : ArrayList(java.util.ArrayList) BasicGradleProject(org.gradle.tooling.model.gradle.BasicGradleProject) GradleBuild(org.gradle.tooling.model.gradle.GradleBuild)

Example 20 with GradleBuild

use of org.gradle.tooling.model.gradle.GradleBuild in project gradle by gradle.

the class FetchIncludedGradleProjects method execute.

@Override
public List<GradleProject> execute(BuildController controller) {
    List<GradleProject> projects = new ArrayList<GradleProject>();
    GradleBuild build = controller.getBuildModel();
    for (GradleBuild includedBuild : build.getIncludedBuilds()) {
        projects.add(controller.getModel(includedBuild, GradleProject.class));
    }
    return projects;
}
Also used : ArrayList(java.util.ArrayList) GradleProject(org.gradle.tooling.model.GradleProject) GradleBuild(org.gradle.tooling.model.gradle.GradleBuild)

Aggregations

GradleBuild (org.gradle.tooling.model.gradle.GradleBuild)22 ArrayList (java.util.ArrayList)15 BasicGradleProject (org.gradle.tooling.model.gradle.BasicGradleProject)8 EclipseProject (org.gradle.tooling.model.eclipse.EclipseProject)4 SomeToolingModel (org.gradle.configurationcache.fixtures.SomeToolingModel)3 BuildEnvironment (org.gradle.tooling.model.build.BuildEnvironment)3 NotNull (org.jetbrains.annotations.NotNull)3 File (java.io.File)2 IOException (java.io.IOException)2 GradleProject (org.gradle.tooling.model.GradleProject)2 AndroidProject (com.android.builder.model.AndroidProject)1 TaskData (com.intellij.openapi.externalSystem.model.task.TaskData)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 CustomModel (org.gradle.integtests.tooling.r16.CustomModel)1 GradleTask (org.gradle.tooling.model.GradleTask)1 CppProject (org.gradle.tooling.model.cpp.CppProject)1 BuildInvocations (org.gradle.tooling.model.gradle.BuildInvocations)1 BasicIdeaProject (org.gradle.tooling.model.idea.BasicIdeaProject)1 IdeaModule (org.gradle.tooling.model.idea.IdeaModule)1