Mastering Apache Maven 3

Book description

Enhance developer productivity and address exact enterprise build requirements by extending Maven

In Detail

Maven is the number one build tool used by developers for more than a decade. Maven stands out among other build tools due to its extremely extensible architecture, which is built on top of the concept "convention over configuration". This has made Maven the de-facto tool used to manage and build Java projects.

This book is a technical guide to the difficult and complex concepts in Maven and build automation. It starts with the core Maven concepts and its architecture, and then explains how to build extensions such as plugins, archetypes, and lifecycles in depth.

This book is a step-by-step guide that shows you how to use Apache Maven in an optimal way to address your enterprise build requirements.

What You Will Learn

  • Apply Maven best practices in designing a build system to improve developer productivity
  • Customize the build process to suit your enterprise needs by developing custom Maven plugins, lifecycles, and archetypes
  • Implement and deploy a Maven repository manager to manage the build process in a better and smoother way
  • Design the build in a way that prevents any maintenance nightmares with proper dependency management
  • Optimize Maven configuration settings
  • Create your own distribution archive using Maven assemblies
  • Build custom Maven lifecycles and lifecycle extensions

Table of contents

  1. Mastering Apache Maven 3
    1. Table of Contents
    2. Mastering Apache Maven 3
    3. Credits
    4. About the Author
    5. Acknowledgments
    6. About the Reviewers
      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. A quick introduction
      2. Installing Apache Maven
        1. Installing Apache Maven on Ubuntu
        2. Installing Apache Maven on Mac OS X
        3. Installing Apache Maven on Microsoft Windows
      3. Configuring the heap size
      4. Monitoring the build
      5. Remote debugging
      6. Convention over configuration
      7. IDE integration
        1. NetBeans integration
        2. IntelliJ IDEA integration
        3. Eclipse integration
      8. Troubleshooting
        1. Enabling Maven debug-level logs
        2. Building dependency tree
        3. Viewing all environment variables and system properties
        4. Viewing the effective POM file
        5. Viewing the dependency classpath
      9. Summary
    10. 2. Demystifying Project Object Model
      1. Project Object Model
      2. The POM hierarchy
      3. Super POM
      4. POM extending and overriding
      5. Maven coordinates
      6. Parent POM file
      7. Managing POM dependencies
        1. Transitive dependencies
        2. Dependency scopes
        3. Optional dependencies
        4. Dependency exclusion
      8. Summary
    11. 3. Maven Configuration
      1. Maven Wagon
        1. Wagon HTTP(S) transport
        2. Wagon system properties
      2. Proxy authentication
      3. Secured repositories
      4. Encrypting credentials in settings.xml
      5. Source Control Management systems
        1. Maven with Subversion
      6. Local repository location
      7. Mirrored repositories
        1. The internal corporate repository
        2. Advanced mirror configurations
      8. Deploying artifacts
        1. Deploying file-based artifacts
        2. Deploying SSH-based artifacts
        3. Deploying FTP-based artifacts
      9. Enabling Maven logging
      10. Summary
    12. 4. Build Lifecycles
      1. Standard lifecycles in Maven
        1. The clean lifecycle
        2. The default lifecycle
        3. The site lifecycle
      2. Lifecycle bindings
      3. Building a custom lifecycle
      4. Lifecycle extensions
      5. Summary
    13. 5. 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. Plexus
      4. Maven and Dependency Injection
        1. Google Guice
      5. Developing custom plugins
        1. Associating a plugin with a lifecycle
        2. The plugin execution order
        3. Inside the execute method
      6. 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. Maven Archetypes
      1. Archetype quickstart
      2. The 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. Maven plugins with the archetype plugin
      6. Java EE web applications with the archetype plugin
        1. Deploying web applications to a remote Apache Tomcat server
      7. Android mobile applications with the archetype plugin
      8. EJB archives with the archetype plugin
      9. JIRA plugins with the archetype plugin
      10. Spring MVC applications with the archetype plugin
      11. Building a custom archetype
        1. The archetype descriptor
        2. Generating a multimodule Maven project
        3. archetype:create-from-project with custom properties
      12. Summary
    16. 8. Maven Repository Management
      1. Maven repositories
      2. The update policy
      3. Multiple repositories
        1. Repositories in settings.xml
      4. The Maven repository manager
        1. Repository management with Nexus
        2. Installing and running Nexus
        3. Creating a hosted repository
      5. Creating a proxy repository
      6. Creating a virtual repository
      7. Blocking selected artifacts
      8. Inclusive and exclusive routing
      9. Scheduled tasks
      10. Artifact indexing
      11. Nexus plugins
      12. A repository metadata model
      13. Summary
    17. 9. Best Practices
      1. Dependency management
      2. Defining a parent module
      3. POM properties
      4. Avoiding repetitive groupId and version tags and inherit from the parent POM
      5. Following naming conventions
      6. Maven profiles
      7. Think twice before you write your own plugin
      8. The Maven release plugin
      9. The Maven enforcer plugin
      10. Avoid using un-versioned plugins
      11. Using exclusive and inclusive routes
      12. Avoid having both release and snapshot repositories in the same group repository
      13. Avoid having both proxy and hosted repositories in the same group repository
      14. Minimizing the number of repositories
      15. Using mirrorOf instead of changing repository URLs
      16. Descriptive parent POM files
      17. Documentation is your friend
      18. Avoid overriding the default directory structure
      19. Using SNAPSHOT versioning during development
      20. Get rid of unused dependencies
      21. Avoid keeping credentials in application POM files
      22. Avoid using deprecated references
      23. Avoid repetition – use archetypes
      24. Avoid using maven.test.skip
      25. Share resources – avoid duplicates
      26. Summary
    18. Index

Product information

  • Title: Mastering Apache Maven 3
  • Author(s): Prabath Siriwardena
  • Release date: December 2014
  • Publisher(s): Packt Publishing
  • ISBN: 9781783983865