问题
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