Maven - Multiple Assemblies in a Single Pump

Is it possible to build multiple artifacts in one POM file? This is not about creating multiple assemblies, but in artifacts that have different assemblies and dependencies, but relate to the same source.

For example, one artifact that I need to collect is a WAR file that excludes certain AspectJ files from the assembly, and another is a JAR file that requires these aspects to be woven during assembly.

Now I have 2 pom.xml that work on 2 copies of the same source to create the necessary artifacts. Can this be done in one POM?

+6
maven-2
source share
2 answers

As a rule, bad practice tries to do what you need, although it can be done with profiles and assemblies, which I would recommend against.

This is how I approach him.

Separate the code in the jar project and configure the jar project to use the aspectj compiler plugin. Making a war project depends on a jar project, and a jar project depends on aspectjrt. The jar dependencies that you want to exclude can be specified as the "provided" area, so they will not be included in the assembly or excluded by setting the jar dependency to exclude these transitive dependencies (see the Transient Dependence section of the Documentation on dependency mechanisms .

When the war is built, any compilation-dependent dependencies (and their transitive dependencies) will be included in the WEB-INF / lib directory (i.e. the aspectjrt parameter will also be included).

If you need to collect both projects at once, define a pom aggregator and specify both banks and military projects as modules.

+9
source share

hmm, I think the easiest way is super-pom using syntax. It seems like it would be easier to maintain than a single estate with two goals.

0
source share

All Articles