1 <?xml version="1.0"?> 2 3 <!-- =================================================================== --> 4 <!-- JBoss build file --> 5 <!-- =================================================================== --> 6 7 <project name="javassist" default="jar" basedir="."> 8 9 <property name="dist-version" value="javassist-3.14.0-GA"/> 10 11 <property environment="env"/> 12 <property name="target.jar" value="javassist.jar"/> 13 <property name="target-src.jar" value="javassist-src.jar"/> 14 <property name="lib.dir" value="${basedir}/lib"/> 15 <property name="src.dir" value="${basedir}/src/main"/> 16 <property name="build.dir" value="${basedir}/build"/> 17 <property name="build.classes.dir" value="${build.dir}/classes"/> 18 <property name="test.src.dir" value="${basedir}/src/test"/> 19 <property name="test.build.dir" value="${basedir}/build/test-classes"/> 20 <property name="test.reports.dir" value = "${basedir}/build/test-output"/> 21 22 <property name="run.dir" value="${build.classes.dir}"/> 23 24 <!-- Build classpath --> 25 <path id="classpath"> 26 <pathelement location="${build.classes.dir}"/> 27 </path> 28 29 <property name="build.classpath" refid="classpath"/> 30 31 <path id="test.compile.classpath"> 32 <pathelement location="${build.classes.dir}"/> 33 <pathelement location="${lib.dir}/junit.jar"/> 34 </path> 35 36 <property name="test.compile.classpath" refid="test.compile.classpath"/> 37 38 <path id="test.classpath"> 39 <pathelement location="${test.build.dir}"/> 40 <pathelement location="${lib.dir}/junit.jar"/> 41 <pathelement location="${build.classes.dir}"/> 42 </path> 43 44 <property name="test.classpath" refid="test.classpath"/> 45 46 <!-- =================================================================== --> 47 <!-- Prepares the build directory --> 48 <!-- =================================================================== --> 49 <target name="prepare" > 50 <mkdir dir="${build.dir}"/> 51 <mkdir dir="${build.classes.dir}"/> 52 <mkdir dir="${test.build.dir}"/> 53 <mkdir dir="${test.reports.dir}"/> 54 </target> 55 56 <!-- =================================================================== --> 57 <!-- Compiles the source code --> 58 <!-- =================================================================== --> 59 <target name="compile" depends="prepare"> 60 <javac srcdir="${src.dir}" 61 destdir="${build.classes.dir}" 62 debug="on" 63 deprecation="on" 64 optimize="off" 65 includes="**"> 66 <classpath refid="classpath"/> 67 </javac> 68 </target> 69 70 <target name="compile14" depends="prepare"> 71 <javac srcdir="${src.dir}" 72 destdir="${build.classes.dir}" 73 debug="on" 74 deprecation="on" 75 source="1.4" 76 target="1.4" 77 optimize="off" 78 includes="**"> 79 <classpath refid="classpath"/> 80 </javac> 81 </target> 82 83 <target name="test-compile" depends="compile"> 84 <javac srcdir="${test.src.dir}" 85 destdir="${test.build.dir}" 86 debug="on" 87 deprecation="on" 88 optimize="off" 89 includes="**"> 90 <classpath refid="test.compile.classpath"/> 91 </javac> 92 </target> 93 94 <target name="test" depends="test-compile"> 95 <junit fork="true" printsummary="true"> 96 <classpath refid="test.classpath"/> 97 <formatter type="plain"/> 98 <formatter type="xml"/> 99 <batchtest todir="${test.reports.dir}"> 100 <fileset dir="${test.build.dir}"> 101 <include name="**/*Test.*"/> 102 </fileset> 103 </batchtest> 104 </junit> 105 </target> 106 107 <target name="sample" depends="compile"> 108 <javac srcdir="${basedir}" 109 destdir="${build.classes.dir}" 110 debug="on" 111 deprecation="on" 112 optimize="off" 113 includes="sample/**" 114 excludes="sample/hotswap/**,sample/evolve/sample/**"> 115 <classpath refid="classpath"/> 116 </javac> 117 118 <copy file="sample/vector/Test.j" 119 todir="${build.classes.dir}/sample/vector"/> 120 121 <javac srcdir="${basedir}/sample/evolve" 122 destdir="${build.classes.dir}/sample/evolve/" 123 debug="on" 124 deprecation="on" 125 optimize="off" 126 includes="sample/**"> 127 <classpath refid="classpath"/> 128 </javac> 129 <copy todir="${build.classes.dir}/sample/evolve"> 130 <fileset dir="sample/evolve"/> 131 </copy> 132 <copy file="${build.classes.dir}/sample/evolve/WebPage.class" 133 tofile="${build.classes.dir}/sample/evolve/WebPage.class.0"/> 134 <copy file="${build.classes.dir}/sample/evolve/sample/evolve/WebPage.class" 135 tofile="${build.classes.dir}/sample/evolve/WebPage.class.1"/> 136 137 <javac srcdir="${basedir}/sample/hotswap" 138 destdir="${build.classes.dir}" 139 debug="on" 140 deprecation="on" 141 optimize="off" 142 includes="*"> 143 <classpath refid="classpath"/> 144 </javac> 145 <mkdir dir="${build.classes.dir}/logging"/> 146 <javac srcdir="${basedir}/sample/hotswap/logging" 147 destdir="${build.classes.dir}/logging" 148 debug="on" 149 deprecation="on" 150 optimize="off" 151 includes="*"> 152 <classpath refid="classpath"/> 153 </javac> 154 <echo>To run the sample programs without ant, change the current directory 155 to ${build.classes.dir}.</echo> 156 </target> 157 158 <target name="jar" depends="compile14"> 159 <jar jarfile="${target.jar}" manifest="${src.dir}/META-INF/MANIFEST.MF"> 160 <fileset dir="${build.classes.dir}"> 161 <include name="**/*.class"/> 162 </fileset> 163 </jar> 164 <jar jarfile="${target-src.jar}" manifest="${src.dir}/META-INF/MANIFEST.MF"> 165 <fileset dir="${src.dir}"> 166 <include name="javassist/**"/> 167 </fileset> 168 </jar> 169 </target> 170 171 <target name="javadocs"> 172 <mkdir dir="html"/> 173 <javadoc 174 Locale="en_US" 175 packagenames="javassist.*" 176 excludepackagenames="javassist.compiler.*,javassist.convert.*,javassist.scopedpool.*,javassist.bytecode.stackmap.*" 177 sourcepath="src/main" 178 defaultexcludes="yes" 179 destdir="html" 180 author="true" 181 version="true" 182 use="true" 183 public="true" 184 nohelp="true" 185 windowtitle="Javassist API"> 186 <doctitle><![CDATA[<h1>Javassist</h1>]]></doctitle> 187 <bottom><![CDATA[<i>Javassist, a Java-bytecode translator toolkit.<br> 188 Copyright (C) 1999-2010 Shigeru Chiba. All Rights Reserved.</i>]]></bottom> 189 </javadoc> 190 </target> 191 192 <target name="dist" depends="jar,javadocs"> 193 <delete file="${dist-version}.zip"/> 194 <zip zipfile="${dist-version}.zip"> 195 <zipfileset dir="${basedir}" prefix="${dist-version}"> 196 <include name="html/**"/> 197 <include name="sample/**"/> 198 <include name="src/main/**"/> 199 <include name="tutorial/**"/> 200 <include name="*.html"/> 201 <include name="*.xml"/> 202 <include name="${target.jar}"/> 203 </zipfileset> 204 </zip> 205 </target> 206 207 <target name="clean"> 208 <delete dir="build"/> 209 <delete dir="html"/> 210 <delete file="${target.jar}"/> 211 <delete file="${dist-version}.zip"/> 212 </target> 213 214 <!-- =================================================================== --> 215 <!-- Run samples --> 216 <!-- =================================================================== --> 217 218 <target name = "sample-all" 219 depends="sample-test,sample-reflect,sample-duplicate,sample-vector"> 220 <echo>** please run sample-rmi, sample-evolve, and</echo> 221 <echo> sample-hotswap (or -hotswap5) separately **</echo> 222 </target> 223 224 <target name = "sample-test" depends="sample" > 225 <java fork="true" dir="${run.dir}" classname="sample.Test"> 226 <classpath refid="classpath"/> 227 </java> 228 </target> 229 230 <target name = "sample-reflect" depends="sample" > 231 <java fork="true" dir="${run.dir}" classname="javassist.tools.reflect.Loader"> 232 <classpath refid="classpath"/> 233 <arg line="sample.reflect.Main Joe" /> 234 </java> 235 </target> 236 237 <target name = "sample-duplicate" depends="sample" > 238 <echo>run sample.duplicate.Viewer without reflection</echo> 239 <java fork="true" dir="${run.dir}" classname="sample.duplicate.Viewer"> 240 <classpath refid="classpath"/> 241 </java> 242 <echo>run sample.duplicate.Viewer with reflection</echo> 243 <java fork="true" dir="${run.dir}" classname="sample.duplicate.Main"> 244 <classpath refid="classpath"/> 245 </java> 246 </target> 247 248 <target name = "sample-vector" depends="sample" > 249 <echo>sample.preproc.Compiler sample/vector/Test.j</echo> 250 <java fork="true" dir="${run.dir}" classname="sample.preproc.Compiler"> 251 <classpath refid="classpath"/> 252 <arg line="sample/vector/Test.j"/> 253 </java> 254 <echo>javac sample/vector/Test.java</echo> 255 <javac srcdir="${build.classes.dir}" 256 destdir="${build.classes.dir}" 257 includes="sample/vector/Test.java"> 258 <classpath refid="classpath"/> 259 </javac> 260 <java fork="true" dir="${run.dir}" classname="sample.vector.Test" /> 261 </target> 262 263 <target name = "sample-rmi" depends="sample" > 264 <echo>** Please open sample/rmi/webdemo.html with your browser **</echo> 265 <java fork="true" dir="${run.dir}" classname="sample.rmi.Counter"> 266 <classpath refid="classpath"/> 267 <arg value="5001" /> 268 </java> 269 </target> 270 271 <target name = "sample-evolve" depends="sample" > 272 <echo>** Please open http://localhost:5003/demo.html with your browser **</echo> 273 <java fork="true" dir="${run.dir}" classname="sample.evolve.DemoLoader"> 274 <classpath refid="classpath"/> 275 <arg value="5003" /> 276 </java> 277 </target> 278 279 <!-- for JDK 1.4 --> 280 <target name = "sample-hotswap" depends="sample"> 281 <echo>** JAVA_HOME/lib/tools.jar must be included in CLASS_PATH</echo> 282 <echo>** for JDK 1.4</echo> 283 <java fork="true" dir="${run.dir}" classname="Test"> 284 <jvmarg line="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000" /> 285 <classpath refid="classpath"/> 286 </java> 287 </target> 288 289 <!-- for Java 5 --> 290 <target name = "sample-hotswap5" depends="sample"> 291 <echo>** JAVA_HOME/lib/tools.jar must be included in CLASS_PATH</echo> 292 <echo>** for JDK 1.5 or later</echo> 293 <java fork="true" dir="${run.dir}" classname="Test"> 294 <jvmarg line="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000" /> 295 <classpath refid="classpath"/> 296 </java> 297 </target> 298 </project> 299