Maven Application got 5 Modules and 6 POM.xml files

此生再无相见时 提交于 2019-12-12 03:19:26

问题


I am working on existing Maven Project Which has got 5 modules like

 <modules>
    <module>sideware</module>
    <module>xmlmodule</module>
    <module>business</module>
    <module>service</module>
    <module>helper</module>
</modules>

Each Module has got a one POM.xml file as well as

and one main Pom.xml

I am using Eclipse to run the POM.xml files as Maven install

Please tell me do i need to run the Each POM.xml indivudally ??

Or can i run the Parent POM.xml file once ??

Thank you


回答1:


I think it is sufficient to run the parent POM. See the question What is the "reactor" in Maven? about the plugin that implements that for Maven. So you have the following options (at least):

  • Build the parent POM, which will build all modules as well.
  • Build a module individually, and it will build its dependencies automatically.

Here is a small experiment I have done on my own:

  1. Build automatically == false.

  2. Build a multi-module Maven project, and add there 2 modules.

  3. Insert some code into the modules.

  4. Run mvn install inside eclipse

As a result, I get the following output in the console:

[INFO] Scanning for projects...
[INFO] Reactor build order: 
[INFO]   MultiModuleExample
[INFO]   Unnamed - com.tsi.mli:sideware:jar:0.0.1-SNAPSHOT
[INFO]   Unnamed - com.tsi.mli:business:jar:0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Building MultiModuleExample
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] [install:install {execution: default-install}]
[INFO] Installing C:\projekte\setools-work\build\example-build-projekte\indigo-full\ws\multi-module-example\pom.xml to C:\Users\mliebelt\.m2\repository\com\tsi\mli\multi-module-example\0.0.1-SNAPSHOT\multi-module-example-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.tsi.mli:sideware:jar:0.0.1-SNAPSHOT
[INFO]    task-segment: [install]
...

The directory structure I have got is:

multi-module-example/
  business/
    src/
    target/
    .classpath
    .project
    pom.xml
  sideware/
    ...
  src/
  .project
  pom.xml


来源:https://stackoverflow.com/questions/7592857/maven-application-got-5-modules-and-6-pom-xml-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!