views:

25

answers:

2

Today, I've been looking at Maven Multi-Module and EAR projects and they seem quite similar in that both seem to define an assembly of a collection of other projects - it almost seems like an EAR project should just be an alternate packaging for a multi-module project.

Have I misunderstood something? Or do these types of project work together?


Following Pascal's answer: Updated to clarify the question, hopefully that will help if it's not easy to understand; sorry it's maybe not phrased very well, the ear stuff is kinda new to me...

So say I have two projects, one producing a war and the other a utility jar. The war depends on the jar and I need to package them up into an ear for deployment. Should I use a project with a pom packaging type? I guess I have to use a project with an ear packaging type somewhere to produce the final artifact, so am I best using just a project with ear packaging, or projects with both pom and ear? If both, how?

A: 

Have I misunderstood something? Or do these types of project work together?

I'm not sure I understood the question but I'm tempted to answer that they work together:

  • Aggregating modules allow to, well, aggregate modules and they must have a pom packaging (and only pom modules can have nested projects).
  • An EAR module is just a module with an ear packaging (and has specific bindings) and can be part of a multi-module project.

Both have different purposes. But they work together.

Pascal Thivent
A: 

EAR projects work just fine as part of a larger aggregated project. In those cases when you do not want to have the EAR be a separate project; you could always create the file via an assembly.

This approach makes sense in some cases. Usually where you have to create multiple versions of the EAR or when you would like to create the deploy a large EAR file but have no need to keep the artifact once created.

I've used this approach to deal with a corporate standard that requires all deployable to be EAR files, even when the app is a single WAR file. An assembly can create the EAR with its single WAR file and deployment descriptors.

sal