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

The following examples show how to use org.gradle.api.Task#dependsOn() . 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: VisualStudioPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Mutate
@SuppressWarnings("GroovyUnusedDeclaration")
public static void createTasksForVisualStudio(TaskContainer tasks, VisualStudioExtensionInternal visualStudioExtension) {
    for (VisualStudioProject vsProject : visualStudioExtension.getProjects()) {
        vsProject.builtBy(createProjectsFileTask(tasks, vsProject));
        vsProject.builtBy(createFiltersFileTask(tasks, vsProject));
    }

    for (VisualStudioSolution vsSolution : visualStudioExtension.getSolutions()) {
        Task solutionTask = tasks.create(vsSolution.getName() + "VisualStudio");
        solutionTask.setDescription(String.format("Generates the '%s' Visual Studio solution file.", vsSolution.getName()));
        vsSolution.setBuildTask(solutionTask);
        vsSolution.builtBy(createSolutionTask(tasks, vsSolution));

        // Lifecycle task for component
        NativeComponentSpec component = vsSolution.getComponent();
        Task lifecycleTask = tasks.maybeCreate(component.getName() + "VisualStudio");
        lifecycleTask.dependsOn(vsSolution);
        lifecycleTask.setGroup("IDE");
        lifecycleTask.setDescription(String.format("Generates the Visual Studio solution for %s.", component));
    }

    addCleanTask(tasks);
}
 
Example 2
Source File: GeneratorPlugin.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
private void setupRuntimeDependencies(Project project, Task generateTask) {
	GeneratorConfig config = project.getExtensions().getByType(GeneratorConfig.class);
	String runtimeConfiguration = config.getRuntime().getConfiguration();
	if (runtimeConfiguration != null) {
		String runtimeConfigurationFirstUpper =
				Character.toUpperCase(runtimeConfiguration.charAt(0)) + runtimeConfiguration.substring(1);

		// make sure applications is compiled in order to startup and extract meta information
		String processResourcesName = "process" + runtimeConfigurationFirstUpper + "Resources";
		String compileJavaName = "compile" + runtimeConfigurationFirstUpper + "Java";
		TaskContainer tasks = project.getTasks();
		Task processResourceTask = tasks.findByName(processResourcesName);
		Task compileJavaTask = tasks.findByName(compileJavaName);
		if (processResourceTask != null) {
			generateTask.dependsOn(processResourceTask);
		}
		if (compileJavaTask != null) {
			generateTask.dependsOn(compileJavaTask, compileJavaTask);
		}
	}
}
 
Example 3
Source File: CreateVisualStudioTasks.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
public void createTasksForVisualStudio(TaskContainer tasks, VisualStudioExtension visualStudioExtension) {
    for (VisualStudioProject vsProject : visualStudioExtension.getProjects()) {
        vsProject.builtBy(createProjectsFileTask(tasks, vsProject));
        vsProject.builtBy(createFiltersFileTask(tasks, vsProject));
    }

    for (VisualStudioSolution vsSolution : visualStudioExtension.getSolutions()) {
        Task solutionTask = tasks.create(vsSolution.getName() + "VisualStudio");
        solutionTask.setDescription(String.format("Generates the '%s' Visual Studio solution file.", vsSolution.getName()));
        vsSolution.setLifecycleTask(solutionTask);
        vsSolution.builtBy(createSolutionTask(tasks, vsSolution));

        // Lifecycle task for component
        ProjectNativeComponent component = vsSolution.getComponent();
        Task lifecycleTask = tasks.maybeCreate(component.getName() + "VisualStudio");
        lifecycleTask.dependsOn(vsSolution);
        lifecycleTask.setGroup("IDE");
        lifecycleTask.setDescription(String.format("Generates the Visual Studio solution for %s.", component));
    }

    addCleanTask(tasks);
}
 
Example 4
Source File: LanguageBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Mutate
void createLifecycleTaskForBinary(TaskContainer tasks, BinaryContainer binaries) {
    Task assembleTask = tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME);
    for (BinarySpecInternal binary : binaries.withType(BinarySpecInternal.class)) {
        if (!binary.isLegacyBinary()) {
            Task binaryLifecycleTask = tasks.create(binary.getNamingScheme().getLifecycleTaskName());
            binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP);
            binaryLifecycleTask.setDescription(String.format("Assembles %s.", binary));
            binary.setBuildTask(binaryLifecycleTask);

            if (binary.isBuildable()) {
                assembleTask.dependsOn(binary);
            }
        }
    }
}
 
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: AndroidPublishPlugin.java    From shipkit with MIT License 5 votes vote down vote up
public void apply(final Project project) {
    final AndroidPublishConfiguration androidPublishConfiguration = project.getExtensions().create(ANDROID_PUBLISH_EXTENSION, AndroidPublishConfiguration.class);

    final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();

    project.getPlugins().apply(LocalSnapshotPlugin.class);
    Task snapshotTask = project.getTasks().getByName(LocalSnapshotPlugin.SNAPSHOT_TASK);
    snapshotTask.dependsOn(MAVEN_LOCAL_TASK);

    project.getPlugins().apply("maven-publish");

    BintrayExtension bintray = project.getExtensions().getByType(BintrayExtension.class);
    bintray.setPublications(PUBLICATION_NAME);

    project.getPlugins().withId("com.android.library", plugin -> {
        deferredConfiguration(project, () -> {
            GradleDSLHelper.publications(project, publications -> {
                MavenPublication p = publications.create(PUBLICATION_NAME, MavenPublication.class, publication -> {
                    publication.setArtifactId(androidPublishConfiguration.getArtifactId());

                    SoftwareComponent releaseComponent = project.getComponents().findByName("release");
                    if (releaseComponent == null) {
                        throw new GradleException("'release' component not found in project. " +
                            "Make sure you are using Android Gradle Plugin 3.6.0-beta05 or newer.");
                    }
                    publication.from(releaseComponent);
                    PomCustomizer.customizePom(project, conf, publication);
                });
                LOG.info("{} - configured '{}' publication", project.getPath(), p.getArtifactId());
            });
        });

        //so that we flesh out problems with maven publication during the build process
        project.getTasks().getByName("build").dependsOn(MAVEN_LOCAL_TASK);
    });
}
 
Example 7
Source File: SpringJavaFormatPlugin.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private void addSourceTasks(SourceSet sourceSet, Task checkAll, Task formatAll) {
	CheckTask checkTask = addSourceTask(sourceSet, CheckTask.class, CheckTask.NAME, CheckTask.DESCRIPTION);
	checkTask.setReportLocation(
			new File(this.project.getBuildDir(), "reports/format/" + sourceSet.getName() + "/check-format.txt"));
	checkAll.dependsOn(checkTask);
	FormatTask formatSourceSet = addSourceTask(sourceSet, FormatTask.class, FormatTask.NAME,
			FormatTask.DESCRIPTION);
	formatSourceSet.conventionMapping("encoding", () -> "UTF-8");
	formatAll.dependsOn(formatSourceSet);
}
 
Example 8
Source File: BuildConfigurationRule.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(String taskName) {
    if (taskName.startsWith(PREFIX)) {
        String configurationName = StringUtils.uncapitalize(taskName.substring(PREFIX.length()));
        Configuration configuration = configurations.findByName(configurationName);

        if (configuration != null) {
            Task task = tasks.create(taskName);
            task.dependsOn(configuration.getAllArtifacts());
            task.setDescription(String.format("Builds the artifacts belonging to %s.", configuration));
        }
    }
}
 
Example 9
Source File: DependencyManager.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private void setupPrepareLibraryTask(
            @NonNull LibraryDependencyImpl libDependency,
            @NonNull Multimap<LibraryDependency, VariantDependencies> reverseMap) {
        Task task = maybeCreatePrepareLibraryTask(libDependency, project);

        // Use the reverse map to find all the configurations that included this android
        // library so that we can make sure they are built.
        // TODO fix, this is not optimum as we bring in more dependencies than we should.
        Collection<VariantDependencies> configDepList = reverseMap.get(libDependency);
        if (configDepList != null && !configDepList.isEmpty()) {
            for (VariantDependencies configDependencies : configDepList) {
                task.dependsOn(configDependencies.getCompileConfiguration().getBuildDependencies());
            }
        }

        // check if this library is created by a parent (this is based on the
        // output file.
        // TODO Fix this as it's fragile
            /*
            This is a somewhat better way but it doesn't work in some project with
            weird setups...
            Project parentProject = DependenciesImpl.getProject(library.getBundle(), projects)
            if (parentProject != null) {
                String configName = library.getProjectVariant()
                if (configName == null) {
                    configName = "default"
                }

                prepareLibraryTask.dependsOn parentProject.getPath() + ":assemble${configName.capitalize()}"
            }
*/

    }
 
Example 10
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 11
Source File: BuildConfigurationRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(String taskName) {
    if (taskName.startsWith(PREFIX)) {
        String configurationName = StringUtils.uncapitalize(taskName.substring(PREFIX.length()));
        Configuration configuration = configurations.findByName(configurationName);

        if (configuration != null) {
            Task task = tasks.create(taskName);
            task.dependsOn(configuration.getAllArtifacts());
            task.setDescription(String.format("Builds the artifacts belonging to %s.", configuration));
        }
    }
}
 
Example 12
Source File: BuildConfigurationRule.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(String taskName) {
    if (taskName.startsWith(PREFIX)) {
        String configurationName = StringUtils.uncapitalize(taskName.substring(PREFIX.length()));
        Configuration configuration = configurations.findByName(configurationName);

        if (configuration != null) {
            Task task = tasks.create(taskName);
            task.dependsOn(configuration.getAllArtifacts());
            task.setDescription(String.format("Builds the artifacts belonging to %s.", configuration));
        }
    }
}
 
Example 13
Source File: GitOriginPlugin.java    From shipkit with MIT License 5 votes vote down vote up
public void provideOriginRepo(Task t, final Action<String> originRepoName) {
    t.dependsOn(identifyTask);
    identifyTask.doLast(new Action<Task>() {
        public void execute(Task task) {
            originRepoName.execute(identifyTask.getRepository());
        }
    });
}
 
Example 14
Source File: ProjectReportsPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(Project project) {
    project.getPlugins().apply(ReportingBasePlugin.class);
    final ProjectReportsPluginConvention convention = new ProjectReportsPluginConvention(project);
    project.getConvention().getPlugins().put("projectReports", convention);

    TaskReportTask taskReportTask = project.getTasks().create(TASK_REPORT, TaskReportTask.class);
    taskReportTask.setDescription("Generates a report about your tasks.");
    taskReportTask.conventionMapping("outputFile", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getProjectReportDir(), "tasks.txt");
        }
    });
    taskReportTask.conventionMapping("projects", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getProjects();
        }
    });

    PropertyReportTask propertyReportTask = project.getTasks().create(PROPERTY_REPORT, PropertyReportTask.class);
    propertyReportTask.setDescription("Generates a report about your properties.");
    propertyReportTask.conventionMapping("outputFile", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getProjectReportDir(), "properties.txt");
        }
    });
    propertyReportTask.conventionMapping("projects", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getProjects();
        }
    });

    DependencyReportTask dependencyReportTask = project.getTasks().create(DEPENDENCY_REPORT,
            DependencyReportTask.class);
    dependencyReportTask.setDescription("Generates a report about your library dependencies.");
    dependencyReportTask.conventionMapping("outputFile", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getProjectReportDir(), "dependencies.txt");
        }
    });
    dependencyReportTask.conventionMapping("projects", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getProjects();
        }
    });

    HtmlDependencyReportTask htmlDependencyReportTask = project.getTasks().create(HTML_DEPENDENCY_REPORT,
            HtmlDependencyReportTask.class);
    htmlDependencyReportTask.setDescription("Generates an HTML report about your library dependencies.");
    new DslObject(htmlDependencyReportTask.getReports().getHtml()).getConventionMapping().map("destination", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getProjectReportDir(), "dependencies");
                }
            });
    htmlDependencyReportTask.conventionMapping("projects", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getProjects();
        }
    });

    Task projectReportTask = project.getTasks().create(PROJECT_REPORT);
    projectReportTask.dependsOn(TASK_REPORT, PROPERTY_REPORT, DEPENDENCY_REPORT, HTML_DEPENDENCY_REPORT);
    projectReportTask.setDescription("Generates a report about your project.");
    projectReportTask.setGroup("reporting");
}
 
Example 15
Source File: BasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void addAssemble(Project project) {
    Task assembleTask = project.getTasks().create(ASSEMBLE_TASK_NAME);
    assembleTask.setDescription("Assembles the outputs of this project.");
    assembleTask.setGroup(BUILD_GROUP);
    assembleTask.dependsOn(project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION).getAllArtifacts().getBuildDependencies());
}
 
Example 16
Source File: ProjectReportsPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(Project project) {
    project.getPlugins().apply(ReportingBasePlugin.class);
    final ProjectReportsPluginConvention convention = new ProjectReportsPluginConvention(project);
    project.getConvention().getPlugins().put("projectReports", convention);

    TaskReportTask taskReportTask = project.getTasks().create(TASK_REPORT, TaskReportTask.class);
    taskReportTask.setDescription("Generates a report about your tasks.");
    taskReportTask.conventionMapping("outputFile", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getProjectReportDir(), "tasks.txt");
        }
    });
    taskReportTask.conventionMapping("projects", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getProjects();
        }
    });

    PropertyReportTask propertyReportTask = project.getTasks().create(PROPERTY_REPORT, PropertyReportTask.class);
    propertyReportTask.setDescription("Generates a report about your properties.");
    propertyReportTask.conventionMapping("outputFile", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getProjectReportDir(), "properties.txt");
        }
    });
    propertyReportTask.conventionMapping("projects", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getProjects();
        }
    });

    DependencyReportTask dependencyReportTask = project.getTasks().create(DEPENDENCY_REPORT,
            DependencyReportTask.class);
    dependencyReportTask.setDescription("Generates a report about your library dependencies.");
    dependencyReportTask.conventionMapping("outputFile", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(convention.getProjectReportDir(), "dependencies.txt");
        }
    });
    dependencyReportTask.conventionMapping("projects", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getProjects();
        }
    });

    HtmlDependencyReportTask htmlDependencyReportTask = project.getTasks().create(HTML_DEPENDENCY_REPORT,
            HtmlDependencyReportTask.class);
    htmlDependencyReportTask.setDescription("Generates an HTML report about your library dependencies.");
    new DslObject(htmlDependencyReportTask.getReports().getHtml()).getConventionMapping().map("destination", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getProjectReportDir(), "dependencies");
                }
            });
    htmlDependencyReportTask.conventionMapping("projects", new Callable<Object>() {
        public Object call() throws Exception {
            return convention.getProjects();
        }
    });

    Task projectReportTask = project.getTasks().create(PROJECT_REPORT);
    projectReportTask.dependsOn(TASK_REPORT, PROPERTY_REPORT, DEPENDENCY_REPORT, HTML_DEPENDENCY_REPORT);
    projectReportTask.setDescription("Generates a report about your project.");
    projectReportTask.setGroup("reporting");
}
 
Example 17
Source File: AbstractBuildableComponentSpec.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setBuildTask(Task buildTask) {
    this.buildTask = buildTask;
    buildTask.dependsOn(buildTaskDependencies);
}
 
Example 18
Source File: JavaPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * Adds a dependency on tasks with the specified name in other projects.  The other projects are determined from
 * project lib dependencies using the specified configuration name. These may be projects this project depends on or
 * projects that depend on this project based on the useDependOn argument.
 *
 * @param task Task to add dependencies to
 * @param useDependedOn if true, add tasks from projects this project depends on, otherwise use projects that depend
 * on this one.
 * @param otherProjectTaskName name of task in other projects
 * @param configurationName name of configuration to use to find the other projects
 */
private void addDependsOnTaskInOtherProjects(final Task task, boolean useDependedOn, String otherProjectTaskName,
                                             String configurationName) {
    Project project = task.getProject();
    final Configuration configuration = project.getConfigurations().getByName(configurationName);
    task.dependsOn(configuration.getTaskDependencyFromProjectDependency(useDependedOn, otherProjectTaskName));
}
 
Example 19
Source File: DependencyManager.java    From javaide with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Adds a dependency on tasks with the specified name in other projects.  The other projects
 * are determined from project lib dependencies using the specified configuration name.
 * These may be projects this project depends on or projects that depend on this project
 * based on the useDependOn argument.
 *
 * @param task                 Task to add dependencies to
 * @param useDependedOn        if true, add tasks from projects this project depends on, otherwise
 *                             use projects that depend on this one.
 * @param otherProjectTaskName name of task in other projects
 * @param configurationName    name of configuration to use to find the other projects
 */
private static void addDependsOnTaskInOtherProjects(final Task task, boolean useDependedOn,
                                                    String otherProjectTaskName,
                                                    String configurationName) {
    Project project = task.getProject();
    final Configuration configuration = project.getConfigurations().getByName(
            configurationName);
    task.dependsOn(configuration.getTaskDependencyFromProjectDependency(
            useDependedOn, otherProjectTaskName));
}
 
Example 20
Source File: JavaPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * Adds a dependency on tasks with the specified name in other projects.  The other projects are determined from
 * project lib dependencies using the specified configuration name. These may be projects this project depends on or
 * projects that depend on this project based on the useDependOn argument.
 *
 * @param task Task to add dependencies to
 * @param useDependedOn if true, add tasks from projects this project depends on, otherwise use projects that depend
 * on this one.
 * @param otherProjectTaskName name of task in other projects
 * @param configurationName name of configuration to use to find the other projects
 */
private void addDependsOnTaskInOtherProjects(final Task task, boolean useDependedOn, String otherProjectTaskName,
                                             String configurationName) {
    Project project = task.getProject();
    final Configuration configuration = project.getConfigurations().getByName(configurationName);
    task.dependsOn(configuration.getTaskDependencyFromProjectDependency(useDependedOn, otherProjectTaskName));
}