Re: Ant build.xml using XDoclet JDO module to automatically enhance class files
Is there a question here? The build file looks reasonable to me. The sun reference enhancer is kind of nasty about only enhancing files in the correct order and not telling you clearly if there is a problem, and is exceedingly slow if you enhance them one by one. The tjdo project on sourceforge has a wrapper ant task that figures out the dependencies and feeds the files in the correct order to the reference enhancer all at once. My experience is that it is about 100 times faster than one-at-a-time. david jencks On 2003.02.27 15:41 Sebastian Thomschke wrote: Since I didn't find any other solutions on the web, I worte an ant build.xml that generates jdo metadata files based on @jdo xdoclet tags in java files having the @jdo.persistence-capable tag and afterwards uses these metadata files to automatically enhances the class files using the sun JDO enhancer. This is the first build I ever wrote, therefore it doesn't contain any best practices. Therefore comments and suggestions are more than welcome. Sebastian ?xml version=1.0 encoding=UTF-8? project name=JDOTest default=compile basedir=. !-- -- !-- Global properties-- !-- -- property name=versionvalue=1.0/ property name=jarnamevalue=jdotest.jar/ property name=runclass value=sebthom.jdotest.Main/ property name=classpath value=/ property name=build.compiler value=jikes/ !-- -- !-- Project directories -- !-- -- property name=bin value=bin/ property name=docs value=docs/ property name=includes value=includes/ property name=lib value=lib/ property name=src value=src/ property name=bin_absolute location=${bin}/ property name=docs_absolute location=${docs}/ property name=includes_absolute location=${includes}/ property name=lib_absolute location=${lib}/ property name=src_absolute location=${src}/ !-- -- !-- Class path -- !-- -- path id=base.path !-- use the value of the ${classpath} property in the classpath -- pathelement path=${classpath}/ !-- includes all jar files in lib -- fileset dir=${lib} include name=**/*.jar/ /fileset !-- includes all jar files in includes -- fileset dir=${includes} include name=**/*.jar/ /fileset !-- includes all compiled class files in includes -- dirset dir=${includes} include name=**/ /dirset /path !-- -- !-- Additional ant tasks -- !-- -- taskdef classpathref=base.path resource=net/sf/antcontrib/antcontrib.properties / taskdef classpathref=base.path name=jdodoclet classname=xdoclet.modules.jdo.JdoDocletTask/ !-- -- !-- Target: display properties -- !-- -- target name=display properties echoproperties/ /target !-- -- !-- Target: compile -- !-- -- target name=compile !-- Create the build directory structure used by compile -- mkdir dir=${bin}/ !-- run javac to compile the source files -- javac srcdir=${src} destdir=${bin} debug=on classpathref=base.path/ !-- generate metadata.jdo file in bin directory -- jdodoclet addedtags=@xdoclet-generated at ${TODAY},@copyright The XDoclet Team,@author XDoclet,@version ${version} excludedtags=@version,@author,@todo destdir=${bin} verbose=false fileset dir=${src} include name=**/*.java/ /fileset jdometadata generation=package/ /jdodoclet !-- enhance every class containing @jdo.persistence-capable tag -- foreach target=compile.jdoEnhancer param=param_JavaFile fileset dir=${src} include name=**/*.java/ or contains text=@jdo.persistence-capable casesensitive=no/ contains text=@jdo:persistence-capable casesensitive=no/ /or /fileset /foreach /target target name=compile.jdoEnhancer !-- set javaFile.fullname -- property name =javaFile.fullname value=${param_JavaFile}/ !-- set javaFile.directory -- dirname property=javaFile.directory file=${javaFile.fullname}/ !-- set javaFile.filename -- basename property=javaFile.filename file=${javaFile.fullname}/ !-- set javaFile.basename -- basename property=javaFile.basename file=${javaFile.fullname}
Ant build.xml using XDoclet JDO module to automatically enhance class files
Since I didn't find any other solutions on the web, I worte an ant build.xml that generates jdo metadata files based on @jdo xdoclet tags in java files having the @jdo.persistence-capable tag and afterwards uses these metadata files to automatically enhances the class files using the sun JDO enhancer. This is the first build I ever wrote, therefore it doesn't contain any best practices. Therefore comments and suggestions are more than welcome. Sebastian ?xml version=1.0 encoding=UTF-8? project name=JDOTest default=compile basedir=. !-- -- !-- Global properties-- !-- -- property name=versionvalue=1.0/ property name=jarnamevalue=jdotest.jar/ property name=runclass value=sebthom.jdotest.Main/ property name=classpath value=/ property name=build.compiler value=jikes/ !-- -- !-- Project directories -- !-- -- property name=bin value=bin/ property name=docs value=docs/ property name=includes value=includes/ property name=lib value=lib/ property name=src value=src/ property name=bin_absolute location=${bin}/ property name=docs_absolute location=${docs}/ property name=includes_absolute location=${includes}/ property name=lib_absolute location=${lib}/ property name=src_absolute location=${src}/ !-- -- !-- Class path -- !-- -- path id=base.path !-- use the value of the ${classpath} property in the classpath -- pathelement path=${classpath}/ !-- includes all jar files in lib -- fileset dir=${lib} include name=**/*.jar/ /fileset !-- includes all jar files in includes -- fileset dir=${includes} include name=**/*.jar/ /fileset !-- includes all compiled class files in includes -- dirset dir=${includes} include name=**/ /dirset /path !-- -- !-- Additional ant tasks -- !-- -- taskdef classpathref=base.path resource=net/sf/antcontrib/antcontrib.properties / taskdef classpathref=base.path name=jdodoclet classname=xdoclet.modules.jdo.JdoDocletTask/ !-- -- !-- Target: display properties -- !-- -- target name=display properties echoproperties/ /target !-- -- !-- Target: compile -- !-- -- target name=compile !-- Create the build directory structure used by compile -- mkdir dir=${bin}/ !-- run javac to compile the source files -- javac srcdir=${src} destdir=${bin} debug=on classpathref=base.path/ !-- generate metadata.jdo file in bin directory -- jdodoclet addedtags=@xdoclet-generated at ${TODAY},@copyright The XDoclet Team,@author XDoclet,@version ${version} excludedtags=@version,@author,@todo destdir=${bin} verbose=false fileset dir=${src} include name=**/*.java/ /fileset jdometadata generation=package/ /jdodoclet !-- enhance every class containing @jdo.persistence-capable tag -- foreach target=compile.jdoEnhancer param=param_JavaFile fileset dir=${src} include name=**/*.java/ or contains text=@jdo.persistence-capable casesensitive=no/ contains text=@jdo:persistence-capable casesensitive=no/ /or /fileset /foreach /target target name=compile.jdoEnhancer !-- set javaFile.fullname -- property name=javaFile.fullname value=${param_JavaFile}/ !-- set javaFile.directory -- dirname property=javaFile.directory file=${javaFile.fullname}/ !-- set javaFile.filename -- basename property=javaFile.filename file=${javaFile.fullname}/ !-- set javaFile.basename -- basename property=javaFile.basename file=${javaFile.fullname} suffix=.java/ !-- set classFile.fullname -- pathconvert property=classFile.fullname targetOS=unix path pathelement location=${javaFile.directory}${file.separator}${javaFile.basename}.class/ /path map from=${src_absolute} to=${bin_absolute} / /pathconvert !-- set classFile.directory -- dirname property=classFile.directory file=${classFile.fullname}/ echoEnhancing: ${classFile.fullname}/echo java fork=yes failonerror=yes classname=com.sun.jdori.enhancer.Main classpathref=base.path !-- Even if the enhancer expects a parameter for the location of the JDO file, the JDO file