Java Code Examples for org.gradle.api.Task#getName()

The following examples show how to use org.gradle.api.Task#getName() . 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: MtlTaskInjector.java    From atlas with Apache License 2.0 6 votes vote down vote up
protected List<Task> findTask(Class<Task> clazz, String variantName) {
    Task[] androidTasks = project.getTasks().withType(clazz).toArray(new Task[0]);
    List<Task> taskList = new ArrayList();
    for (Task task : androidTasks) {
        if (task.getName().endsWith("TestJavaWithJavac")){
            continue;
        }
        if (variantName.contains("-")){
            variantName = variantName.replace("-","");
        }
        if (task instanceof DefaultAndroidTask) {

            if (variantName.toLowerCase().equals(((DefaultAndroidTask)task).getVariantName().toLowerCase())) {
                taskList.add(task);
            }
        } else {
            String name = task.getName();
            if (name.toLowerCase().contains(variantName.toLowerCase())) {
                taskList.add(task);
            }
        }
    }
    return taskList;
}
 
Example 2
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 3
Source File: TaskQueryHelper.java    From atlas with Apache License 2.0 6 votes vote down vote up
public static <T extends Task> List<T> findTask(Project project, Class<T> clazz, BaseVariantData vod) {

        Task[] androidTasks = project.getTasks().withType(clazz).toArray(new Task[0]);

        String variantName = vod.getName();

        List<Task> taskList = new ArrayList();
        for (Task task : androidTasks) {
            if (task instanceof DefaultAndroidTask) {
                if (variantName.equals(((DefaultAndroidTask)task).getVariantName())) {
                    taskList.add(task);
                }
            } else {

                String name = task.getName();
                if (name.toLowerCase().contains(variantName)) {
                    taskList.add(task);
                }
            }

        }
        return (List<T>)taskList;
    }
 
Example 4
Source File: ProjectConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds the tasks from the project to the GradleProject.
 *
 * @param project the source parent project. Where we get the sub projects from.
 * @param projectView the destination of the tasks from project.
 */
private void addTasks(Project project, ProjectView projectView) {
    List<String> defaultTasks = project.getDefaultTasks();
    for (Task task : project.getTasks()) {
        String taskName = task.getName();

        boolean isDefault = defaultTasks.contains(taskName);

        projectView.createTask(taskName, task.getDescription(), isDefault);
    }
}
 
Example 5
Source File: ProjectDependencies2TaskResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(ProjectInternal project) {
    for (Project dependsOnProject : project.getDependsOnProjects()) {
        logger.debug("Checking task dependencies for project: {} dependsOn: {}", project, dependsOnProject);
        for (Task task : project.getTasks()) {
            String taskName = task.getName();
            Task dependentTask = dependsOnProject.getTasks().findByName(taskName);
            if (dependentTask != null) {
                logger.debug("Setting task dependencies for task: {}", taskName);
                task.dependsOn(dependentTask);
            }
        }
    }
}
 
Example 6
Source File: ProjectConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds the tasks from the project to the GradleProject.
 *
 * @param project the source parent project. Where we get the sub projects from.
 * @param projectView the destination of the tasks from project.
 */
private void addTasks(Project project, ProjectView projectView) {
    List<String> defaultTasks = project.getDefaultTasks();
    for (Task task : project.getTasks()) {
        String taskName = task.getName();

        boolean isDefault = defaultTasks.contains(taskName);

        projectView.createTask(taskName, task.getDescription(), isDefault);
    }
}
 
Example 7
Source File: ProjectConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds the tasks from the project to the GradleProject.
 *
 * @param project the source parent project. Where we get the sub projects from.
 * @param projectView the destination of the tasks from project.
 */
private void addTasks(Project project, ProjectView projectView) {
    List<String> defaultTasks = project.getDefaultTasks();
    for (Task task : project.getTasks()) {
        String taskName = task.getName();

        boolean isDefault = defaultTasks.contains(taskName);

        projectView.createTask(taskName, task.getDescription(), isDefault);
    }
}
 
Example 8
Source File: ProjectConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds the tasks from the project to the GradleProject.
 *
 * @param project the source parent project. Where we get the sub projects from.
 * @param projectView the destination of the tasks from project.
 */
private void addTasks(Project project, ProjectView projectView) {
    List<String> defaultTasks = project.getDefaultTasks();
    for (Task task : project.getTasks()) {
        String taskName = task.getName();

        boolean isDefault = defaultTasks.contains(taskName);

        projectView.createTask(taskName, task.getDescription(), isDefault);
    }
}
 
Example 9
Source File: ProjectDependencies2TaskResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(ProjectInternal project) {
    for (Project dependsOnProject : project.getDependsOnProjects()) {
        logger.debug("Checking task dependencies for project: {} dependsOn: {}", project, dependsOnProject);
        for (Task task : project.getTasks()) {
            String taskName = task.getName();
            Task dependentTask = dependsOnProject.getTasks().findByName(taskName);
            if (dependentTask != null) {
                logger.debug("Setting task dependencies for task: {}", taskName);
                task.dependsOn(dependentTask);
            }
        }
    }
}
 
Example 10
Source File: ExecuteGradleCommandClientProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void beforeExecute(Task task) {
    String currentTaskName = task.getProject().getName() + ":" + task.getName();
    client.sendMessage(ProtocolConstants.TASK_STARTED_TYPE, currentTaskName, new Float(percentComplete));
}
 
Example 11
Source File: ExecuteGradleCommandClientProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void afterExecute(Task task, TaskState state) {
    totalTasksExecuted++;
    percentComplete = (totalTasksExecuted / totalTasksToExecute) * 100;
    String currentTaskName = task.getProject().getName() + ":" + task.getName();
    client.sendMessage(ProtocolConstants.TASK_COMPLETE_TYPE, currentTaskName, new Float(percentComplete));
}
 
Example 12
Source File: ExecuteGradleCommandClientProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void afterExecute(Task task, TaskState state) {
    totalTasksExecuted++;
    percentComplete = (totalTasksExecuted / totalTasksToExecute) * 100;
    String currentTaskName = task.getProject().getName() + ":" + task.getName();
    client.sendMessage(ProtocolConstants.TASK_COMPLETE_TYPE, currentTaskName, new Float(percentComplete));
}
 
Example 13
Source File: ExecuteGradleCommandClientProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void beforeExecute(Task task) {
    String currentTaskName = task.getProject().getName() + ":" + task.getName();
    client.sendMessage(ProtocolConstants.TASK_STARTED_TYPE, currentTaskName, new Float(percentComplete));
}
 
Example 14
Source File: ExecuteGradleCommandClientProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void afterExecute(Task task, TaskState state) {
    totalTasksExecuted++;
    percentComplete = (totalTasksExecuted / totalTasksToExecute) * 100;
    String currentTaskName = task.getProject().getName() + ":" + task.getName();
    client.sendMessage(ProtocolConstants.TASK_COMPLETE_TYPE, currentTaskName, new Float(percentComplete));
}
 
Example 15
Source File: ExecuteGradleCommandClientProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void beforeExecute(Task task) {
    String currentTaskName = task.getProject().getName() + ":" + task.getName();
    client.sendMessage(ProtocolConstants.TASK_STARTED_TYPE, currentTaskName, new Float(percentComplete));
}
 
Example 16
Source File: ExecuteGradleCommandClientProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void afterExecute(Task task, TaskState state) {
    totalTasksExecuted++;
    percentComplete = (totalTasksExecuted / totalTasksToExecute) * 100;
    String currentTaskName = task.getProject().getName() + ":" + task.getName();
    client.sendMessage(ProtocolConstants.TASK_COMPLETE_TYPE, currentTaskName, new Float(percentComplete));
}
 
Example 17
Source File: ExecuteGradleCommandClientProtocol.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void beforeExecute(Task task) {
    String currentTaskName = task.getProject().getName() + ":" + task.getName();
    client.sendMessage(ProtocolConstants.TASK_STARTED_TYPE, currentTaskName, new Float(percentComplete));
}