Maven - How to build multiple Independent Maven projects from one project

后端 未结 2 768
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 14:26

I have 3 maven projects

  • WebComponents
  • DataComponents
  • ServiceComponents

When i build each of the projects i have to go into eac

相关标签:
2条回答
  • 2020-12-13 14:59

    You're looking for Maven aggregation without inheritance. As shown in the referenced page, you just create a new POM whose packaging is "pom" and which has a list of "modules". A module is a relative path to another Maven project:

    <project>
      ...
      <packaging>pom</packaging>
      ...
      <modules>
        <module>foo</module> <!-- module is in a subdirectory of this project -->
        <module>../bar</module> <!-- module is a sibling to this project -->
        <module>../../../other-projects/baz</module> <!-- somewhere else entirely -->
      </modules>
    </project>
    

    Default behavior when building such a pom--known as an "aggregator"--is to build all of the modules as if you'd executed Maven in each module directory with the same arguments.

    0 讨论(0)
  • 2020-12-13 15:02

    If you add an aggregator project in the directory above the three projects that names them as modules (module name = subdirectory name), it will build them without needing any changes in their own POMs. They don't need to reference it as a parent.

    0 讨论(0)
提交回复
热议问题