Reputation: 19635
I have a multi-level maven project with the following structure:
+ project
+ subproject1
+ 1_module1
+ 1_module2
+ 1_module3
+ 1_module3
+ subproject2
+ 2_module1
+ 2_module2
+ 2_module3
+ ...
+ subproject3
+ 3_module1
+ 3_module2
+ 3_module3
+ ...
+ packaging-project
The packaging-project
packages the build artifacts of the subprojects, and declares pom
type dependencies on subproject1
, subproject2
, and subproject3
. This (correctly) puts it last in the reactor build order, and therefore this works perfectly fine with a single-threaded build.
However, with a multi-threaded build (e.g. mvn -T4
) the packaging-project
build is executed by maven before all of the subproject modules are built.
One solution I've found is to explicitly list every module of every subproject as a dependency in packaging-project
. However, this is annoying and brittle -- every time a new module is created, it has to be listed explicitly in packaging-project
or risk breaking the build.
Another solution is to run packaging-project
via a profile, and then execute it explicitly in a separate mvn
call subsequent to the primary build. This is a good solution but requires an extra step at build time.
Is there another way to declare a build-order dependency between packaging-project
and every module of the listed subprojects, without explicitly declaring each submodule of each subproject as a dependency?
Upvotes: 5
Views: 1399
Reputation: 700
As far as I am aware the only way to make one module build being dependent on others is to make them a dependency of that build, which as you state means having a manually maintained list. Your description should give you the clue: that module is dependent on another.
Upvotes: 1