aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes What is the best practice to handle multiple module in Maven ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "What is the best practice to handle multiple module in Maven ?" Watch "What is the best practice to handle multiple module in Maven ?" New topic
Author

What is the best practice to handle multiple module in Maven ?

Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 188
Good day,

My project involve two module, there are web module and EJB module. my question are below:

1. What is the best practice to handle multiple module in maven? is there any sample i should refer?
2. If there is EJB module involve in the project, i need to package it into .ear file? .war file will not help in my case, am i right?
3. I'm using eclipse with m2m plugin, should i create a new maven project with "maven-archtype-quickstart" or "maven-archtype-j2ee-simple" or some other archtype to handle above scenario?

Thanks for guidance!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

My advice:

1) Do separate Maven projects, one for the EJB JAR, the other for the WAR.

2) Maybe. Which version of Java EE are you targeting? The latest versions let you package EJBs into your WAR. If you still want an EAR, do it as a third Maven project.

3) I never use an archetype but just select "create a simple Maven project" and select the correct packaging type, but I do that mainly because I already have example POMs that I can use (I completely overwrite the generated POM) and I have been too lazy to convert them into archetypes!


JBoss In Action
Shiv Vishwakarma
Greenhorn

Joined: May 29, 2007
Posts: 22

Hi Peter,

I have a smilar situation where-in I have to mavenize an existing ear application that has ejb, web, and one another plain java project for some properties file.
When I looked at the existing ear, it has two jars, one for ejb and one for properties project and one war file.
Now since I am have to mavenize this application. I am totally confused and not able to get to any point.
It would appreciate if your help me with the steps to mavenize this application.

My Approach:
1. create a parent maven project, with build type as POM.
2. create another web project, using maven archtype for .war (it is maven module for parent maven project)
3. create another plain java project again using maven archtype for bundling as .jar.
4. create one last project for ejb to be packaged as .jar

Note: this application will be deployed in Websphere.

Thanks,
Shiv


Vishwakarma, Shiv
SCJP 1.4, SCWCD 5
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

I would have four Maven projects - one for the JAR with properties, one for the war, one for the ejbs, and the final for creating the ear. I don't see why you would need a parent pom (or did you mean a master pom?), at least not just for this particular situation. Then I would configure Jenkins to build them in the proper order (that is, rebuild the ear if any of the components get rebuilt).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the best practice to handle multiple module in Maven ?