org.gradle.api.execution.TaskExecutionGraph Java Examples

The following examples show how to use org.gradle.api.execution.TaskExecutionGraph. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CpdPlugin.java    From gradle-cpd-plugin with Apache License 2.0 6 votes vote down vote up
private void logWarningIfCheckTaskOnTaskGraph(Project project, TaskExecutionGraph graph) {
    if (logger.isWarnEnabled()) {
        Optional<Task> lastCheckTask = graph.getAllTasks().stream().sorted(reverseOrder())
                .filter(t -> t.getName().endsWith(LifecycleBasePlugin.CHECK_TASK_NAME)).findFirst();
        if (lastCheckTask.isPresent()) { // it is possible to just execute a task before "check", e.g. "compileJava"
            Task task = lastCheckTask.get();
            String message = "\n" +
                    "WARNING: Due to the absence of '" + LifecycleBasePlugin.class.getSimpleName() +
                    "' on " + project + " the task ':" + TASK_NAME_CPD_CHECK +
                    "' could not be added to task graph. Therefore CPD will not be executed. To prevent this, manually add a task dependency of ':" +
                    TASK_NAME_CPD_CHECK + "' to a '" + LifecycleBasePlugin.CHECK_TASK_NAME +
                    "' task of a subproject.\n" +
                    "1) Directly to " + task.getProject() + ":\n" +
                    "    " + task.getName() + ".dependsOn(':" + TASK_NAME_CPD_CHECK + "')\n" +
                    "2) Indirectly, e.g. via " + project + ":\n" +
                    "    project('" + task.getProject().getPath() + "') {\n" +
                    "        plugins.withType(LifecycleBasePlugin) { // <- just required if 'java' plugin is applied within subproject\n" +
                    "            " + task.getName() + ".dependsOn(" + TASK_NAME_CPD_CHECK + ")\n" +
                    "        }\n" +
                    "    }\n";
            logger.warn(message);
        }
    }
}
 
Example #2
Source File: BasePlugin.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
protected void configureProject() {
        extraModelInfo = new ExtraModelInfo(project, isLibrary());
        sdkHandler = new SdkHandler(project, getLogger());
        androidBuilder = new AndroidBuilder(
                project == project.getRootProject() ? project.getName() : project.getPath(),
                "Android Gradle Java N-IDE",
                new GradleProcessExecutor(project),
                new GradleJavaProcessExecutor(project),
                extraModelInfo,
                getLogger(),
                isVerbose());

//        project.getPlugins().apply(JavaBasePlugin.class);

        // call back on execution. This is called after the whole build is done (not
        // after the current project is done).
        // This is will be called for each (android) projects though, so this should support
        // being called 2+ times.
        project.getGradle().getTaskGraph().addTaskExecutionGraphListener(
                new TaskExecutionGraphListener() {
                    @Override
                    public void graphPopulated(TaskExecutionGraph taskGraph) {
                        for (Task task : taskGraph.getAllTasks()) {
                            if (task instanceof PreDex) {
                                PreDexCache.getCache().load(
                                        new File(project.getRootProject().getBuildDir(),
                                                FD_INTERMEDIATES + "/dex-cache/cache.xml"));
                                break;
                            }
                        }
                    }
                });
    }
 
Example #3
Source File: LazyConfiguration.java    From shipkit with MIT License 5 votes vote down vote up
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();
            }
        }
    }
}
 
Example #4
Source File: TaskManager.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private void createLintVitalTask(@NonNull ApkVariantData variantData) {
    checkState(getExtension().getLintOptions().isCheckReleaseBuilds());
    // TODO: re-enable with Jack when possible
    if (!variantData.getVariantConfiguration().getBuildType().isDebuggable()) {
        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);
                }
            }
        });
    }
}
 
Example #5
Source File: MetricsPlugin.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {

  Metrics metrics = Metrics.filtered(initializeMetrics(project), MetricsPlugin::isTaskPublic);

  TaskExecutionGraph taskGraph = project.getGradle().getTaskGraph();
  taskGraph.addTaskExecutionListener(new MeasuringTaskExecutionListener(metrics, taskGraph));
}
 
Example #6
Source File: SupportPortalDownload.java    From commerce-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void graphPopulated(TaskExecutionGraph graph) {
    List<SupportPortalDownload> downloadTasks = graph.getAllTasks().stream().filter(t -> t instanceof SupportPortalDownload).map(t -> (SupportPortalDownload) t).collect(Collectors.toList());
    if (!downloadTasks.isEmpty()) {
        ssoCredentialsCache = new SSOCredentialsCache();
        downloadTasks.forEach(t -> t.setCredentialsCache(ssoCredentialsCache));
    }
}
 
Example #7
Source File: InProcessGradleExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    List<Task> planned = new ArrayList<Task>(graph.getAllTasks());
    graph.addTaskExecutionListener(new TaskListenerImpl(planned, executedTasks, skippedTasks));
}
 
Example #8
Source File: ExecuteGradleCommandClientProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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()));
}
 
Example #9
Source File: BuildLogger.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    logger.info(String.format("Tasks to be executed: %s", graph.getAllTasks()));
}
 
Example #10
Source File: BuildProgressFilter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    if (gradle != null && graph == gradle.getTaskGraph()) {
        logger.graphPopulated(graph.getAllTasks().size());
    }
}
 
Example #11
Source File: ExecuteGradleCommandClientProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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()));
}
 
Example #12
Source File: InProcessGradleExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    List<Task> planned = new ArrayList<Task>(graph.getAllTasks());
    graph.addTaskExecutionListener(new TaskListenerImpl(planned, executedTasks, skippedTasks));
}
 
Example #13
Source File: BuildLogger.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    logger.info(String.format("Tasks to be executed: %s", graph.getAllTasks()));
}
 
Example #14
Source File: BuildProgressFilter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    if (gradle != null && graph == gradle.getTaskGraph()) {
        logger.graphPopulated(graph.getAllTasks().size());
    }
}
 
Example #15
Source File: ExecuteGradleCommandClientProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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()));
}
 
Example #16
Source File: ExecuteGradleCommandClientProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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()));
}
 
Example #17
Source File: BuildProgressFilter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    if (gradle != null && graph == gradle.getTaskGraph()) {
        logger.graphPopulated(graph.getAllTasks().size());
    }
}
 
Example #18
Source File: InProcessGradleExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    List<Task> planned = new ArrayList<Task>(graph.getAllTasks());
    graph.addTaskExecutionListener(new TaskListenerImpl(planned, executedTasks, skippedTasks));
}
 
Example #19
Source File: MeasuringTaskExecutionListener.java    From firebase-android-sdk with Apache License 2.0 4 votes vote down vote up
MeasuringTaskExecutionListener(Metrics metrics, TaskExecutionGraph taskGraph) {
  this.metrics = metrics;
  this.taskGraph = taskGraph;
}
 
Example #20
Source File: BuildLogger.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    logger.info(String.format("Tasks to be executed: %s", graph.getAllTasks()));
}
 
Example #21
Source File: InProcessGradleExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    List<Task> planned = new ArrayList<Task>(graph.getAllTasks());
    graph.addTaskExecutionListener(new TaskListenerImpl(planned, executedTasks, skippedTasks));
}
 
Example #22
Source File: BuildLogger.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    logger.info(String.format("Tasks to be executed: %s", graph.getAllTasks()));
}
 
Example #23
Source File: BuildProgressFilter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void graphPopulated(TaskExecutionGraph graph) {
    if (gradle != null && graph == gradle.getTaskGraph()) {
        logger.graphPopulated(graph.getAllTasks().size());
    }
}
 
Example #24
Source File: Gradle.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns the {@link TaskExecutionGraph} for this build.
 *
 * @return The task graph. Never returns null.
 */
TaskExecutionGraph getTaskGraph();
 
Example #25
Source File: Gradle.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns the {@link TaskExecutionGraph} for this build.
 *
 * @return The task graph. Never returns null.
 */
TaskExecutionGraph getTaskGraph();
 
Example #26
Source File: Gradle.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns the {@link TaskExecutionGraph} for this build.
 *
 * @return The task graph. Never returns null.
 */
TaskExecutionGraph getTaskGraph();
 
Example #27
Source File: Gradle.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Returns the {@link TaskExecutionGraph} for this build.
 *
 * @return The task graph. Never returns null.
 */
TaskExecutionGraph getTaskGraph();