HIBERNATE JBoss.org
 |  Register  | 
     
News 
About 
   Feature List 
   Road Map 
Documentation 
   Related Projects 
   External Documentation 
Download 
Forum & Mailinglists 
Support & Training 
JIRA Issue Tracking
Wiki Community Area


Hibernate Public Training Courses


Get Hibernate in Action eBook!


JavaWorld 2003 Finalist


Jolt Award 2004 Winner
      
Documentation > Community Area > Maven, XDoclet and Hibernate

Maven, XDoclet and Hibernate

The XDoclet for Hibernate plugin for Maven can be used to generate your mapping files.

You will need to add some properties to your project.properties.

maven.xdoclet.hibernatedoclet.destDir=${maven.build.dir}/xdoclet/hibernatedoclet
maven.xdoclet.hibernatedoclet.fileset.0=true
maven.xdoclet.hibernatedoclet.fileset.0.dir=${maven.src.dir}/java
maven.xdoclet.hibernatedoclet.fileset.0.include=**/*.java

By default the HibernateDoclet plugin generates mapping files for Hibernate 1.1. If you wish to create mapping files for Hibernate 2.0 add the following line to your project.properties file:

maven.xdoclet.hibernatedoclet.hibernate.0.Version=2.0

Now modify your maven.xml file to generate the mapping files when the code is compiled.

  <preGoal name="java:compile">
    <mkdir dir="${maven.xdoclet.hibernatedoclet.destDir}"/>
    <attainGoal name="xdoclet:hibernatedoclet"/>
  </preGoal>

If you now execute maven java:compile mapping files will be created in the target/xdoclet/hibernatedoclet directory.

It is helpful to keep these mapping files in the same place as the appropriate class files, this could be done by altering the maven.xdoclet.hibernatedoclet.destDir property, or by altering the maven.xml to copy the files appropriately i.e.

  <preGoal name="java:jar-resources">
    <echo message="${maven.build.dest}"/>
    <copy todir="${maven.build.dest}">
      <fileset dir="${maven.xdoclet.hibernatedoclet.destDir}"/>
    </copy>
  </preGoal>
                                                                                
  <preGoal name="test:test-resources">
    <copy todir="${maven.test.dest}">
      <fileset dir="${maven.xdoclet.hibernatedoclet.destDir}"/>
    </copy>
  </preGoal>
      

coWiki