public void whenReady(final Action<TaskExecutionGraph> action) { graphListeners.add(new TaskExecutionGraphListener() { @Override public void graphPopulated(TaskExecutionGraph graph) { action.execute(graph); } }); }
@Override public void graphPopulated(TaskExecutionGraph graph) { Set<Project> seen = Sets.newHashSet(); for (Task task : graph.getAllTasks()) { if (seen.add(task.getProject())) { ProjectInternal projectInternal = (ProjectInternal) task.getProject(); projectInternal.bindAllModelRules(); } } }
public void graphPopulated(TaskExecutionGraph graph) { for (Task key : actions.keySet()) { if (graph.hasTask(key)) { for (Runnable r : actions.get(key)) { //TODO add 'info' level logging explaining what happens. Similar to how we do it in DeferredConfiguration r.run(); } } } }
private void createLintVitalTask(@NonNull ApkVariantData variantData) { checkState(getExtension().getLintOptions().isCheckReleaseBuilds()); // TODO: re-enable with Jack when possible if (!variantData.getVariantConfiguration().getBuildType().isDebuggable() && !variantData.getVariantConfiguration().getUseJack()) { String variantName = variantData.getVariantConfiguration().getFullName(); String capitalizedVariantName = StringHelper.capitalize(variantName); String taskName = "lintVital" + capitalizedVariantName; final Lint lintReleaseCheck = project.getTasks().create(taskName, Lint.class); // TODO: Make this task depend on lintCompile too (resolve initialization order first) optionalDependsOn(lintReleaseCheck, variantData.javacTask); lintReleaseCheck.setLintOptions(getExtension().getLintOptions()); lintReleaseCheck.setSdkHome(sdkHandler.getSdkFolder()); lintReleaseCheck.setVariantName(variantName); lintReleaseCheck.setToolingRegistry(toolingRegistry); lintReleaseCheck.setFatalOnly(true); lintReleaseCheck.setDescription( "Runs lint on just the fatal issues in the " + capitalizedVariantName + " build."); //variantData.assembleVariantTask.dependsOn lintReleaseCheck // If lint is being run, we do not need to run lint vital. // TODO: Find a better way to do this. project.getGradle().getTaskGraph().whenReady(new Closure<Void>(this, this) { public void doCall(TaskExecutionGraph taskGraph) { if (taskGraph.hasTask(LINT)) { lintReleaseCheck.setEnabled(false); } } }); } }
public void graphPopulated(TaskExecutionGraph graph) { List<Task> planned = new ArrayList<Task>(graph.getAllTasks()); graph.addTaskExecutionListener(new TaskListenerImpl(planned, executedTasks, skippedTasks)); }
public void graphPopulated(TaskExecutionGraph taskExecutionGraph) { List<Task> taskList = taskExecutionGraph.getAllTasks(); this.totalTasksToExecute = taskList.size(); client.sendMessage(ProtocolConstants.NUMBER_OF_TASKS_TO_EXECUTE, null, new Integer(taskList.size())); }
public void graphPopulated(TaskExecutionGraph graph) { logger.info("Tasks to be executed: {}", graph.getAllTasks()); }
public void graphPopulated(TaskExecutionGraph graph) { if (gradle != null && graph == gradle.getTaskGraph()) { logger.graphPopulated(graph.getAllTasks().size()); } }
public void graphPopulated(TaskExecutionGraph graph) { logger.info(String.format("Tasks to be executed: %s", graph.getAllTasks())); }
@SuppressWarnings("rawtypes") void createTasks(Project project) { Task rootCheckTask = project.task(EXTENSION + CHECK); rootCheckTask.setGroup(TASK_GROUP); rootCheckTask.setDescription(CHECK_DESCRIPTION); Task rootApplyTask = project.task(EXTENSION + APPLY); rootApplyTask.setGroup(TASK_GROUP); rootApplyTask.setDescription(APPLY_DESCRIPTION); spotlessExtension.formats.forEach((key, value) -> { // create the task that does the work String taskName = EXTENSION + capitalize(key); SpotlessTask spotlessTask = project.getTasks().create(taskName, SpotlessTask.class); value.setupTask(spotlessTask); // create the check and apply control tasks Task checkTask = project.getTasks().create(taskName + CHECK); Task applyTask = project.getTasks().create(taskName + APPLY); // the root tasks depend on them rootCheckTask.dependsOn(checkTask); rootApplyTask.dependsOn(applyTask); // and they depend on the work task checkTask.dependsOn(spotlessTask); applyTask.dependsOn(spotlessTask); // when the task graph is ready, we'll configure the spotlessTask appropriately project.getGradle().getTaskGraph().whenReady(new Closure(null) { private static final long serialVersionUID = 1L; // called by gradle @SuppressFBWarnings("UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS") public Object doCall(TaskExecutionGraph graph) { if (graph.hasTask(checkTask)) { spotlessTask.setCheck(); } if (graph.hasTask(applyTask)) { spotlessTask.setApply(); } return Closure.DONE; } }); }); // Add our check task as a dependency on the global check task // getTasks() returns a "live" collection, so this works even if the // task doesn't exist at the time this call is made if (spotlessExtension.enforceCheck) { project.getTasks() .matching(task -> task.getName().equals(JavaBasePlugin.CHECK_TASK_NAME)) .all(task -> task.dependsOn(rootCheckTask)); } // clear spotless' cache when the user does a clean, but only after any spotless tasks Task clean = project.getTasks().getByName(BasePlugin.CLEAN_TASK_NAME); clean.doLast(unused -> SpotlessCache.clear()); project.getTasks() .withType(SpotlessTask.class) .all(task -> task.mustRunAfter(clean)); }
/** * Returns the {@link TaskExecutionGraph} for this build. * * @return The task graph. Never returns null. */ TaskExecutionGraph getTaskGraph();