Chapter 4. Using Gradle for Java Projects

We have seen how to write tasks in a Gradle build and how to execute them, but we haven't seen how to perform real-life tasks, such as compiling source code or testing with Gradle.

In this chapter, we will discuss how to use the Gradle Java plugin to get tasks for compiling and packaging a Java project. We will also see how Gradle's build-by-convention features make it very easy to start and work with a source code.

Why plugins?

In Gradle, we can apply plugins to our project. A plugin basically adds extra functionalities such as tasks and properties to our project. By using a plugin, functionality is decoupled from the core Gradle build logic. We can write our own plugins, but Gradle also ships with plugins ...

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.