tags:

views:

49

answers:

1

I have two independent gwt based projects using pom aggregation , so four projects(or modules) in total. Tree looks like this .

Reactor1(just pom.xml)  
|-- war1 (gwt related stuff)  
`-- jar1 (Spring , hibernate etc)

and an other project but structure is exactly the same

Reactor2(just pom.xml)  
|-- war2 (gwt related stuff)  
`-- jar2 (Spring , hibernate etc)  

While being independent they are part of same business project . One is say reporting project and other one is CMS .I want to centralize all the major dependencies say just for example GWT , Spring , Hibernate (as obviously the core ones) . So I am thinking of a tree like this .

Parent(GWT ,SPring,Hibernate) 
|-- Reactor1 (just pom.xml)
|   |-- war1 (gwt stuff from parent)
|   `-- jar1 (Spring , hibernate etc from parent)
`-- Reactor2 (just pom.xml) 
    |-- war2 (gwt related stuff from parent)
    `-- jar2 (Spring , hibernate etc from parent)  

Can some one please advice me if I am on the right path . I am just thinking that war file this is also getting the dependencies that it did not need (like spring and hibernate etc) like wise jars are getting dependencies like gwt which they do not need . Does it matter or not ? or am I on a tangent here :) . Any advice would be really appreciated . (I know my formatting is looking horrible but I hope it makes sense)

A: 

Can some one please advice me if I am on the right path.

I think that you are definitely on the right path. Just create this Parent aggregating pom and declare the GWT, Spring, and Hibernate dependencies under the dependencyManagement element.

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.acme.business</groupId>
  <artifactId>parent</artifactId>
  <version>1.0.0</version>
  ...
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.5.5-Final</version>
      </dependency>
      ...
    <dependencies>
  </dependencyManagement>
  ...
</project>

Then, in a child project, you can add a dependency on Hibernate Core using the following declaration:

<project>
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.acme.business</groupId>
    <artifactId>reactor-1</artifactId>
    <version>1.0.0</version>
  </parent>
  <artifactId>jar1</artifactId>
  ...
  <dependencies>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
    </dependency>
  </dependencies>
</project>

References

Pascal Thivent