Skip to content
BENIBIX Learn

Apache Maven

Development🛠️ Editors & ToolsBuild Automation

Also known as Maven, mvn, pom.xml

A free build tool for Java. One pom.xml file describes the whole project.

Think of it like

It is like a school day with a set plan. Each class comes in the same order.

Example

Lucy clones a Java project and types mvn package. Maven fetches the packages, runs the tests and puts the jar in target.

Why it matters

Every Maven project looks the same inside. A new person can build any of them with one command.

Definition

Apache Maven is a free build tool for Java projects. The whole project is described in one file called pom.xml. That file lists the packages the project needs, and Maven fetches them. Maven expects a fixed folder layout, with code in src/main/java. It runs a set list of phases, like compile, test and package. The finished jar file lands in the target folder.

Example code

console
$ mvn package
[INFO] Building jar: target/my-app-1.0-SNAPSHOT.jar
[INFO] BUILD SUCCESS
One command builds, tests and packs the code. The jar goes in the target folder.
Maven is the build tool whose recipe is a pom.xml file.

Common mistake

Fighting the folder layout. Put files where Maven expects them, or it will not find your code.

Key takeaways

  1. 1
    One file. pom.xml describes the whole project.
  2. 2
    Fixed layout. Code goes in src/main/java.
  3. 3
    Set phases. Compile, test, package, in that order.

Compare

Learn it properly