@Override public Rule addRule(final String description, final Action<String> ruleAction) { return addRule(new Rule() { public String getDescription() { return description; } public void apply(String taskName) { ruleAction.execute(taskName); } @Override public String toString() { return "Rule: " + description; } }); }
/** * Writes a rule for the current project. * * @param rule The rule */ public void addRule(Rule rule) { if (!currentProjectHasRules) { addSubheading("Rules"); } getTextOutput().println(GUtil.elvis(rule.getDescription(), "")); currentProjectHasRules = true; }
@Override public void generate(Project project) throws IOException { renderer.showDetail(isDetail()); renderer.addDefaultTasks(project.getDefaultTasks()); AggregateMultiProjectTaskReportModel aggregateModel = new AggregateMultiProjectTaskReportModel(!isDetail(), isDetail()); TaskDetailsFactory taskDetailsFactory = new TaskDetailsFactory(project); SingleProjectTaskReportModel projectTaskModel = new SingleProjectTaskReportModel(taskDetailsFactory); projectTaskModel.build(getProjectTaskLister().listProjectTasks(project)); aggregateModel.add(projectTaskModel); for (Project subproject : project.getSubprojects()) { SingleProjectTaskReportModel subprojectTaskModel = new SingleProjectTaskReportModel(taskDetailsFactory); subprojectTaskModel.build(getProjectTaskLister().listProjectTasks(subproject)); aggregateModel.add(subprojectTaskModel); } aggregateModel.build(); DefaultGroupTaskReportModel model = new DefaultGroupTaskReportModel(); model.build(aggregateModel); for (String group : model.getGroups()) { renderer.startTaskGroup(group); for (TaskDetails task : model.getTasksForGroup(group)) { renderer.addTask(task); } } renderer.completeTasks(); for (Rule rule : project.getTasks().getRules()) { renderer.addRule(rule); } }
private void applyRules(String name) { if (applyingRulesFor.contains(name)) { return; } applyingRulesFor.add(name); try { for (Rule rule : rules) { rule.apply(name); } } finally { applyingRulesFor.remove(name); } }
public void generate(Project project) throws IOException { renderer.showDetail(isDetail()); renderer.addDefaultTasks(project.getDefaultTasks()); AggregateMultiProjectTaskReportModel aggregateModel = new AggregateMultiProjectTaskReportModel(!isDetail()); TaskDetailsFactory taskDetailsFactory = new TaskDetailsFactory(project); SingleProjectTaskReportModel projectTaskModel = new SingleProjectTaskReportModel(taskDetailsFactory); projectTaskModel.build(getProjectTaskLister().listProjectTasks(project)); aggregateModel.add(projectTaskModel); for (Project subproject : project.getSubprojects()) { SingleProjectTaskReportModel subprojectTaskModel = new SingleProjectTaskReportModel(taskDetailsFactory); subprojectTaskModel.build(getProjectTaskLister().listProjectTasks(subproject)); aggregateModel.add(subprojectTaskModel); } aggregateModel.build(); DefaultGroupTaskReportModel model = new DefaultGroupTaskReportModel(); model.build(aggregateModel); for (String group : model.getGroups()) { renderer.startTaskGroup(group); for (TaskDetails task : model.getTasksForGroup(group)) { renderer.addTask(task); for (TaskDetails child : task.getChildren()) { renderer.addChildTask(child); } } } renderer.completeTasks(); for (Rule rule : project.getTasks().getRules()) { renderer.addRule(rule); } }
@Override @Internal List<Rule> getRules();
public Rule addRule(Rule rule) { rules.add(rule); return rule; }
public Rule addRule(final String description, final Closure ruleAction) { return addRule(description, ClosureBackedAction.<String>of(ruleAction)); }
public List<Rule> getRules() { return Collections.unmodifiableList(rules); }
public Rule addRule(String description, Closure ruleAction) { return delegate.addRule(description, ruleAction); }
@Override public Rule addRule(String description, Action<String> ruleAction) { return delegate.addRule(description, ruleAction); }
public Rule addRule(Rule rule) { return delegate.addRule(rule); }
public List<Rule> getRules() { return delegate.getRules(); }
public void generate(Project project) throws IOException { renderer.showDetail(isDetail()); renderer.addDefaultTasks(project.getDefaultTasks()); AggregateMultiProjectTaskReportModel aggregateModel = new AggregateMultiProjectTaskReportModel(!isDetail()); TaskDetailsFactory taskDetailsFactory = new TaskDetailsFactory(project); SingleProjectTaskReportModel projectTaskModel = new SingleProjectTaskReportModel(taskDetailsFactory); ProjectInternal projectInternal = (ProjectInternal) project; TaskContainerInternal tasks = projectInternal.getTasks(); tasks.actualize(); projectTaskModel.build(Sets.union(tasks, projectInternal.getImplicitTasks())); aggregateModel.add(projectTaskModel); for (Project subproject : project.getSubprojects()) { SingleProjectTaskReportModel subprojectTaskModel = new SingleProjectTaskReportModel(taskDetailsFactory); ProjectInternal subprojectInternal = (ProjectInternal) subproject; TaskContainerInternal subprojectTasks = subprojectInternal.getTasks(); subprojectTasks.actualize(); subprojectTaskModel.build(subprojectTasks); aggregateModel.add(subprojectTaskModel); } aggregateModel.build(); DefaultGroupTaskReportModel model = new DefaultGroupTaskReportModel(); model.build(aggregateModel); for (String group : model.getGroups()) { renderer.startTaskGroup(group); for (TaskDetails task : model.getTasksForGroup(group)) { renderer.addTask(task); for (TaskDetails child : task.getChildren()) { renderer.addChildTask(child); } } } renderer.completeTasks(); for (Rule rule : project.getTasks().getRules()) { renderer.addRule(rule); } }