-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Help - sample Ant build.xml for new Hibernate Tools, please?
PostPosted: Wed Mar 22, 2006 2:50 am 
Beginner
Beginner

Joined: Mon Aug 15, 2005 9:00 pm
Posts: 37
Hi

I am new to Ant. Can someone show me a simple working (for you) ant build.xml for use with HibernateTools-3.1.0.beta4. I can replace my paths/jars into it.

Thx
Chuck


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 4:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Something along the lines of this;

Code:
<target name="hbm2java" description="Generate .java from .hbm files.">
     
  <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
    <classpath refid="classpath.common"/>
  </taskdef>
     
  <hibernatetool destdir="${src.dir}">
    <configuration>
      <fileset dir="${src.dir}">
        <include name="**/hbm/*.hbm.xml"/>
      </fileset>
    </configuration>
    <hbm2java generics="false"/>
  </hibernatetool>

</target>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 7:11 am 
Beginner
Beginner

Joined: Wed Mar 22, 2006 4:33 am
Posts: 20
Location: Berlin, Germany
Here is one of my basic ant build files to generate mappings and schema exports from XDoclet comments in my .java files

Uli

Code:
<?xml version="1.0" encoding="UTF-8"?>

<project name="hibernatetest" default="hbmxdoclet2" basedir=".">
   
   <property name="src" value="${basedir}/src"/>
   <property name="build" value="${basedir}/bin"/>
   <property name="lib" value="${basedir}/lib"/>
   <property name="xdoclet.home" value="C:/Program Files/Java/xdoclet-1.2.3"/>
   <property name="xdoclet2.home" value="C:/Program Files/Java/xdoclet-plugins-1.0.3"/>

   <!-- generate .hbm.xml files from XDoclet comments in .java files -->
   <target name="hbmxdoclet">
      <taskdef name="hibernatedoclet" classname="xdoclet.modules.hibernate.HibernateDocletTask">
         <classpath>
            <fileset dir="${xdoclet.home}">
                <include name="**/*.jar"/>
            </fileset>
         </classpath>
      </taskdef>
      <hibernatedoclet
         destdir="${src}"
         excludedtags="@version,@author,@todo"
         force="true"
         mergedir="${build}"
         verbose="true">
         <fileset dir="${src}">
            <include name="**/*.java"/>
         </fileset>
         <hibernate version="3.0"/>
      </hibernatedoclet>
   </target>
   <!-- generate sql DDL script from mapping files -->
   <target name="schema">
      <schemaexport
         config="${src}/hibernate.cfg.xml"
         quiet="no"
         text="true"
         drop="false"
         delimiter=";"
         output="schema-export.sql">
         <fileset dir="${src}">
            <include name="**/*.hbm.xml"/>
         </fileset>
      </schemaexport>
   </target>
   <!--
   generate .hbm.xml files from XDoclet2 comments in .java files
   necessary if you want to use Java 5 features such as generics
   -->
   <target name="hbmxdoclet2">
      <path id="xdoclet2.task.classpath">
         <fileset dir="${xdoclet2.home}">
            <include name="**/*.jar" />
         </fileset>
      </path>
      
      <taskdef
         name="xdoclet"
         classname="org.xdoclet.ant.XDocletTask"
         classpathref="xdoclet2.task.classpath"
      />
      
      <xdoclet>
         <fileset dir="${src}">
            <include name="**/*.java"/>
         </fileset>
         
         <component
            classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin"
            version="3.0"
            destdir="${src}"
            encoding="UTF-8"
         />
      </xdoclet>
   </target>
</project>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.