Book Image

Gradle Effective Implementations Guide - Second Edition

By : Hubert Klein Ikkink
Book Image

Gradle Effective Implementations Guide - Second Edition

By: Hubert Klein Ikkink

Overview of this book

Gradle is a project automation tool that has a wide range of applications. The basic aim of Gradle is to automate a wide variety of tasks performed by software developers, including compiling computer source code to binary code, packaging binary codes, running tests, deploying applications to production systems, and creating documentation. The book will start with the fundamentals of Gradle and introduce you to the tools that will be used in further chapters. You will learn to create and work with Gradle scripts and then see how to use Gradle to build your Java Projects. While building Java application, you will find out about other important topics such as dependency management, publishing artifacts, and integrating the application with other JVM languages such as Scala and Groovy. By the end of this book, you will be able to use Gradle in your daily development. Writing tasks, applying plugins, and creating build logic will be your second nature.
Table of Contents (18 chapters)
Gradle Effective Implementations Guide - Second Edition
About the Author
About the Reviewer

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 file of our standalone project. Gradle implicitly added the Groovy plugin and dependencies on the Gradle API and Groovy for us when the build.gradle file is in the buildSrc directory. Now we have a standalone project and we must add these dependencies...