Apache Maven Dependency Management

Book description

With this guide, you can easily manage your Java or Java EE dependencies. It takes you from basic to advanced dependency management techniques in easy, logical steps. Swap your homebrew processes for automated solutions.

  • Improve your productivity by efficiently managing dependencies.
  • Learn how to detect and fix dependency conflicts
  • Learn how to share transitive relations and to visualize your dependencies

In Detail

Managing dependencies in a multi-module project is difficult. In a multi-module project, libraries need to share transitive relations with each other. Maven eliminates this need by reading the project files of dependencies to figure out their inter-relations and other related information. Gaining an understanding of project dependencies will allow you to fully utilize Maven and use it to your advantage.

Aiming to give you a clear understanding of Maven’s functionality, this book focuses on specific case studies that shed light on highly useful Maven features which are often disregarded. The content of this book will help you to replace homebrew processes with more automated solutions.

This practical guide focuses on the variety of problems and issues which occur during the conception and development phase, with the aim of making dependency management as effortless and painless as possible. Throughout the course of this book, you will learn how to migrate from non-Maven projects to Maven, learn Maven best practices, and how to simplify the management of multiple projects. The book emphasizes the importance of projects as well as identifying and fixing potential conflicts before they become issues. The later sections of the book introduce you to the methods that you can use to increase your team’s productivity. This book is the perfect guide to help make you into a proud software craftsman.

Table of contents

  1. Apache Maven Dependency Management
    1. Table of Contents
    2. Apache Maven Dependency Management
    3. Credits
    4. About the Author
    5. About the Reviewer
    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. Basic Dependency Management
      1. Nomenclature
        1. Reminders on Maven origins
        2. Dependency
      2. Long and short designations
        1. Long designation
        2. Short designation
      3. Visualizing dependencies
      4. Transitive dependencies
        1. The concept of transitivity
        2. Resolution
        3. Exclusions
        4. Optional dependencies
      5. Parents/modules
        1. Parent POM
        2. Modules
      6. Version ranges
      7. Summary
    9. 2. Dependency Mechanism and Scopes
      1. Scopes
        1. Nomenclature of scope
          1. Compile
          2. Provided
          3. Runtime
          4. Test
          5. System
          6. Import
        2. Scope overlay rules (via transitive dependencies)
          1. The dependencyManagement tag
            1. First case study
            2. Second case study
          2. The import scope
        3. Modules and submodules (advanced)
          1. Maven Reactor
            1. Reactor sorting
          2. Reactor options and the Reactor plugin for Maven 2
        4. Management of dependencies in folders
          1. The dependencies in their folders
          2. Nonarchive files
        5. Summary
    10. 3. Dependency Designation (advanced)
      1. The type tag
        1. The classic cases
      2. Creating a new packaging/type
        1. Case study
          1. The first step – Maven plugin
          2. The second step – call the plugin
      3. The Classifier
      4. The dependency plugin
        1. The analyze goal
        2. Classpath
        3. Other goals of dependency
        4. Other miscellaneous plugins
        5. The Enforce plugin
          1. The dependency convergence
          2. Banned dependencies
          3. Other rules
        6. Tattletale
          1. Dependencies
          2. Reports
          3. Archives
        7. Dependency, enforce, and tattletale – conclusion
      5. Dynamic POMs and dependencies
        1. Effective POM and settings
        2. Dynamic POM
        3. Case study
        4. A quick and dirty solution
        5. A clean solution
          1. With properties in command lines
          2. Profiles and settings
          3. Dynamic POMs – conclusion
      6. Summary
    11. 4. Migration of Dependencies to Apache Maven
      1. Case study
      2. Setting the folders
      3. Introducing Maven with standard libraries
        1. Available POM
        2. Unavailable POM
          1. Disclosing information from Manifest.MF
          2. Online tools
          3. Checksums
        3. Next steps
      4. Non-Maven standard libraries
        1. State
          1. Quick and (very) dirty
          2. (A bit) slower and (far) cleaner
      5. Summary
    12. 5. Tools within Your IDE
      1. Case study
      2. IntelliJ IDEA
        1. XML with XSD completion
        2. Module Dependency Graph
        3. Dependency addition
          1. Dependency addition from Java code
          2. Dependency search and generation within a POM
        4. Conclusion on IntelliJ IDEA
      3. Eclipse
        1. Dependency view
        2. Dependency Hierarchy view
        3. Effective POM view
        4. Maven Repository view
        5. Conclusion on Eclipse
      4. NetBeans
        1. Overview
        2. Dependency addition
      5. Summary
    13. 6. Release and Distribute
      1. Best practices before release
      2. Fixing conflicts with tier-parties
      3. Releasing the source code
        1. The Maven Release plugin
      4. Delivering artifacts and distributions
        1. Artifacts
        2. Release distribution
          1. A simple case
            1. Compiling both Java and Groovy sources
          2. A complex case
            1. Study case
            2. Following the process
            3. Conclusion
      5. Distribution management
      6. Summary
    14. A. Useful Public Repositories
      1. Maven Central
      2. iBiblio
      3. JavaNet
      4. JBoss
      5. CodeHaus
      6. Apache
      7. OSS Sonatype
    15. Index

Product information

  • Title: Apache Maven Dependency Management
  • Author(s):
  • Release date: October 2013
  • Publisher(s): Packt Publishing
  • ISBN: 9781783283019