Dave,

Yes. Child poms should always explicitly name their parents.

The reason for this is that you might have a parent pom that exists in the repository and not in your directory structure. In order for maven to be able to find that pom, it will need the repository 'coordinates'. An example of where this type of pom would be useful is for companies that have multiple projects going which need to keep their dependency and plugin versions in sync.

Cheers,

Joe Hindsley


laredotornado wrote:
Thanks, Joe. So we do keep the version element within the <parent> element? Thus, the version appears in both the pom.xml in the root and also in the
webapp/pom.xml ?

  - Dave



Joe Hindsley wrote:
Hi Dave,

If you want to inherit the parent's groupId and version values, you simply remove them from the child's pom definition. In your case, the child pom would look like:

   <parent>
     <groupId>Myco.galc.capitol.tours</groupId>
     <artifactId>Myco-galc-capitol-tours</artifactId>
     <version>1.0-SNAPSHOT</version>
   </parent>

   <name>Myco GA Capitol Tours Webapp</name>
   <description>Myco GA Capitol Tours Webapp</description>
   <artifactId>Myco-galc-capitol-tours-webapp</artifactId>
   <packaging>war</packaging>

We also do this for our multi-module projects since it makes dependency management a little easier.

Hope this helps,

Joe Hindsley


laredotornado wrote:
Hi,

I'm using Maven 2.2.  In my maven project, I have this fragment in my
pom.xml at the project root ...

  <name>Myco GA Capitol Tours</name>
  <description>Myco GA Capitol Tours</description>
  <inceptionYear>2009</inceptionYear>

  <groupId>Myco.galc.capitol.tours</groupId>
  <artifactId>Myco-galc-capitol-tours</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
        
Then I have a webapp sub-folder and I have this in the webapp/pom.xml ...


  <parent>
    <groupId>Myco.galc.capitol.tours</groupId>
    <artifactId>Myco-galc-capitol-tours</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>

  <name>Myco GA Capitol Tours Webapp</name>
  <description>Myco GA Capitol Tours Webapp</description>
  <artifactId>Myco-galc-capitol-tours-webapp</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>


You'll notice I have "1.0-SNAPSHOT" hard-coded a couple of times in my
webapp/pom.xml.  Is there any way I can replace that with something that
will be automatically inherited from the parent?

Thanks, - Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to