0

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

  • parent
    • m1
    • m2
    • sub-parent (a project that doesn't generate an artifact, but a folder with resources for m3 to use)
    • m3

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?

Imaskar
  • 2,773
  • 24
  • 35
  • First if you have resources in a different module than they are used this is the first mistake...furthermore if you say "sub parent" does that mean you have packaging "pom" ? – khmarbaise May 18 '18 at 17:19
  • Every project here has a `pom.xml`. The sub-parent one gathers artifacts from some other modules and signs them. m3 copies the result to itself. If m3 would do that, unnecessary jars would come along. – Imaskar May 18 '18 at 17:23
  • What do you mean by "gathers" artifacts? And sign them? Can you make and example project which shows the given situation? Apart from that if m3 builds earlier than sub-parent your dependencies between the modules are wrong. – khmarbaise May 18 '18 at 17:26
  • Gathers=copies to its folder by declaring them as dependencies. Then maven-jarsigner-plugin is fired over that folder. This strucure is kinda ad-hoc to be able to build project as a descktop app and as a jnlp web app. I'll try to make an example, but it'll take a while. – Imaskar May 18 '18 at 17:40
  • https://github.com/Imaskar/build-order – Imaskar May 18 '18 at 18:22
  • 1
    If you need to be sure having build sub-parent before m3 you simple have to define a dependency to sub-parent in m3 which makes sense cause the sub-parent will be used in m3..... – khmarbaise May 22 '18 at 10:17
  • if defined as a dependency, it fails with something like "could not resolve sub-parent.jar", because sub-parrent does not produce jar artifact. – Imaskar May 22 '18 at 11:56

1 Answers1

2

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>
Imaskar
  • 2,773
  • 24
  • 35