1

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? e.g. by once defining a 'dependency group' and reusing it in those three locations?

gorootde
  • 4,003
  • 4
  • 41
  • 83
  • Have you declared `all` pom as parent of rest of the modules? – Avinash Feb 13 '17 at 10:01
  • Yes, `all` is the parent (see indentation) – gorootde Feb 13 '17 at 10:04
  • Possible duplicate of [Maven multi-module: aggregate common dependencies in a single one?](http://stackoverflow.com/questions/6086774/maven-multi-module-aggregate-common-dependencies-in-a-single-one) – Avinash Feb 13 '17 at 10:09

1 Answers1

0

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. E.g. listing all dependencies is done by the Maven-Site-Plugin.
  2. I would avoid to create too many modules.
Community
  • 1
  • 1
J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142