0
votes

I've currently got a parent pom that declares two modules: an ear and a war. The ear is reliant on the war (and declares a dependency for it with group/artifact id and packaging type).

When packaging from the parent pom level, the reactor picks up both artifacts and properly packages the war into the ear as you would expect. However, when packaging from the ear's project pom (despite having declared elements in both projects pointing to the parent pom) the ear fails to find the war artifact.

I know that when packaging at the ear level Maven finds its way to the parent correctly, but does it not then iterate down to the various modules that the parent contains to pick up artifacts?

Thanks :)

2

2 Answers

0
votes

That's the way Maven works. It's OK. When resolving dependencies, Maven looks for them in reactor, then local repository, then remote repos. So, when doing a build from a parent project level, both projects are in the reactor, so EAR can pick WAR easily. (To be specific, it's not because the parent-child relation, but the fact they are modules.) However, when you build an EAR module in isolation, reactor can't provide WAR as well as local repo as well as remote repos. If you install WAR module into local repo by mvn install and then try to build EAR, WAR artifact will be found using local repo.

0
votes

Sounds like your parenting structure is broken, if the EAR depends on the WAR then it should be a child module.