Question

Is it possible to define ear module as parent module in a multimodular project?

I have the following project structure.

  • Module EAR-1 is an aggregation of ModuleA and ModuleB
  • Module EAR-2 is an aggregation of ModuleA and ModuleC

They both should generate ears to deploy.

I dont't want to have a dummy module for parent module. I want pack the global dependencies and the configuration in an existing project.

Which module/pom is the right one to put all these general information. This pom will be then my parent pom.

Was it helpful?

Solution

It seems that you have 2 differents concerns.

  1. Module A, B and C are partially re-used in 2 projects.
  2. You want to manage 2 ear projects (EAR 1 and 2) via a single one.

I imagine that A is a jar (providing services or common classes), and B and C are war, isn't it ?

If projects are really linked toghter, I mean you build them together, you deliver them at the same time, when you promote a release, you do it on all project, I would recommend the following structure. I 'd never tested that, so I don't know if there's drawback.

/parent
+--pom.xml
|
+--/moduleA
|  +--pom.xml
+--/moduleB
|  +--pom.xml
+--/moduleC
|  +--pom.xml
+--/app-ear1
|  +--pom.xml
+--/app-ear2
|  +--pom.xml
\    

Consider there is no dummy parent project until you collect and share information or management within.

The parent one will gather module, obviously, and dependencyManagement (in order to ease the management of dependencies versions) and pluginManagement. It will also contains team, CI management, etc. Indeed, it will contain all common informations.

Then, when you want to build the whole, use mvn package on parent. When you'll release it, juste execute mvn release:perform on parent.

If you want to use / distribute them separatly (ear 1 from one side, and ear 2 from another), you may not have the same structure.

/corporate
+--pom.xml


/moduleA
+--pom.xml


/parent-1
+--pom.xml
|
+--/moduleB
|  +--pom.xml
|
+--/app-ear1
|  +--pom.xml
\


/parent-2
+--pom.xml
|
+--/moduleC
|  +--pom.xml
|
+--/app-ear2
|  +--pom.xml
\

Corporate would be extended by parent1 and parent2, and it would have the same role than a parent in case 1 regarding dependencyManagement, pluginManagement and informations like CI. Consider that you couls also do it in the first case.

Take a look here : Maven2: Best practice for Enterprise Project (EAR file). You may find more informations.

In both cases, be careful if you use WTP with eclispse : Multi Module Maven2 Project with WTP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top