Skip to content
BENIBIX Learn

Make, Maven and Gradle

Level 5 · Building the project

What a build tool does, and how it skips work that has not changed. Make with its Makefile, Maven with pom.xml, and Gradle for Java and Android.

Course contentsLesson 12 of 13

After this lesson you can

  • Say what a build tool does
  • Read a simple Makefile
  • Tell Maven from Gradle

13 mincovers 4 glossary entries

Worth reading first: Virtual Environments and uv

What a build tool does, and how the big three differ

A build tool runs the steps that turn your code into a finished program. You write the steps once in a file, and the tool runs them in order: compile, test, then pack it up. Good ones skip any step whose files did not change. Make, the oldest of the best-known three, dates from 1976.

Without one, someone builds by hand, and each person builds in a slightly new way. The copy that works on one laptop fails on the server. With a build tool, each person and each server runs the very same steps.

Make is old and simple. It reads a file called a Makefile, which lists targets, the files each one needs, and the commands that make it. Make compares file dates and rebuilds only what depends on a changed file. It began with C programs, and people now use it to run all kinds of jobs.

Make has one famous trap. Each command line in a Makefile must start with a tab, not spaces. Many editors turn a tab into spaces, and Make then stops with an error about a missing separator.

Apache Maven is a build tool for Java. The whole project is described in one file, pom.xml, which also lists the packages it needs. Maven expects a fixed layout, with code in src/main/java, and runs a set list of phases such as compile, test and package. The result lands in a folder called target.

Gradle is a build tool used most for Java, Kotlin and Android apps. Its steps live in a file called build.gradle.kts, which is code, so you can add steps of your own. It skips work that has not changed, so later builds are fast. Projects ship a small script, gradlew, that fetches the right Gradle version.

The common mistake is running a Gradle you put on your own machine. It may be the wrong version for the project, so use ./gradlew instead. With Maven, the mistake is fighting the layout. Put files where it looks for them, or it will not find your code.

Three build tools side by side

ToolRecipe fileMostly used for
MakeMakefileC programs, and any job you can script
Apache Mavenpom.xmlJava projects with a fixed layout
Gradlebuild.gradle.ktsJava, Kotlin and Android apps

Which one you will meet

  1. 1

    Make

    When a project needs a few simple named jobs, or is written in C.

  2. 2

    Maven

    When a Java team wants one standard layout and few choices.

  3. 3

    Gradle

    When you build an Android app, or a Java project needs custom steps.

makefile
app: main.c
	cc -o app main.c

test: app
	./app --self-test
Two targets. test needs app, and app needs main.c. Each command line starts with a tab.
A build tool reads its recipe file. Then it runs compile, test and package, in that order.

Worked example

Jack's build drops from 6 minutes to 40 seconds

Jack's Android app takes 6 minutes to build from scratch. He changes one line of one screen and builds again with ./gradlew build.

Gradle sees that only one file changed and skips the rest. The second build takes 40 seconds.

The words for this lesson4

Check yourself

Why does Make say missing separator?

Finished this lesson?

Marking it complete also marks its 4 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.