A Maven Tutorial
January 10, 2010 00:19:30 Last update: January 31, 2012 16:28:42
Maven is a powerful yet complex tool. When I started learning Maven, the first obstacle was, of course, its complexity. The second, was the lack of documentation that can get me off the ground quickly. This tutorial is an attempt to create a pragmatic guide that aims to get you familiar with Maven in the quickest way possible. The main theme is to get you on some hands on experience to start out and lead you through the creation of a simple Java EE project as quickly as possible. Instead of trying to give you a good read, I try to get you on the journey right away. The topics are roughly ordered by the logical sequence but you can jump around in any way you want.
Any feedback or suggestions are welcomed and appreciated.
Practice Projects
The best way to learn how to use a tool is - use it.
Concepts
Bare minimum gobbledigook you need to know about Maven.
Problems and solutions
What are some of the problems you encountered while using Maven? Nothing? You haven't used it yet.
Maven 3.0 update
These notes were written for Maven 2.x. Maven 3.0 has been released since then. However, because of the good compatibility between 3.0 and 2.x, these notes are still applicable. Please refer to Maven 3.x Compatibility Notes for things that have changed.
A final word about Maven
Maven is a powerful tool that can do a lot of wonderful things. But there are also a multitude of ways to shoot yourself in the foot. Without caution, you can build a Maven project so complex that you'll only have time to maintain Maven and no time for anything else. By all means, keep it simple.
Any feedback or suggestions are welcomed and appreciated.
Practice Projects
The best way to learn how to use a tool is - use it.
- Maven "Hello World"
- Maven: start a new project with archetype:generate
- Add Java EE dependencies for Maven 2
- Start a webapp (web application) project with Maven
- Start a Java EE application with Maven
- Fine tuning Maven dependencies
- Resolving Maven dependencies with dependency:tree
- Maven resource filtering and build profiles
Concepts
Bare minimum gobbledigook you need to know about Maven.
- Maven standard directory layout
- Maven POM, supper POM and effective POM
- Maven build lifecycles, phases and goals
- Maven project packaging
- Maven repositories
- Maven dependency types
- Maven dependency scopes
- Maven dependency management
- Maven plugins
Problems and solutions
What are some of the problems you encountered while using Maven? Nothing? You haven't used it yet.
- Maven: tricky JAVA_HOME setting
- Maven compilation error: annotations are not supported in -source 1.3
- Maven: generics are not supported in -source 1.3
- Maven Error assembling EJB: META-INF/ejb-jar.xml is required for ejbVersion 2.x
- Maven failure executing javac OutOfMemoryError
- Maven: class file has wrong version 50.0, should be 49.0
- JBoss Maven repository permission denied
Maven 3.0 update
These notes were written for Maven 2.x. Maven 3.0 has been released since then. However, because of the good compatibility between 3.0 and 2.x, these notes are still applicable. Please refer to Maven 3.x Compatibility Notes for things that have changed.
A final word about Maven
Maven is a powerful tool that can do a lot of wonderful things. But there are also a multitude of ways to shoot yourself in the foot. Without caution, you can build a Maven project so complex that you'll only have time to maintain Maven and no time for anything else. By all means, keep it simple.