aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes JSF2 with JPA2 module - how can i create 2 projs using Maven (Eclipse) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "JSF2 with JPA2 module - how can i create 2 projs using Maven (Eclipse)" Watch "JSF2 with JPA2 module - how can i create 2 projs using Maven (Eclipse)" New topic
Author

JSF2 with JPA2 module - how can i create 2 projs using Maven (Eclipse)

nicolas diogo
Greenhorn

Joined: Nov 03, 2011
Posts: 20
hi,

i am not very versed with Maven.
so i am trying to achieve something that i understand the process.

in Eclipse, i have created a JSF2 project, and i would like to have a second project (child/module) for the JPA2 (DB logic).
if i try creating a new project as:
new Maven Module

it will give an error saying:
The parent project must have a packaging type of POM

i have tried to understand this document here:
https://maven.apache.org/plugins/maven-eclipse-plugin/reactor.html

it seems that i am not able to understand the explanation.

the aspects of packaging the parent project into POM, and adding this POM reference to the child/module project seems counter intuitive.
as i expected these references to the other way around.

could i ask for some clarification here?

thanks,





Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
Don’t know, but this question is too difficult for “beginning”, so I shall move it. Not sure where: lte’s try the Maven forum.
nicolas diogo
Greenhorn

Joined: Nov 03, 2011
Posts: 20
thanks for moving into a better area
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

It sounds like you referenced a parent in your POM. That is, you pom.xml has a <parent> section. If you do that, the parent artifact must be of package type "pom".

Maven supports two different POM hierarchies:

One is the master/subproject hierarchy. In this hierarchy you have a master POM that, when you run a build, will also build submodules. This hierarchy is defined by placing a <modules> entry into the master POM. The mast and submodule POMs can use any packaging type. Example: a master POM with packaging type of "ear" might have submodules of type "jar" (for an EJB project) and "war" (for the web app project).

The other is the parent/child hierarchy. In this hierarchy the parent defines a common build structure (plugins, dependencies, properties, etc) that is then used by one of more child projects. This hierarchy is defined by placing a <parent> entry into the child POM. In this case the parent POM must use a packaging type of "pom" because that POM doesn't define any artifact other than itself. Example: you might have a parent POM that defines all of the typical things that you need in yoru environment to build a JSF web apps, this would include the JSP library, perhaps some javascript libraries, JUnit, plugins that define the WAR contents, etc, etc. Then each individual JSP web app would reference that parent POM (thus inheriting all of its app definition), and would then need to define very few things. (At work we make extensive use of parent POMs so that every artifact of a specific kind is built exactly the same way; in addition most of our specific POMs for an app have almost no information in them except for maybe some additional dependencies - we end up with very short POMs)

At work I constantly preach against people confusing the two hierarchies (lost of example on the web mix the two hierarchies thus adding to the confusion). My recommendation is to never use the master/submodule hierarchy - if you need that build it into Jenkins. But use the parent/child relationship everywhere that you can; it significant reduces rework (I wholly support the DRY principle - Don't Repeat Yourself).

The free online book Maven: The Definitive Guide has a good explanation of the two hierarchies.


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF2 with JPA2 module - how can i create 2 projs using Maven (Eclipse)