I have the following project:
5(+) jars, each building specific components, with both common dependencies and jar-specific dependencies
1 war (which bundles these jars, and their dependencies)
1 ear (which holds the war and only the war)
How do I fit all of this nicely into maven?
I had the following setup:
project-root.pom
|- generic jar dependency 1
|- generic jar dependency 2
|- modules
| - jar 1 (uses generic dependencies, and a couple of others)
| - jar 2 (uses generic dependencies, and a couple of others)
| - war project (uses generic jars, and jar 1 and 2)
| - ear project
But this doesn’t work, as the ear project will include the generic jar dependencies of the parent in the /lib folder.
How can such a project be set up nicely in maven?
Update
I kinda worked around it by having a root pom which declares modules for jar1, 2, the war and the ear project, but only having jar1, jar2, and the war inherit from the parent pom. The ear project doesn’t. Is this proper practice?
The structure you scribbled down gives me a different feeling about your project structure. Let me describe that a little bit. If i see a structure like the following i would assume:
But you described in the text the relationship of the module in a differnt way:
With the above structure you can simply define the dependencies in the war like depending on jar-1, jar-2. The ear depends on the war only. The jar-1 might depend on the generic-jar depency 1 and so on. The levels give the observer a different impression of the project as it really has. So you structure should represent you dependency structure. I’m not sure if this the correct structure for your project but represent the structure (folder structure) as your dependencies direct you.