Reputation: 23
its regarding building an existing EAR using maven which contains multiple modules . we have a EAR project which contains web and jar projects in it total of 8 projects. ear was built using RAD and hence currently non of the project is having POM files . now i want to use maven for project. i want to use m2eclipse for creating POM's and build. plannig to creat a parent project and create modules under it, which includes ear project and others as well. so effective structure should be as below
workspace
>parent proj
>ear project
>web proj
>jar1 proj
>jar2 proj
but i have ear file containing all the projects and if i import ear in work space it create flate structure for all the projects as below
workspace
>web proj
>jar1 proj
>jar2 proj
concern is becuase of RAD project setup and .metadata files created by it in workspace. if i create parent project in workspace and then import ear in parent its a problem. please advise how can i do following
1> add indirection of parent project and below it have all the projects in ear
2>how to add ear project under parent which hold all the modules at build time
hope my situation and requirment is clear please advise on it
Thanks narayan
Upvotes: 0
Views: 818
Reputation: 23
thanks @crowne
instead of hierarchical structure i can use module approach.
to wrap all the existing projects, create a maven project of packaging type pom in same workspace then existing projects can be added as modules as below
../module1
../module2
../module3
path specified are alway relative to location of pom in which modules are declared.
Upvotes: 1
Reputation: 8534
You shouldn't have to import the ear into the parent project, the parent should just reference the ear as a module in its pom, and appear as a subdirectory within the parent.
Perhaps I'm unclear of what you mean by import.
The order that the modules are declared in the parent pom is the order in which they are built, so the ear should be the last module in the list as it has jar1, jar2 and web modules as dependencies.
web should be the second last module in the list because it presumably depends on jar1 or jar2 or both.
M2Eclipse has the ability to import a multi-module project structure that you described above as separate projects within the workspace, choosing this option prevents you from having to work on each individual module through the parent project and expanding all the way down.
This does not change the nested structure on disk, it merely presents the modules each as their own project, and the module directories are also visible in the parent project.
It also allows each module to be built individually, or a complete build can be performed by building the parent project.
Read about maven reactor in this question.
I suggest that before you tackle your main project try out a quick archetype, see http://docs.codehaus.org/display/MAVENUSER/Archetypes+List
The appfuse archetypes by Matt Raible are really good examples to work from, try the command below to create a skeleton structure:
mvn org.apache.maven.plugins:maven-archetype-plugin:2.0:generate -DgroupId=com.test.archetest -DartifactId=archetest -DarchetypeArtifactId=appfuse-modular-jsf -DarchetypeGroupId=org.appfuse.archetypes
Have a look at the general project structure, and then import it using M2Eclipse which will generate the eclipse project files..
You could also do this through mvn eclipse:eclipse
, but that won't give you the separate modules in your workspace.
Some project choose not to commit the eclipse project files, and rather have then generated from the pom through either of the methods mentioned above.
If you use the structure from the archetype given above, then you'll need to add an ear module to the parent project, this can be done through M2Eclipse.
Upvotes: 1