Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
472 views
in Technique[技术] by (71.8m points)

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

I have 3 maven projects

  • WebComponents
  • DataComponents
  • ServiceComponents

When i build each of the projects i have to go into each folder and run mvn clean install on each of the projects.

I have looked into multi module projects and most of the resources i see suggest that i have to make a change to the structure of my existing projects.

Is it possible to have a new project that will build each of the independent projects without me having to make any changes to anything in the existing project including their individual pom files?

I can probably achieve this by writing a simple batch file that builds every projects but is it possible using Maven?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...