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.
Rich seller
source share