简体   繁体   中英

How to manage maven Dependencies as Group?

I got the following Maven module layout:

  • All
    • Sub-Project 1
    • Sub-Project 2
    • Sub-Project 3
    • Sub-Project N
    • Deliverable-Build
    • Dependency-Report

I manage all my submodule versions in the 'All' as managed dependencies. I reference those managed dependencies in the 'Deliverable-Build' module, to include them in the final zip archive.

The same dependency set needs to be referenced in the 'Dependency Report' module.

If the developer creates a new sub-module. He needs to manually put the new module into

  1. 'All' as managed dependency
  2. 'Deliverable-Build' as dependency
  3. 'Dependency-Report' as dependency

It is easy to forget one of those, so is there a way to simplify this? eg by once defining a 'dependency group' and reusing it in those three locations?

You cannot combine dependencyManagement and dependency lists into one whole. For no. 2 and 3, you could create a pom containing all relevant dependencies and reference it, as described in

How to use POMs as a dependency in Maven?

Let me add two comments:

  1. Perhaps you can create your Dependency-Report in the Deliverable-Build project, so that you reduce the duplication of logic. Eg listing all dependencies is done by the Maven-Site-Plugin.
  2. I would avoid to create too many modules.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM