private DefaultGradleProject<LaunchableGradleTask> buildHierarchy(Project project) {
    List<DefaultGradleProject<LaunchableGradleTask>> children =
        new ArrayList<DefaultGradleProject<LaunchableGradleTask>>();
    for (Project child : project.getChildProjects().values()) {
      children.add(buildHierarchy(child));
    }

    DefaultGradleProject<LaunchableGradleTask> gradleProject =
        new DefaultGradleProject<LaunchableGradleTask>()
            .setPath(project.getPath())
            .setName(project.getName())
            .setDescription(project.getDescription())
            .setBuildDirectory(project.getBuildDir())
            .setProjectDirectory(project.getProjectDir())
            .setChildren(children);

    gradleProject.getBuildScript().setSourceFile(project.getBuildFile());
    gradleProject.setTasks(tasks(gradleProject, (TaskContainerInternal) project.getTasks()));

    for (DefaultGradleProject child : children) {
      child.setParent(gradleProject);
    }

    return gradleProject;
  }
예제 #2
0
  private void findTasks(
      Project project,
      Map<String, LaunchableGradleTaskSelector> taskSelectors,
      Collection<String> visibleTasks) {
    for (Project child : project.getChildProjects().values()) {
      findTasks(child, taskSelectors, visibleTasks);
    }

    for (Task task : taskLister.listProjectTasks(project)) {
      // in the map, store a minimally populated LaunchableGradleTaskSelector that contains just the
      // description and the path
      // replace the LaunchableGradleTaskSelector stored in the map iff we come across a task with
      // the same name whose path has a smaller ordering
      // this way, for each task selector, its description will be the one from the selected task
      // with the 'smallest' path
      if (!taskSelectors.containsKey(task.getName())) {
        LaunchableGradleTaskSelector taskSelector =
            new LaunchableGradleTaskSelector()
                .setDescription(task.getDescription())
                .setPath(task.getPath());
        taskSelectors.put(task.getName(), taskSelector);
      } else {
        LaunchableGradleTaskSelector taskSelector = taskSelectors.get(task.getName());
        if (hasPathWithLowerOrdering(task, taskSelector)) {
          taskSelector.setDescription(task.getDescription()).setPath(task.getPath());
        }
      }

      // visible tasks are specified as those that have a non-empty group
      if (PublicTaskSpecification.INSTANCE.isSatisfiedBy(task)) {
        visibleTasks.add(task.getName());
      }
    }
  }
 private DefaultProjectOutcomes buildProjectOutput(Project project, ProjectOutcomes parent) {
   DefaultProjectOutcomes projectOutput =
       new DefaultProjectOutcomes(
           project.getName(),
           project.getPath(),
           project.getDescription(),
           project.getProjectDir(),
           getFileOutcomes(project),
           parent);
   for (Project child : project.getChildProjects().values()) {
     projectOutput.addChild(buildProjectOutput(child, projectOutput));
   }
   return projectOutput;
 }
 private void setProjectProperties(Project project) {
   addPropertiesToProject(project);
   for (Project childProject : project.getChildProjects().values()) {
     setProjectProperties(childProject);
   }
 }