HIBERNATE  |  Register  | 
      SEARCH: 
   
News 
Features 
Documentation 
   Related Projects 
   External Documentation 
Download 
Forum & Mailinglists 
Support 
JIRA Issue Tracking
Wiki Community Area


JBoss.org



middlegen

JIRA Issue Tracking




      
Documentation > Community Area > Maven, XDoclet and Hibernate

Maven, XDoclet and Hibernate

The XDoclet 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">
    <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 web collaboration