Build tools
On this page 8 topics
Overview
Topics
- Maven basics
- pom.xml
- dependencies
- build lifecycle
- running tests
Learn first
61 min of reading · 2.5 h of practice (estimate)
Learning outcomes
- Explain what a build tool does and why manual
javacdoes not scale. - Read a
pom.xml: coordinates, dependencies, and plugins. - Run
mvn compile,test, andpackageand explain the lifecycle phases. - Add a dependency from Maven Central and convert an existing project to Maven.
Lessons
Lab and exercises
Lab
BEG-054-LAB1 · Mavenize
Outcomes: 1–4 · Time: ~2.5 h Convert the data-structures project to Maven with JUnit as a test dependency; mvn test passes from the terminal. Acceptance: builds on a clean machine.
Exercises (assessment: practical check)
| ID | Outcome | Task |
|---|---|---|
| BEG-054-EX01 | 1 | List three problems with compiling a ten-library project by hand with javac. |
| BEG-054-EX02 | 2 | Label groupId, artifactId, version, a dependency, and a plugin in a given pom.xml. |
| BEG-054-EX03 | 2 | Place five given files into the correct Maven folders. |
| BEG-054-EX04 | 3 | Run mvn compile, mvn test, and mvn package; say what each produced. |
| BEG-054-EX05 | 3 | Explain why mvn package also runs the tests. |
| BEG-054-EX06 | 4 | Add a library from Maven Central and use one class from it. |
| BEG-054-EX07 | 4 | Make sure target/ is not committed in the converted project. |
Show solutions
- EX01 Long class paths, manual downloads of JARs, no repeatable steps (and no test running).
- EX02 Coordinates sit at the top; dependencies under
<dependencies>; plugins under<build><plugins>. - EX03 Main classes in
src/main/java; tests insrc/test/java;pom.xmlat the root. - EX04
compilemakes classes intarget/classes;testruns tests;packagecreates a JAR intarget/. - EX05 Lifecycle phases run in order;
testcomes beforepackage. - EX06 Add the
<dependency>block, then import its class; Maven downloads it on the next build. - EX07
.gitignorecontainstarget/;git statusdoes not show it.
Quiz
Outcomes: O1 why build tools · O2 pom.xml · O3 lifecycle · O4 dependencies and conversion.
A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.
Practical part
Practical check: the data-structures project builds and mvn test passes from a clean clone (lab and EX01–EX07). Pass: at least 8 of 10 quiz questions and a build that works on a clean machine.
Common mistakes
Wrong folder layout; committing target/.
Assessment
Practical check.
Career relevance
Maven in depth (JNR-002).