Creating a task in a standalone project

To make a task reusable for other projects, we must have a way to distribute the task. Also, other projects that want to use the task must be able to find our task. We will see how to publish our task in a repository and how other projects can use the task in their projects.

We have seen how to place the task implementation from the build file in the buildSrc directory. The buildSrc directory is similar to a normal Gradle build project, so it is easy to create a standalone project for our task. We only have to copy the contents of the buildSrc directory to our newly created project directory.

Let's create a new project directory and copy the contents of the buildSrc directory. We must edit the build.gradle ...

Get Gradle Effective Implementations Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.