利用Ant和XDoclet自动产生映射文件例子
2009-09-23 00:00:00 来源:WEB开发网//在test目录下建立build.xml,其中<property name="xdoclet.home" value="C:/xdoclet-plugins-dist-1.0.4">为你所解压的xdoclet目录。 Ant build File build.xml
<project name="Hibernate Example" default="about" basedir=".">
<!-- The location where your xdoclet jar files reside -->
<property name="xdoclet.lib.home" value="c:/java_api/xdoclet-1.2b3/lib"/>
<target name="clean" depends="init" description="removes all directories
related to this build">
<delete dir="${dist}"/>
</target>
<target name="init" description="Initializes properties that are used by
other targets.">
<property name="dist" value="dist"/>
</target>
<target name="prepare" depends="init,clean" description="creates dist dir
ectory">
<echo message="Creating required directories..."/>
<mkdir dir="${dist}"/>
</target>
<target name="hibernate" depends="prepare"
description="Generates Hibernate class descriptor files.">
<taskdef name="hibernatedoclet" classname="xdoclet.
modules.hibernate.HibernateDocletTask"> <classpath>
<fileset dir="${xdoclet.lib.home}">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<!-- Execute the hibernatedoclet task -->
<hibernatedoclet
destdir="."
excludedtags="@version,@author,@todo"
force="true"
verbose="true"
mergedir="${dist}">
<fileset dir=".">
<include name="**/dbdemo/*.java"/>
</fileset>
<hibernate version="2.0"/>
</hibernatedoclet>
</target>
<target name="about" description="about this build file" depends="init">
<echo message=" Use this format for the arguments:"/>
<echo message=" ant hibernate"/>
<echo message=""/>
</target>
</project>
执行过程: Windows-->ShowView-->Other-->Ant文件里面(Ant)-->在Ant空白处右键 -->Add Buildfiles-->选择你要生成配置文件的bulild.xml文件点击OK,让后分别执行,所要生成的文件即可.赶快试试吧...
更多精彩
赞助商链接