You are previewing Apache Maven 2 Effective Implementation.
O'Reilly logo
Apache Maven 2 Effective Implementation

Book Description

Build and Manage Applications with Maven, Continuum, and Archiva

  • Follow a sample application which will help you to get started quickly with Apache Maven

  • Learn how to use Apache Archiva - an extensible repository manager - with Maven to take care of your build artifact repository

  • Leverage the power of Continuum - Apache's continuous integration and build server - to improve the quality and maintain the consistency of your build

  • Guidance on how to use Maven in a team environment to maximise its potential

In Detail

By building up a sample application, this book guides developers painlessly through building a project with Maven. This book shows you how to combine Maven with Continuum and Archiva, which will allow you to build an efficient, secure application and make developing in a team easy.

You may already be aware of the pitfalls of 'integration hell' caused by changed code being submitted to repositories by a number of developers. When you implement Continuum in your build, you can easily perform continuous integration, avoiding timely rework and reducing cost and valuable time. You will be able to use Maven more efficiently in a team after you learn how to set up Archiva, Apache's repository manager.

It's easy to quickly get to work with Maven and get the most out of its related tools when you follow the sequential coverage of the sample application in this book. A focus on team environments ensures that you will avoid the pitfalls that are all too common when working in a team. Soon, by learning the best practices of working with Maven, you will have built an effective, secure Java application.

Table of Contents

  1. Apache Maven 2 Effective Implementation
    1. Apache Maven 2 Effective Implementation
    2. Credits
    3. About the Authors
    4. About the Reviewers
    5. 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 for the book
        2. Errata
        3. Piracy
        4. Questions
    6. 1. Maven in a Nutshell
      1. A whirlwind tour
        1. Installing Maven
        2. Creating a new project from an archetype
        3. Building the project
        4. Reusing builds
        5. Adding dependencies
        6. Adding functionality through plugins
        7. Adding resources
        8. Running tests
        9. Getting help
        10. Enhancing the development process
        11. Viewing detailed project information
        12. Multiple module builds
        13. What if I need to convert an existing project?
      2. Summary
    7. 2. Staying in Control with Archiva
      1. Importance of a repository manager
      2. Installing Archiva
      3. Separating your repositories
      4. Hooking up Maven with Archiva
        1. Setting up a proxy
        2. Configuring your settings.xml
        3. Building your project
      5. Searching for artifacts in Archiva
      6. Deploying from Maven
        1. Creating a new user
        2. Configuring and deploying from Maven
      7. Deploying via web form
      8. Summary
    8. 3. Building an Application Using Maven
      1. Introducing the sample project
      2. Setting up a multi-module build
        1. Creating the parent POM
        2. Creating the modules
        3. Dependency management
        4. Fleshing out the example application
      3. Creating an organization POM
      4. Configuring basic reports
      5. Preparing for non-code modules
        1. Creating a modules tree
      6. Adding a documentation module
        1. Building the site automatically
        2. Assembling the site for distribution
        3. Adding site resources
        4. Adding a skin
      7. Distributing the application
        1. Generating the runtime environment with the App Assembler plugin
        2. Generating the assembly archive
          1. Adding the documentation to the distribution archive
      8. Summary
    9. 4. Application Testing with Maven
      1. Types of testing in Maven
        1. Unit testing (or code testing)
        2. Integration testing (or module testing)
        3. Functional and other types of testing
      2. Working with tests
        1. Surefire plugin configuration
          1. Controlling the execution of tests
          2. Inclusion and exclusion of tests
          3. Running specific tests from the command line
          4. Skipping tests temporarily
        2. Producing a report for the test results
        3. Reviewing test coverage
          1. Coverage and multimodule projects
      3. Integration, functional, and other testing
        1. Running integration tests using naming patterns
          1. Operating the Selenium server
          2. Deploying the application to a container
          3. Simplifying test grouping with TestNG
        2. Using a separate integration test module
        3. Altering integration tests with profiles
          1. Using TestNG parameters
          2. Measuring coverage for integration tests
      4. Summary
    10. 5. Reporting and Checks
      1. Review: Example application
      2. Constructing the developer's site
      3. Maven reports
        1. Adding reports to the project
        2. Configuring plugins for both reporting and the build
        3. Configuring reports in the site life cycle
      4. Setting up quality checks
        1. Setting a minimum coverage requirement
        2. Best practices for configuring coverage checks
      5. Reporting and quality tools
        1. Dependencies
        2. Javadoc
        3. Checkstyle
        4. PMD
        5. FindBugs
        6. Clirr
        7. Other tools
      6. Reporting best practices
        1. Choosing reports
        2. Site deployment
        3. Introducing and selecting failure thresholds
      7. Tying it all together
        1. Dashboard plugin
        2. Sonar
      8. Summary
    11. 6. Useful Maven Plugins
      1. The Remote Resources plugin
        1. Creating a Remote Resource bundle
        2. Processing Remote Resources in a project
      2. The Build Number plugin
      3. The Shade plugin
        1. Building a standalone artifact
        2. Shading dependencies
      4. The Build Helper plugin
        1. Adding source directories
        2. Attaching arbitrary artifacts
        3. Other goals
      5. The AntRun plugin and scripting languages
        1. Running simple tasks
        2. Interacting with the Maven project
        3. Converting Ant or Maven 1 builds
        4. Maven plugins written in Ant
        5. Other scripting languages
      6. The Exec plugin
        1. Adding the Exec plugin to the Build life cycle
        2. Running the Exec plugin standalone
      7. Summary
    12. 7. Maven Best Practices
      1. Preparing the development environment
        1. Maven installation and user settings
          1. Encrypting server passwords
        2. Project settings
        3. Configuring repositories
      2. Keeping it simple
        1. Using conventions
        2. Using inheritance
        3. Decomposing the build into modules
          1. Aligning the source structure
          2. Selecting group and artifact identifiers
          3. Building modules together
          4. Each module should be independently useful
          5. Watching the dependencies
          6. Separating API from implementation
        4. Trimming dependencies
        5. Dependency version management
        6. Profiles and pipelining
        7. Scripting and writing plugins
        8. Creating and using archetypes
      3. Build portability
        1. Setting expectations
        2. Hard coding
        3. Portable profiles
        4. Portable artifacts
        5. Resource filtering
        6. Shared resources
      4. Build reproducibility
      5. Summary
    13. 8. Continuum: Ensuring the Health of your Source Code
      1. Knowing when your build breaks
      2. Setting up Continuum
        1. Setting up a source repository
        2. Installing prerequisites
        3. Installing and configuring Continuum
      3. Using Continuum
        1. At a glance
        2. The build queues
        3. The build definition
          1. Project group build definition
          2. Project build definition
        4. The notifiers
          1. Different types of notifiers
          2. Configuring notifiers in Maven
        5. The Build results
          1. Dependency changes
        6. Installations and build environments
          1. Installations
          2. Build environments
      4. Summary
    14. 9. Continuum in Depth
      1. Releasing projects
        1. Release early, release often
        2. Maven release process
          1. Release profile
        3. Releasing projects using Continuum
          1. Preparing a release
          2. Finalizing a release
          3. Viewing release history
          4. Other types of releases
          5. Troubleshooting releases in Continuum
      2. Build pipelining and multiple build definitions
      3. Parallel builds
        1. How it works
        2. Configuring parallel builds
      4. Distributed builds
        1. Master and slave
        2. Configuring distributed builds
        3. Doing project releases on a build agent
      5. Maintenance
        1. Configuring multiple local repositories
        2. Cleaning up local repositories
        3. Cleaning up directories
      6. Summary
    15. 10. Archiva in a Team
      1. Roles and permissions
      2. Introducing repository groups
        1. Configuring and using repository groups
      3. RSS feeds discovering new artifacts in your repository
        1. Repository level feeds
        2. Artifact level feeds
      4. Deleting artifacts in your repository
      5. The Archiva reports
        1. Repository statistics
        2. Repository health
      6. The Archiva consumers
        1. What is a consumer?
        2. Archiva's maintenance-savvy consumers
          1. Purging outdated snapshots
          2. Correcting Maven metadata
          3. Creating missing checksums
          4. Database cleanup consumers
      7. Summary
    16. 11. Archetypes
      1. What are Maven archetypes?
        1. Benefits of Maven archetypes
      2. Generating projects
        1. From archetype:create to archetype:generate
        2. Using archetypes within multi-module projects
      3. Common archetypes
          1. Maven site archetype
          2. Maven Mojo (plugin) archetype
          3. Maven simple J2EE archetype
          4. The AppFuse Spring archetype
          5. Other examples
      4. Writing a new archetype
        1. Creating an archetype from a skeleton
        2. Using the custom archetype
      5. Managing catalogs
      6. Summary
    17. 12. Maven, Archiva, and Continuum in the Enterprise
      1. Configuring security
        1. A brief look at Redback
        2. Setting up security for multiple teams in Continuum
        3. Setting up security for multiple teams in Archiva
        4. Additional Redback configuration
        5. Using LDAP
      2. Interfacing with other tools in the enterprise
        1. Continuum web services
          1. Building the Continuum plugin
          2. Using Continuum's web services
        2. Archiva web services
          1. Building the Archiva plugin
          2. Using Archiva's web services
      3. Summary
    18. A. Troubleshooting Maven
      1. Examining Maven output
      2. Using debug mode
      3. Confirming the expected models
      4. Analyzing dependencies
      5. Download problems
    19. B. Recent Maven Features
      1. Server password encryption
      2. Reactor project selection
        1. Resuming a failed build
        2. Building a subset of modules
        3. The Reactor plugin
          1. Building modules with local changes
      3. Reconfiguring default life cycle goals
      4. Parallel artifact resolution
    20. C. Migrating Archiva and Continuum Data
      1. Using a different database
      2. Database backup and migrating between versions
        1. Migrating Continuum
        2. Migrating Archiva