You are previewing Maven Build Customization.
O'Reilly logo
Maven Build Customization

Book Description

Discover the real power of Maven 3 to manage your Java projects more effectively than ever

In Detail

Maven is one of the most popular tools used to control the dependencies and to administer a Java project. Maven can be used by newbies without the need to learn complex mechanisms, but it is also a powerful tool for big projects developed by different teams and organized over different modules and repositories.

This book will provide you with all the information you need, right from managing dependencies to improving the build process of your organization. Starting with a simple project, you will create your development environment step-by-step, automatically build your code from resources (XML, DB), and package your JAR, WAR, and EAR files for different environments. Furthermore, you will learn about the complex hereditary features of Maven.

Finally, this book will benefit you by teaching Maven-Gradle and Maven-Eclipse integration using the m2e plugin, managing the Maven repository from Gradle, and building a working Maven environment from Gradle

What You Will Learn

  • Discover the power of Maven with a real project and practical examples
  • Develop a simple plugin to interact with databases and change the status of your bug tracker
  • Get to grips with Maven dependencies
  • Develop and test your own custom plugin
  • Customize your package with the Maven profile
  • Use the most powerful plugins to release and test your software
  • Install Maven, Nexus, and Hudson to manage your code efficiently
  • Build your first application with Maven, Gradle, and Android
  • 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 http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Maven Build Customization
      1. Table of Contents
      2. Maven Build Customization
      3. Credits
      4. About the Authors
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. 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
      8. 1. Maven and Its Philosophy
        1. Core concepts of Maven
        2. Introduction to the transportation project
          1. Creating the project
          2. Structuring the project
        3. Summary
      9. 2. Core Maven Concepts
        1. Build lifecycles
          1. The default lifecycle
          2. The clean lifecycle
        2. Maven goals
          1. Getting help on plugin goals and parameters
        3. Packaging types
          1. JAR
          2. WAR
          3. POM
          4. EJB
          5. EAR
          6. Built-in lifecycles and default bindings
        4. Adding and configuring Maven plugins
          1. The plugin-level configuration
          2. The execution-level configuration
        5. Managing dependencies
          1. Dependency scopes
          2. Dependency version ranges
          3. Transitive dependencies and the dependency tree
          4. Dependency inheritance
          5. The super and the effective POMs
        6. Maven settings
        7. Properties and resource filtering
          1. Maven properties
          2. Resource filtering
        8. Building EE applications
          1. Building WEB applications
          2. Building enterprise applications
        9. Configuring repositories
          1. Enabling releases and snapshots
        10. Best practices
          1. Aggregate POMs
          2. Dependency management
          3. Plugin management
        11. Summary
      10. 3. Writing Plugins
        1. A problem to solve
        2. Developing a new plugin
        3. Implementing Mojo
        4. Testing Mojo
        5. Best practices for testing
        6. Integration testing
        7. maven-plugin-plugin
        8. Custom plugin – mantis-maven-plugin
          1. Custom plugin implementations
        9. Summary
      11. 4. Managing the Code
        1. Maven build profiles
          1. What is a profile?
          2. The structure of a profile
          3. Profile activation
          4. Sample build profiles
        2. Maven Assembly Plugin
          1. Fitting to environment
          2. Building your own archive through the Assembly plugin
          3. The descriptor file
          4. The project configuration
        3. Maven Site Plugin
          1. Creating a simple site
          2. Creating your own project site manually
            1. Configuring the site for a submodule
            2. Reporting the Javadoc
            3. Skinning Maven sites
            4. Maven site content
        4. Summary
      12. 5. Continuous Integration and Delivery with Maven
        1. Key concepts of continuous integration and delivery
        2. The repository management server
          1. Installing Nexus
            1. Installing Nexus on a Unix-based OS
            2. Installing Nexus on Windows
          2. Customizing Nexus
          3. Testing the Nexus installation
          4. Configuring the Nexus server
          5. Testing the Nexus server
          6. Managing repositories
            1. Configuring official repositories
            2. The User Managed Repository
          7. Nexus access-level security
        3. Integrating Ant
          1. Installing Ant
          2. Understanding Ant
          3. Ant custom tasks
            1. Maven-Ant integration
            2. Ant-Maven integration
        4. SCM integration
          1. Maven SCM Plugin
          2. Maven Release Plugin
          3. Deploying on the remote repository
        5. Continuous Integration and Delivery with Hudson or Jenkins
          1. Installing Hudson
          2. Configuring Hudson
          3. Working with Hudson
          4. Working with Hudson interactively
          5. Maven-Hudson integration to deliver a new artifact
          6. Testing software automation
            1. Scheduling a test reporting
          7. Aligning the shared development environment
            1. Integration tests
            2. Static code analysis tools (FindBugs)
        6. Bug fixing
          1. A case study with MantisBT
        7. A more realistic case – the transportation project
          1. Choosing the component to build
          2. Preparing the version of a multimodule component
            1. Configuring Hudson
            2. Preparing the version of a multimodule with a flat structure (an alternative way)
            3. Finalizing the release
        8. Summary
      13. 6. Maven Android
        1. Prerequisites
        2. Creating your own Android application with an archetype
        3. Creating your own Android application
          1. Creating or modifying the AndroidManifest file
          2. Defining a simple Maven POM file
            1. Description tags
            2. Building with Maven plugin goals
        4. Declaring dependencies
          1. A compatibility library for API v4
            1. The final POM file with dependencies
        5. Useful instrumentations to test, sign, and zipalign
          1. The test profile
          2. Signing and zipaligning the package
          3. The bug detector (Lint)
        6. Eclipse integration
          1. Installing the Android connector
          2. Mavenized Android Project
        7. Summary
      14. A. Integrating Maven – Gradle
        1. What is Gradle?
        2. How Gradle works
        3. Creating a simple project with Gradle
        4. Gradle's project configuration
        5. Deploying on the Maven repository
        6. Creating the project's POM
      15. B. Maven Integration for Eclipse
        1. Importing existing Maven projects
        2. Checking out Maven projects from SCM repositories
        3. Building Maven projects
        4. m2e plugin settings
        5. Managing the POM
        6. Managing repository indexes
        7. Managing dependencies and plugins
        8. m2e connectors and lifecycle mapping
        9. Managing Java EE projects
      16. C. Maven Global Settings
        1. The settings.xml file
          1. Servers
          2. Proxies
          3. Profiles
      17. D. Maven Short References – Common Commands and Archetypes
        1. Commands
          1. Build
          2. Deploy and release
          3. Android
          4. Miscellaneous
        2. Archetypes
        3. Maven variables
        4. The default and clean Maven lifecycle
      18. Index