Search in sources :

Example 1 with CustomModel

use of org.gradle.integtests.tooling.r16.CustomModel in project gradle by gradle.

the class UseOtherTypesToFetchProjectModel method execute.

public Map<String, CustomModel> execute(BuildController controller) {
    // Use an IdeaModule to reference a project
    IdeaProject ideaProject = controller.getModel(IdeaProject.class);
    for (IdeaModule ideaModule : ideaProject.getModules()) {
        visit(ideaModule, controller, new HashMap<String, CustomModel>());
    }
    // Use an EclipseProject to reference a project
    EclipseProject eclipseProject = controller.getModel(EclipseProject.class);
    visit(eclipseProject, controller, new HashMap<String, CustomModel>());
    // Use a GradleProject to reference a project
    GradleProject rootProject = controller.getModel(GradleProject.class);
    Map<String, CustomModel> projects = new HashMap<String, CustomModel>();
    visit(rootProject, controller, projects);
    return projects;
}
Also used : EclipseProject(org.gradle.tooling.model.eclipse.EclipseProject) IdeaProject(org.gradle.tooling.model.idea.IdeaProject) IdeaModule(org.gradle.tooling.model.idea.IdeaModule) HashMap(java.util.HashMap) GradleProject(org.gradle.tooling.model.GradleProject) CustomModel(org.gradle.integtests.tooling.r16.CustomModel)

Example 2 with CustomModel

use of org.gradle.integtests.tooling.r16.CustomModel in project gradle by gradle.

the class UseGradleBuildToFetchProjectModel method execute.

public Map<String, CustomModel> execute(BuildController controller) {
    GradleBuild gradleBuild = controller.getBuildModel();
    Map<String, CustomModel> projects = new HashMap<String, CustomModel>();
    for (BasicGradleProject project : gradleBuild.getProjects()) {
        projects.put(project.getName(), controller.getModel(project, CustomModel.class));
    }
    return projects;
}
Also used : HashMap(java.util.HashMap) BasicGradleProject(org.gradle.tooling.model.gradle.BasicGradleProject) CustomModel(org.gradle.integtests.tooling.r16.CustomModel) GradleBuild(org.gradle.tooling.model.gradle.GradleBuild)

Example 3 with CustomModel

use of org.gradle.integtests.tooling.r16.CustomModel in project gradle by gradle.

the class ComplexCustomModelBuildingAction method execute.

@Override
public Map<String, CustomModel> execute(BuildController controller) {
    Map<String, CustomModel> result = new HashMap<String, CustomModel>();
    for (BasicGradleProject project : controller.getBuildModel().getProjects()) {
        result.put(project.getPath(), controller.getModel(project, CustomModel.class));
    }
    CustomModel rootProjectModel = controller.getModel(controller.getBuildModel().getRootProject(), CustomModel.class);
    for (CustomModel customModel : result.values()) {
        assert customModel.getThing() == rootProjectModel.getThing();
    }
    return result;
}
Also used : HashMap(java.util.HashMap) BasicGradleProject(org.gradle.tooling.model.gradle.BasicGradleProject) CustomModel(org.gradle.integtests.tooling.r16.CustomModel)

Example 4 with CustomModel

use of org.gradle.integtests.tooling.r16.CustomModel in project gradle by gradle.

the class CustomModelBuildingAction method execute.

@Override
public CustomModel execute(BuildController controller) {
    CustomModel model1 = controller.getModel(CustomModel.class);
    CustomModel model2 = controller.getModel(CustomModel.class);
    assert model1.getThing() == model2.getThing();
    return model1;
}
Also used : CustomModel(org.gradle.integtests.tooling.r16.CustomModel)

Aggregations

CustomModel (org.gradle.integtests.tooling.r16.CustomModel)4 HashMap (java.util.HashMap)3 BasicGradleProject (org.gradle.tooling.model.gradle.BasicGradleProject)2 GradleProject (org.gradle.tooling.model.GradleProject)1 EclipseProject (org.gradle.tooling.model.eclipse.EclipseProject)1 GradleBuild (org.gradle.tooling.model.gradle.GradleBuild)1 IdeaModule (org.gradle.tooling.model.idea.IdeaModule)1 IdeaProject (org.gradle.tooling.model.idea.IdeaProject)1