Reputation: 3
I have a maven project that consists of a couple of modules. The main structure and setup is this:
/project/pom.xml
: packaging=pom, lists all sub-modules, version: TRUNK-SNAPSHOT
/project/core-module/pom.xml
: packaging=jar/project/war-module/pom.xml
: packaging=war, depends on core-module
with ${project.version}
I use IntelliJ for development if that somehow matters.
When I now develop/run/debug the war-module
and meanwhile I change code in the core-module
things get out of hand. The running war-module
application (running via jetty:run-exploded
) uses the core-module
which is "installed" in my local ~/.m2/ repository
instead of the current build. It doesen't matter if I do a "rebuild project" in IntelliJ or a mvn clean
before running.
My question is: do I have to mvn install
each time, can I circumvent the installed packages or do I have to change packaging options?
Upvotes: 0
Views: 212
Reputation: 7858
Making a long story short, the answer is: YES, in a multi-module project you have to run mvn install
every time so the dependencies of your war-module
get compiled and installed in your local repository.
However, for local testing I usually recommend to make use of the IDE features to test our local changes. With IntelliJ is really easy to configure and it supports a lot of different application servers.
The reason for this is: Imagine working on a large team, using an enterprise shared repository to hold your common dependencies without the need to publish them to Maven central. If any of your colleagues has made changes to core-module
, committed them and make them available through your internal shared repo then Maven will download that dependency and then use to run the Jetty plugin.
The good side of this is that you'll be testing with last version of those dependencies, the bad side of it is that the code of those dependencies is not the same as the one in your working copy.
Upvotes: 1