Maven multi-threaded build: force a packing module to run

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 

packaging-project packs sub packaging-project assembly artifacts and declares pom type dependencies on subproject1 , subproject2 and subproject3 . This (correctly) puts it in the assembly order of the reactor, and therefore it works great with single-threaded assembly.

However, with multi-threaded builds (e.g. mvn -T4 ), packaging-project builds are done with maven before . All sub-project modules are built.

One solution I found is to explicitly list each module of each subproject as a dependency in the packaging-project . However, this is annoying and fragile - every time a new module is created, it must be explicitly specified in the packaging-project or at risk of assembly destruction.

Another solution is to run the packaging-project through the profile, and then execute it explicitly in a separate mvn call after the initial build. This is a good solution, but requires an extra step during assembly.

Is there any other way to declare an assembly order dependency between the packaging-project and each module of the listed subprojects without explicitly declaring each submodule of each subproject as a dependency?

+4
source share
1 answer

As far as I know, the only way to make one assembly of a module dependent on others is to make them dependent on this assembly, which, as you say, means having a list maintained manually. Your description should give you a clue: this module depends on another.

0
source

Source: https://habr.com/ru/post/1502857/


All Articles