maven - advice on usage of multi-modules (jar, war, …) project

别说谁变了你拦得住时间么 提交于 2019-12-23 04:46:14

问题


I have the following Maven organization:

- ./pom.xml (top-level project, which defines the 4 modules below)
   - ./a/pom.xml (jar)
   - ./b/pom.xml (jar)
   - ./c/pom.xml (war)
   - ./d/pom.xml (war)

So far, I have been using Maven as following (all executed in the root):

1. mvn clean compile install
2. mvn tomcat7:redeploy -pl c
3. mvn tomcat7:redeploy -pl d

Although this works perfectly, I am not really sure if this is the preferred way. In the first step, I am installing all projects, but actually, only the jar projects a and b should be installed. There is no need to install the c and d projects.

Although it doesn't hurt installing c and d, is there a better usage of Maven to avoid this? I can always manually install a and b, but this ofcourse conterfeits the benefits of modules (auto-detection of dependency order, to name one benefit).


回答1:


compile and install are both part of the default lifecycle, so there's no need to call compile. And you don't need to install files in case dependencies are part of the reactor (i.e. all the maven projects being built). Instead package is good enough, although I prefer verify in case there are integration-tests. You could probably do this as well: mvn verify tomcat7:redeploy -pl c -am, where -am triggers projects of the multimodule project which are required to build c.



来源:https://stackoverflow.com/questions/33196340/maven-advice-on-usage-of-multi-modules-jar-war-project

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