Search in sources :

Example 1 with BasicGradleProject

use of org.gradle.tooling.model.gradle.BasicGradleProject 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 2 with BasicGradleProject

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

the class FetchProjectModelsBuildAction method execute.

public List<Object> execute(BuildController controller) {
    List<Object> models = new ArrayList<Object>();
    for (BasicGradleProject project : controller.getBuildModel().getProjects()) {
        Object model = controller.getModel(project, modelType);
        models.add(model);
    }
    return models;
}
Also used : ArrayList(java.util.ArrayList) BasicGradleProject(org.gradle.tooling.model.gradle.BasicGradleProject)

Example 3 with BasicGradleProject

use of org.gradle.tooling.model.gradle.BasicGradleProject in project grails-core by grails.

the class FetchAllTaskSelectorsBuildAction method execute.

public AllTasksModel execute(BuildController controller) {
    AllTasksModel model = new AllTasksModel();
    Map<String, Set<String>> allTaskSelectors = new LinkedHashMap<String, Set<String>>();
    model.allTaskSelectors = allTaskSelectors;
    Map<String, Set<String>> allTasks = new LinkedHashMap<String, Set<String>>();
    model.allTasks = allTasks;
    Map<String, String> projectPaths = new HashMap<String, String>();
    model.projectPaths = projectPaths;
    for (BasicGradleProject project : controller.getBuildModel().getProjects()) {
        BuildInvocations entryPointsForProject = controller.getModel(project, BuildInvocations.class);
        Set<String> selectorNames = new LinkedHashSet<String>();
        for (TaskSelector selector : entryPointsForProject.getTaskSelectors()) {
            selectorNames.add(selector.getName());
        }
        allTaskSelectors.put(project.getName(), selectorNames);
        Set<String> taskNames = new LinkedHashSet<String>();
        for (Task task : entryPointsForProject.getTasks()) {
            taskNames.add(task.getName());
        }
        allTasks.put(project.getName(), taskNames);
        projectPaths.put(project.getName(), project.getPath());
        if (project.getProjectDirectory().getAbsolutePath().equals(currentProjectPath)) {
            model.currentProject = project.getName();
        }
    }
    return model;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Task(org.gradle.tooling.model.Task) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BasicGradleProject(org.gradle.tooling.model.gradle.BasicGradleProject) BuildInvocations(org.gradle.tooling.model.gradle.BuildInvocations) TaskSelector(org.gradle.tooling.model.TaskSelector) LinkedHashMap(java.util.LinkedHashMap) AllTasksModel(org.grails.cli.gradle.FetchAllTaskSelectorsBuildAction.AllTasksModel)

Example 4 with BasicGradleProject

use of org.gradle.tooling.model.gradle.BasicGradleProject 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 5 with BasicGradleProject

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

the class FetchAllTaskSelectorsBuildAction method execute.

public Map<String, Set<String>> execute(BuildController controller) {
    Map<String, Set<String>> model = new HashMap<String, Set<String>>();
    for (BasicGradleProject project : controller.getBuildModel().getProjects()) {
        BuildInvocations entryPointsForProject = controller.getModel(project, BuildInvocations.class);
        Set<String> selectorNames = new HashSet<String>();
        for (TaskSelector selector : entryPointsForProject.getTaskSelectors()) {
            selectorNames.add(selector.getName());
        }
        model.put(project.getName(), selectorNames);
    }
    return model;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) BasicGradleProject(org.gradle.tooling.model.gradle.BasicGradleProject) BuildInvocations(org.gradle.tooling.model.gradle.BuildInvocations) TaskSelector(org.gradle.tooling.model.TaskSelector) HashSet(java.util.HashSet)

Aggregations

BasicGradleProject (org.gradle.tooling.model.gradle.BasicGradleProject)6 HashMap (java.util.HashMap)4 Set (java.util.Set)2 CustomModel (org.gradle.integtests.tooling.r16.CustomModel)2 TaskSelector (org.gradle.tooling.model.TaskSelector)2 BuildInvocations (org.gradle.tooling.model.gradle.BuildInvocations)2 GradleBuild (org.gradle.tooling.model.gradle.GradleBuild)2 AndroidProject (com.android.builder.model.AndroidProject)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 TreeMap (java.util.TreeMap)1 Task (org.gradle.tooling.model.Task)1 AllTasksModel (org.grails.cli.gradle.FetchAllTaskSelectorsBuildAction.AllTasksModel)1