11 Building with Gradle & Maven

 

This chapter covers

  • Why build tools matter for a well-grounded developer
  • Maven
  • Gradle

The JDK ships with a compiler to turn Java source code into class files as we saw in Chapter 4. Despite that fact, few projects of any size rely just on javac. Let’s start by looking at why a well-grounded developer should invest in familiarity with this layer of tooling.

11.1 Why build tools matter for a well-grounded developer

Build tools are the norm for a number of reasons:

  • Automating tedious operations
  • Managing dependencies
  • Ensuring consistency between developers

Although many options exist, two choices dominate the landscape today: Maven and Gradle. Understanding what these tools aim to solve, digging below the surface of how they get their job done, and understanding the differences between them - and how to extend them - will pay off for the well-grounded developer.

11.1.1 Automating tedious operations

javac can turn any Java source file into a class file, but there’s more to building a typical Java project than that. Just getting all the files properly listed to the compiler could be tedious in a large project if done by hand. Build tools provide defaults for finding code and let you easily configure if you have a non-standard layout instead.

The conventional layout popularized by Maven and used by default by Gradle as well looks like this:

11.1.2 Managing dependencies

11.1.3 Ensuring consistency between developers

11.2 Maven

11.2.1 The build lifecycle

11.2.2 Commands/POM intro

11.2.3 Building

11.2.4 Controlling the manifest

11.2.5 Adding another language

11.2.6 Testing

11.2.7 Dependency management

11.2.8 Reviewing

11.2.9 Moving beyond Java 8

11.2.11 Maven and modules

sitemap