This is a classic example of how maven handles its artifacts. And the key to explain this behavior is the local repository.

When you build your multiproject for the first time, what happens is maven will build jar1 first and update your local repository copy since jar2 depends on it. Then maven will build jar2 which will then use the updated copy of jar1 in the local repository.

But when do a change in jar1, then build jar2, what happens is when building jar2, it will use the jar1 copy in the local repository which has not been updated. To achieve what you want, after doing some changes in jar1, do a "mvn install" on jar1 first, then when you do "mvn install" on jar2, it will then fail as that is what you want.

Just remember to install the project after your edits, so other projects can see what you've changed in the local repository.

^_^



Michael Fiedler wrote:

I have the following structure where JAR2 depends on JAR1.

Parent
|- pom.xml
|
|- JAR1
|   |- pom.xml
| |
|- JAR2
|   |- pom.xml


The JAR1 and JAR2 projects are developed concurrently, and pom.xml of JAR2 lists JAR1 as a dependency.
The parent pom.xml lists JAR1 and JAR2 as modules.

All of this builds fine the first time when I execute 'm2 install' on the 
Parent pom.xml file. But if I make a change to a class in JAR1 which would 
cause a compile error in JAR2, this compile error is not being caught when I 
run 'm2 install' at the parent pom.xml. The only way I can get this to work is 
to run 'm2 clean install', and then I am able to see the failure in JAR2. But I 
don't want to run 'clean' every time I do a build.

Has anyone else come across this issue? Any workarounds?

Thank you,
Michael Fiedler


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to