You are previewing Maven Essentials.
O'Reilly logo
Maven Essentials

Book Description

Get started with the essentials of Apache Maven and get your build automation system up and running quickly

About This Book

  • Explore the essentials of Apache Maven essentials to arm yourself with all the ingredients needed to develop a comprehensive build automation system

  • Identify the extension points in Apache Maven and learn more about them in-depth

  • Improve developer productivity by optimizing the build process with best practices in Maven using this compact guide

  • Who This Book Is For

    The book is ideal for for experienced developers who are already familiar with build automation, but want to learn how to use Maven and apply its concepts to the most difficult scenarios in build automation.

    What You Will Learn

  • Comprehend the key concepts in Apache Maven

  • Build your own custom plugins and get to know how Maven extension points are used

  • Troubleshoot build issues with greater confidence

  • Optimize Maven’s configuration settings

  • Write custom lifecycles and extensions

  • Get hands-on and create a Maven assembly

  • Explore the best practices to design a build system that improves developer productivity

  • In Detail

    Maven is the #1 build tool used by developers and it has been around for more than a decade. Maven stands out among other build tools due to its extremely extensible architecture, which is built on of the concept of convention over configuration. It’s widely used by many open source Java projects under Apache Software Foundation, Sourceforge, Google Code, and more.

    Maven Essentials is a fast-paced guide to show you the key concepts in Maven and build automation. We get started by introducing you to Maven and exploring its core concepts and architecture. Next, you will learn about and write a Project Object Model (POM) while creating your own Maven project. You will also find out how to create custom archetypes and plugins to establish the most common goals in build automation. After this, you’ll get to know how to design the build to prevent any maintenance nightmares, with proper dependency management. We then explore Maven build lifecycles and Maven assemblies. Finally, you will discover how to apply the best practices when designing a build system to improve developer productivity.

    Style and approach

    This book is a practical and compact guide that will show you how to use Apache Maven in an optimal way to address enterprise build requirements. It provides technical guidance to get you started with Maven and build automation.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. Maven Essentials
      1. Table of Contents
      2. Maven Essentials
      3. Credits
      4. About the Author
      5. Acknowledgments
      6. About the Reviewer
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      9. 1. Apache Maven Quick Start
        1. Installing Apache Maven
          1. Installing Apache Maven on Ubuntu
          2. Installing Apache Maven on Mac OS X
          3. Installing Apache Maven on Microsoft Windows
        2. Configuring the heap size
        3. Hello Maven!
        4. Convention over configuration
        5. Maven repositories
        6. IDE integration
          1. NetBeans integration
          2. IntelliJ IDEA integration
          3. Eclipse integration
        7. Troubleshooting
          1. Enabling Maven debug level logs
          2. Building a dependency tree
          3. Viewing all the environment variables and system properties
          4. Viewing the effective POM file
          5. Viewing the dependency classpath
        8. Summary
      10. 2. Understanding the Project Object Model (POM)
        1. Project Object Model (POM)
        2. POM hierarchy
        3. Super POM
        4. POM extending and overriding
        5. Maven coordinates
        6. The parent POM
        7. Managing POM dependencies
          1. Transitive dependencies
          2. Dependency scopes
          3. Optional dependencies
            1. Dependency exclusion
        8. Summary
      11. 3. Maven Archetypes
        1. Archetype quickstart
        2. Batch mode
        3. Archetype catalogues
          1. Building an archetype catalogue
          2. Public archetype catalogues
          3. The anatomy of archetype – catalog.xml
        4. The archetype plugin goals
        5. Java EE web applications with the archetype plugin
          1. Deploying web applications to a remote Apache Tomcat server
        6. Android mobile applications with the archetype plugin
        7. EJB archives with the archetype plugin
        8. JIRA plugins with the archetype plugin
        9. Spring MVC applications with the archetype plugin
        10. Summary
      12. 4. Maven Plugins
        1. Common Maven plugins
          1. The clean plugin
          2. The compiler plugin
          3. The install plugin
          4. The deploy plugin
          5. The surefire plugin
          6. The site plugin
          7. The jar plugin
          8. The source plugin
          9. The resources plugin
          10. The release plugin
        2. Plugin discovery and execution
          1. Plugin management
          2. Plugin repositories
          3. Plugin as an extension
        3. Summary
      13. 5. Build Lifecycles
        1. Standard lifecycles in Maven
          1. The clean lifecycle
          2. The default lifecycle
          3. The site lifecycle
        2. Lifecycle bindings
        3. Lifecycle extensions
        4. Summary
      14. 6. Maven Assemblies
        1. The assembly plugin
        2. The assembly descriptor
        3. Artifact/resource filtering
        4. Assembly help
        5. A runnable standalone Maven project
        6. Summary
      15. 7. Best Practices
        1. Dependency management
        2. Defining a parent module
        3. POM properties
        4. Avoiding repetitive groupIds and versions, and inheriting from the parent POM
        5. Following naming conventions
        6. Think twice before you write your own plugin. You may not need it!
        7. The Maven release plugin
        8. The Maven enforcer plugin
        9. Avoiding the use of unversioned plugins
        10. Descriptive parent POM files
        11. Documentation is your friend
        12. Avoid overriding the default directory structure
        13. Using SNAPSHOT versioning during the development
        14. Get rid of unused dependencies
        15. Avoiding keeping credentials in application POM files
        16. Avoiding using deprecated references
        17. Avoiding repetition – use archetypes
        18. Avoiding using maven.test.skip
        19. Summary
      16. Index