Maven by Example

Table of Contents

As developers, we understand that you don't want to spend years reading documentation about your build tool. We get it. You just want to get to work. On the other hand, if you don't take a little bit of time to understand what Maven can do and what it was designed for, there's a good possibility you'll be needlessly reinventing wheels. Take an hour or two and walk through Table of Contents, it's a gentle introduction to Maven and we promise it will save you time. Sonatype maintains two books focused on Maven: an example-driven introduction to Maven, "Maven by Example" and Maven: The Complete Reference. If you already understand how to use Maven and are just looking for a reference, go read the other book.

Authors

Tim O'Brien John Casey Brian Fox Jason Van Zyl Juven Xu Thomas Locher Dan Fabulich Eric Redmond Bruce Snyder

Preface
1. Acknowledgements
2. How to contribute
1. Introducing Apache Maven
1.1. Maven… What is it?
1.2. Convention Over Configuration
1.3. A Common Interface
1.4. Universal Reuse through Maven Plugins
1.5. Conceptual Model of a "Project"
1.6. Is Maven an alternative to XYZ?
1.7. Comparing Maven with Ant
2. Installing Maven
2.1. Verify your Java Installation
2.2. Downloading Maven
2.3. Installing Maven
2.4. Testing a Maven Installation
2.5. Maven Installation Details
2.6. Uninstalling Maven
2.7. Getting Help with Maven
2.8. About the Apache Software License
3. A Simple Maven Project
3.1. Introduction
3.2. Creating a Simple Project
3.3. Building a Simple Project
3.4. Simple Project Object Model
3.5. Core Concepts
3.6. Summary
4. Customizing a Maven Project
4.1. Introduction
4.2. Defining the Simple Weather Project
4.3. Creating the Simple Weather Project
4.4. Customize Project Information
4.5. Add New Dependencies
4.6. Simple Weather Source Code
4.7. Add Resources
4.8. Running the Simple Weather Program
4.9. Writing Unit Tests
4.10. Adding Test-scoped Dependencies
4.11. Adding Unit Test Resources
4.12. Executing Unit Tests
4.13. Building a Packaged Command Line Application
5. A Simple Web Application
5.1. Introduction
5.2. Defining the Simple Web Application
5.3. Creating the Simple Web Project
5.4. Configuring the Jetty Plugin
5.5. Adding a Simple Servlet
5.6. Adding J2EE Dependencies
5.7. Conclusion
6. A Multi-module Project
6.1. Introduction
6.2. The Simple Parent Project
6.3. The Simple Weather Module
6.4. The Simple Web Application Module
6.5. Building the Multimodule Project
6.6. Running the Web Application
7. Multi-module Enterprise Project
7.1. Introduction
7.2. The Simple Parent Project
7.3. The Simple Model Module
7.4. The Simple Weather Module
7.5. The Simple Persist Module
7.6. The Simple Web Application Module
7.7. Running the Web Application
7.8. The Simple Command Module
7.9. Running the Simple Command
7.10. Conclusion
8. Optimizing and Refactoring POMs
8.1. Introduction
8.2. POM Cleanup
8.3. Optimizing Dependencies
8.4. Optimizing Plugins
8.5. Optimizing with the Maven Dependency Plugin
8.6. Final POMs
8.7. Conclusion
9. Creative Commons License
10. Copyright