mavenmaven-3maven-dependency-pluginparallel-builds

Maven parallel build wrong order


I'm trying to speed up my maven build with parallel processing. The project is multi-modular with nested modules. The structure is like:

Edit: now I even see, that at least once m3 did its copying goal before sub-parent even starts, thus used the result of previous build before sub-parent started its clean.

If I do mvn dependency:tree -Dverbose -Dincludes=my.packages.* I see that sub-parent is correctly listed in the dependencies of m3. However, sometimes (rarely) parallel build mvn -T 1C clean install fails, because m3 build is being executed earlier than sub-parent.

Is there a workaround to enforce order? I know you can't set it directly. The thing is, I cant put sub-parent as a dependency to m3, because it doesn't have an artifact. And I don't sure I need it, because dependency tree shows that maven knows about this dependency.

Edit: I've added a sample minimal project. https://github.com/Imaskar/build-order . Except that sub/keystore need to be swapped for real one. Interestingly, here dependency tree doesn't show sub as a dependency of m3. How to tell m3 to depend on it, despite the fact that sub is not built to a jar file?


Solution

  • Ok, I figured it out some time ago, but wanted for anyone to take the credit. The solution is declaring a dependency with

    <type>pom</type>