2

This is similar to the asked and answered question Maven test dependency on multi module project. However, this has nothing to do with the test phase, instead I'm having problems with package.

I have a multi-module project something like:

root
|
|-parent-client
| |
| |-client-1
| |
| \-client-2
|
\-parent-server
  |
  |-server-1
  |
  |-server-2
  |
  |-server-3
  |
  \-server-4

My dependencies are client-1 -> client-2 -> server-1 -> server-2 -> server-3 -> server-4, which is to say that client-2 depends on server-1, server-1 depends on server-2, and so on. Each is scoped to compile.

So the problem is that when I run mvn clean package in the root, I get a compilation failure in server-2 that package server-3 does not exist.

When I run mvn clean compile followed by mvn package in the root, it runs through without issue.

It always fails at the same module when it fails.

My understanding of the Build Lifecycle is that compile package is redundant since package includes the compile lifecycle.

The project is more complex, with a total of 41 modules, two parents and one root. Creating a simple example inevitably works as expected.

I'm stumped as to how I should proceed.


Update 2015-10-25

Turns out I was wrong about the order of commands for success. I've updated my question and the description, and included debug output per Michael-O's request:

<snip/>

[INFO] --- maven-ejb-plugin:2.3:ejb (default-ejb) @ terradatum-systemconfig ---
[INFO] Building EJB terradatum-systemconfig-4.8.1-SNAPSHOT with EJB version 3.0
[INFO] Building jar: /home/rbellamy/Development/Terradatum/metrics-project/metrics-server/systemconfig/ejb/target/terradatum-systemconfig-4.8.1-SNAPSHOT.jar
[INFO] Building EJB client terradatum-systemconfig-4.8.1-SNAPSHOT-client
[INFO] Building jar: /home/rbellamy/Development/Terradatum/metrics-project/metrics-server/systemconfig/ejb/target/terradatum-systemconfig-4.8.1-SNAPSHOT-client.jar

<snip/>

[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building terradatum-payment 4.8.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ terradatum-payment ---
[INFO] Deleting /home/rbellamy/Development/Terradatum/metrics-project/metrics-server/payment/ejb/target
[INFO] 
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ terradatum-payment ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ terradatum-payment ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to /home/rbellamy/Development/Terradatum/metrics-project/metrics-server/payment/ejb/target/classes
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING : 
[INFO] -------------------------------------------------------------
[WARNING] bootstrap class path not set in conjunction with -source 1.6
[INFO] 1 warning
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/rbellamy/Development/Terradatum/metrics-project/metrics-server/payment/ejb/src/main/java/com/terradatum/common/payment/PaymentRemoteDelegate.java:[13,42] package com.terradatum.common.systemconfig does not exist

<snip/>

Update 2015-11-16

After much refactoring the build no longer fails in the same place. I've seen it fail in a similar way, consistently, but the location of the failure moves around. I am not running multiple threads, but it seems very clear to me there's a race somewhere in which an obviously available package (absolutely located and reachable in my ~/.m2/repository local cache, and added to the classpath) is not visible to the Maven compiler.

And knowing what I know about race conditions, I have no idea how I would file a bug report of any substance given I can't offer anything more than supposition and finger pointing.

Community
  • 1
  • 1
rbellamy
  • 5,683
  • 6
  • 38
  • 48
  • Debug output might help. – Michael-O Oct 25 '15 at 21:45
  • If you have such errors like server-3 does not exist...your pom's seemed to be not correct, cause you don't define the correct dependency or you missed to define a parent or a module....Apart from your message "package ..." does not exist.. – khmarbaise Oct 27 '15 at 07:39
  • @khmarbaise - if my modules and dependencies are wrong, why does the compile succeed? – rbellamy Oct 28 '15 at 15:45
  • Because your dependencies are picked up from the local repository or from a repository manager which you might have configured...A final test for such kind is. clean the local repository completely and than just try `mvn clean package` ...I assume than your build will fail... – khmarbaise Oct 28 '15 at 18:54
  • You are correct, `mvn clean package` does fail. I've been over the modules and their dependencies with a fine-tooth comb, and I must be missing something obvious as the one that fails is structurally identical to those that succeed. Furthermore, as you can see from my debug output, the artifact in question `terradatum-systemconfig` is being packaged BEFORE the error. – rbellamy Oct 30 '15 at 16:42
  • And the artifact in question is part of the classpath during compilation. I'm seriously wondering if this is some kind of race condition, except it fails in the same place every time. The fact that it does fail in the same place every time lends credence to the claim by @khmarbaise that I've got something mis-configured. I am seriously at a loss on how to identify what I've done wrong... – rbellamy Oct 30 '15 at 16:56

0 Answers0