1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
|
<!-- $Id: build.xml,v 1.57 2009/07/23 06:48:27 jhunter Exp $ -->
<!--
For instructions on how to build JDOM, please view the README.txt file.
-->
<project default="package" basedir=".">
<!-- =================================================================== -->
<!-- Initialization target -->
<!-- =================================================================== -->
<tstamp >
<format property="snapshot.time" pattern="yyyy.MM.dd.HH.mm" />
<format property="year" pattern="yyyy" />
</tstamp>
<!--
Give user a chance to override without editing this file
(and without using -D arguments each time they build).
The build properties a user is likely to override include:
- lib.dir The directory where to look for the default JAR
files. Defaults to ./lib
- xml-apis.jar The JAR containing the DOM, SAX and JAXP classes.
Defaults to ${lib.dir}/xml-apis.jar
- parser.jar The JAR containing the XML parser to use.
Defaults to ${lib.dir}/xerces.jar
- jaxen.lib.dir The directory containing the Jaxen JAR libraries.
Defaults to ${lib.dir}
-->
<property file="${user.home}/jdom.build.properties" />
<property file="${basedir}/build.properties" />
<property name="Name" value="JDOM"/>
<property name="name" value="jdom"/>
<property name="version" value="2.x-${snapshot.time}"/>
<property name="version.impl" value="${version}"/>
<property name="version.spec" value="2.0.0"/>
<property name="gpg" value="gpg"
description="Path to the GNU gpg program for maven target"/>
<property name="jarbase" value="${name}-${version}" />
<property name="instrument" value="true" />
<echo message="----------- ${Name} ${version} ------------"/>
<property name="compile.debug" value="true" />
<property name="compile.optimize" value="true" />
<property name="compile.target" value="1.5" />
<property name="compile.source" value="1.5" />
<property name="compile.deprecation" value="true" />
<property name="build" value="./build"/>
<property name="core" value="./core" />
<property name="core.src" value="${core}/src/java" />
<property name="core.build" value="${build}/core" />
<property name="about" value="./core/package" />
<property name="about.src" value="${about}" />
<property name="about.build" value="${build}/about" />
<property name="metainf" value="./core/package/META-INF" />
<property name="metainf.build" value="${build}/META-INF" />
<property name="contrib" value="./contrib" />
<property name="contrib.src" value="${contrib}/src/java" />
<property name="contrib.build" value="${build}/contrib" />
<property name="junit" value="./test" />
<property name="junit.src" value="${junit}/src/java" />
<property name="junit.resources" value="${junit}/src/resources" />
<property name="junit.build" value="${build}/junit" />
<property name="junit.xml" value="${build}/junit.xml" />
<property name="junit.report" value="${build}/junit.report" />
<property name="junit.instrumented" value="${build}/instrumented" />
<property name="samples" value="./core/samples/" />
<property name="samples.src" value="${samples}/" />
<property name="samples.build" value="${build}/samples"/>
<!-- Do not set a stax.dir
but it is available for override (for Java5 for example) -->
<property name="stax.dir" value="dummy" />
<property name="lib.dir" value="./lib"/>
<property name="packages" value="org.jdom2.*"/>
<property name="build.javadocs" value="${build}/apidocs"/>
<property name="package" value="${build}/package"/>
<property name="coverage.out" value="${build}/coverage" />
<property name="mavendir" value="${build}/maven" />
<filter token="year" value="${year}"/>
<filter token="version" value="${version}"/>
<filter token="date" value="${TODAY}"/>
<filter token="jdk" value="${compile.target}" />
<!-- Default JAR libraries -->
<property name="parser.jar" value="${lib.dir}/xercesImpl.jar" />
<property name="xmlapi.jar" value="${lib.dir}/xml-apis.jar" />
<property name="jaxen.jar" value="${lib.dir}/jaxen-1.1.6.jar" />
<property name="junit.jar" value="${lib.dir}/junit-4.8.2.jar" />
<property name="isorelax.jar" value="${contrib}/lib/isorelax.jar" />
<property name="xalan.jar" value="${lib.dir}/xalan/xalan-2.7.1.jar" />
<property name="xalanser.jar" value="${lib.dir}/xalan/serializer-2.7.1.jar" />
<!-- Compilation class path -->
<path id="base.class.path">
<pathelement location="${jaxen.jar}" />
<pathelement location="${parser.jar}" />
<pathelement location="${xmlapi.jar}" />
<pathelement location="${junit.jar}" />
<pathelement location="${isorelax.jar}" />
<pathelement location="${xalan.jar}" />
<pathelement location="${xalanser.jar}" />
<!-- normally these stax jars will not be found -->
<!-- this is used for testing Java5 (the test sets stax.dir) -->
<pathelement location="${stax.dir}/jsr173_1.0_api.jar" />
<pathelement location="${stax.dir}/sjsxp.jar" />
</path>
<path id="core.class.path">
<path refid="base.class.path"/>
<pathelement location="${core.build}"/>
</path>
<path id="contrib.class.path">
<path refid="core.class.path"/>
<pathelement location="${contrib.build}"/>
</path>
<path id="junit.class.path">
<pathelement location="${junit.instrumented}" />
<pathelement location="${junit.build}"/>
<path refid="contrib.class.path"/>
<fileset dir="${lib.dir}/cobertura" includes="*.jar" />
</path>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage">
<echo message=""/>
<echo message=""/>
<echo message="JDOM Build file"/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message=" available targets are:"/>
<echo message=""/>
<echo message=" - package [default] -> generates ./build/jdom2.jar and other supporting files"/>
<echo message=" - compile -> compiles the source code"/>
<echo message=" - javadoc -> generates the API documentation in ./build/javadocs"/>
<echo message=" - junit -> runs the JUnit tests"/>
<echo message=" - coverage -> generates test coverage metrics"/>
<echo message=" - eclipse -> generates an Eclipse project (source folders, jars, etc)"/>
<echo message=" - clean -> restores the distribution to its original and clean state"/>
<echo message=" - maven -> Prepares a package-upload for maven-central"/>
<echo message=""/>
<echo message=" See the comments inside the build.xml file for more details."/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message=""/>
</target>
<!-- =================================================================== -->
<!-- Prepares the build directory -->
<!-- =================================================================== -->
<target name="prepare">
<mkdir dir="${build}"/>
<mkdir dir="${core.build}"/>
<mkdir dir="${about.build}"/>
<mkdir dir="${samples.build}"/>
<mkdir dir="${junit.build}"/>
<mkdir dir="${contrib.build}"/>
<mkdir dir="${metainf.build}"/>
</target>
<!-- =================================================================== -->
<!-- Compiles the source directory -->
<!-- =================================================================== -->
<target name="compile.core" depends="prepare"
description="Compiles the core source code">
<!-- Copy resources and stuff - everything except Java code -->
<copy todir="${core.build}" >
<fileset dir="${core.src}" excludes="**/*.java" />
</copy>
<javac srcdir="${core.src}"
destdir="${core.build}"
debug="${compile.debug}"
optimize="${compile.optimize}"
target="${compile.target}"
source="${compile.source}"
deprecation="${compile.deprecation}"
includeantruntime="false">
<classpath refid="base.class.path"/>
</javac>
</target>
<target name="compile.samples" depends="compile.core, compile.contrib"
description="Compiles the sample source code">
<!-- Copy resources and stuff - everything except Java code -->
<copy todir="${samples.build}" >
<fileset dir="${samples.src}" excludes="**/*.java" />
</copy>
<javac srcdir="${samples.src}"
destdir="${samples.build}"
debug="${compile.debug}"
optimize="${compile.optimize}"
target="${compile.target}"
source="${compile.source}"
deprecation="${compile.deprecation}"
includeantruntime="false">
<classpath refid="contrib.class.path" />
</javac>
</target>
<target name="compile.contrib" depends="compile.core"
description="Compiles the contrib source code">
<!-- Copy resources and stuff - everything except Java code -->
<copy todir="${contrib.build}" >
<fileset dir="${contrib.src}" excludes="**/*.java" />
</copy>
<javac srcdir="${contrib.src}"
destdir="${contrib.build}"
debug="${compile.debug}"
optimize="${compile.optimize}"
target="${compile.target}"
source="${compile.source}"
deprecation="${compile.deprecation}"
includeantruntime="false">
<classpath refid="core.class.path" />
</javac>
</target>
<target name="compile.junit" depends="compile.core, compile.contrib"
description="Compiles the junit source code">
<!-- Copy resources and stuff - everything except Java code -->
<copy todir="${junit.build}" >
<fileset dir="${junit.src}" excludes="**/*.java" />
<fileset dir="${junit.resources}" />
</copy>
<!-- ignore deprecation warnings in jUnit -->
<javac srcdir="${junit.src}"
destdir="${junit.build}"
debug="${compile.debug}"
optimize="${compile.optimize}"
target="${compile.target}"
source="${compile.source}"
deprecation="no"
includeantruntime="false">
<classpath refid="contrib.class.path" />
</javac>
</target>
<target name="compile" depends="compile.core, compile.junit, compile.contrib, compile.samples"
description="Compiles all JDOM code (core, samples, junit, contrib)" />
<!-- =================================================================== -->
<!-- Creates the API documentation -->
<!-- =================================================================== -->
<target name="javadoc" depends="prepare"
description="Creates the API documentation">
<mkdir dir="${build.javadocs}"/>
<javadoc packagenames="${packages}"
sourcepath="${core.src}"
destdir="${build.javadocs}"
author="true"
version="true"
use="true"
splitindex="true"
noindex="false"
windowtitle="${Name} v${version}"
doctitle="${Name} v${version}<br>API Specification"
header="<b>${Name}<br><font size='-1'>${version}</font></b>"
bottom="Copyright © ${year} Jason Hunter, Brett McLaughlin. All Rights Reserved.">
<classpath refid="base.class.path"/>
</javadoc>
</target>
<!-- =================================================================== -->
<!-- Creates the jars -->
<!-- =================================================================== -->
<target name="jars" depends="compile, javadoc"
description="Builds the Jars">
<fixcrlf srcdir="." includes="**/*.bat" excludes="build*.*" eol="crlf"/>
<fixcrlf srcdir="." includes="**/*.sh" excludes="build*.*" eol="lf"/>
<!-- Filters defined specifically for updating the manifest -->
<filter token="version.spec" value="${version.spec}"/>
<filter token="version.impl" value="${version.impl}"/>
<copy todir="${metainf.build}/META-INF" filtering="yes">
<fileset dir="${metainf}"/>
<fileset dir=".">
<include name="LICENSE.txt"/>
</fileset>
</copy>
<jar jarfile="${package}/${jarbase}.jar" manifest="${metainf.build}/META-INF/MANIFEST.MF">
<fileset dir="${core.build}" includes="**/*.class" />
<fileset dir="${metainf.build}" excludes="**/MANIFEST.MF" />
</jar>
<jar jarfile="${package}/${jarbase}-contrib.jar" >
<fileset dir="${contrib.build}" includes="**/*" />
<fileset dir="${metainf.build}" excludes="**/MANIFEST.MF" />
</jar>
<jar jarfile="${package}/${jarbase}-junit.jar" >
<fileset dir="${junit.build}" includes="**/*" />
<fileset dir="${metainf.build}" excludes="**/MANIFEST.MF" />
</jar>
<jar destfile="${package}/${jarbase}-javadoc.jar"
basedir="${build.javadocs}" includes="**/*" />
<jar jarfile="${package}/${jarbase}-sources.jar" >
<fileset dir="${core.src}" includes="**/*" />
<fileset dir="${junit.src}" includes="**/*" />
<fileset dir="${contrib.src}" includes="**/*" />
</jar>
</target>
<target name="androidtests" depends="jars">
<property name="android.project" value="JUT" />
<property name="android" value="${build}/android" />
<property name="android.libs" value="${android}/${android.project}/libs" />
<mkdir dir="${android}" />
<mkdir dir="${android.libs}" />
<path id="at.class.path">
<pathelement location="${package}/${jarbase}.jar" />
<pathelement location="${package}/${jarbase}-contrib.jar" />
<pathelement location="${package}/${jarbase}-junit.jar" />
<path refid="base.class.path"/>
</path>
<!-- Convert the test cases from JUnit4 to a JUnit3 format -->
<!-- This also copies the resources only. -->
<java classname="org.jdom2.contrib.android.TranslateTests"
classpathref="at.class.path" >
<arg value="${package}/${jarbase}-junit.jar" />
<arg value="${android}/${android.project}Test/src" />
</java>
<copy todir="${android.libs}">
<fileset dir="${package}"
includes="${jarbase}.jar, ${jarbase}-contrib.jar ${jarbase}-junit.jar" />
</copy>
<copy todir="${android.libs}" file="${jaxen.jar}"/>
<copy todir="${android.libs}" file="${xalan.jar}"/>
<copy todir="${android.libs}" file="${xalanser.jar}"/>
<copy todir="${android.libs}" file="${junit.jar}"/>
</target>
<!-- =================================================================== -->
<!-- Creates the class package -->
<!-- =================================================================== -->
<target name="package" depends="coverage, jars"
description="Creates the class package">
<zip destfile="${package}/${jarbase}.zip">
<fileset dir="${package}" includes="${jarbase}*.jar" />
<fileset dir="${basedir}" includes="lib/xerces* lib/jaxen* lib/xml*" />
<fileset dir="${basedir}" includes="LICENSE.txt README.txt" />
</zip>
</target>
<!-- =================================================================== -->
<!-- Clean targets -->
<!-- =================================================================== -->
<target name="clean" description="Removes build files">
<delete dir="${build}" failonerror="false"/>
</target>
<!-- =================================================================== -->
<!-- JUnit and Test Coverage targets -->
<!-- =================================================================== -->
<target name="coverage.setup" description="Set up code-coverage metrics" depends="compile.core">
<taskdef classpathref="junit.class.path" resource="tasks.properties"/>
<delete dir="${junit.instrumented}"/>
<mkdir dir="${junit.instrumented}" />
<property name="cobertura.datafile" value="${junit.instrumented}/cobertura.ser"/>
<cobertura-instrument todir="${junit.instrumented}" datafile="${cobertura.datafile}">
<fileset dir="${core.build}">
<include name="**/*.class"/>
<!-- exclude name="**/**/jaxen/**/*.class"/ -->
</fileset>
</cobertura-instrument>
<property name="forkjunit" value="true" />
</target>
<target name="junit.nodeps"
description="Run all the JUnit tests, but do not compile anything first">
<delete dir="${junit.report}" />
<mkdir dir="${junit.report}" />
<delete dir="${junit.xml}" />
<mkdir dir="${junit.xml}" />
<!-- We need to fork to get the resources on the classpath -->
<!-- Otherwise we rely on ant's ClassLoader which does not do resources nicely -->
<junit fork="true" forkmode="once" haltonerror="false" haltonfailure="false"
failureproperty="junit.failed" printsummary="true" timeout="100000"
showoutput="true" includeantruntime="true" >
<sysproperty key="net.sourceforge.cobertura.datafile"
file="${cobertura.datafile}" />
<classpath refid="junit.class.path" />
<formatter type="xml"/>
<batchtest haltonerror="false" haltonfailure="false"
failureproperty="junit.failed" todir="${junit.xml}" >
<sort>
<name />
<fileset dir="${junit.src}">
<include name="**/Test*.java"/>
<exclude name="**/generate/**" />
</fileset>
</sort>
</batchtest>
</junit>
<junitreport todir="${junit.report}">
<fileset dir="${junit.xml}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.report}"/>
</junitreport>
</target>
<target name="junit" depends="compile.core, compile.junit, junit.nodeps"
description="Compile code required for JUnit, then run JUnit tests"/>
<target name="coverage" depends="coverage.setup, junit"
description="Run the code coverage tool.">
<delete dir="${coverage.out}"/>
<mkdir dir="${coverage.out}" />
<cobertura-report srcdir="${core.src}" destdir="${coverage.out}" datafile="${cobertura.datafile}"/>
<echo message="See ${coverage.out}/index.html for results." />
</target>
<!-- =================================================================== -->
<!-- Eclipse targets -->
<!-- =================================================================== -->
<target name="eclipse" description="Set up your eclipse project (source folders, jars, etc.)">
<echo file="./.classpath" xml:space="preserve"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="core/src/java"/>
<classpathentry kind="src" path="core/package"/>
<classpathentry kind="src" path="core/samples"/>
<classpathentry kind="src" path="test/src/java"/>
<classpathentry kind="src" path="test/src/resources"/>
<classpathentry kind="src" path="contrib/src/java" excluding="org/jdom/contrib/ids/doc-files/|org/jdom/contrib/input/scanner/doc-files/|org/jdom2/contrib/ids/doc-files/|org/jdom2/contrib/ids/doc-files/|org/jdom2/contrib/input/scanner/doc-files/|org/jdom2/contrib/input/scanner/doc-files/"/>
<classpathentry kind="src" path="contrib/samples"/>
<classpathentry kind="src" path="contrib/src/java/org/jdom2/contrib/ids/doc-files"/>
<classpathentry kind="src" path="contrib/src/java/org/jdom2/contrib/input/scanner/doc-files"/>
<classpathentry kind="lib" path="${junit.jar}"/>
<classpathentry kind="lib" path="${parser.jar}"/>
<classpathentry kind="lib" path="${xmlapi.jar}"/>
<classpathentry kind="lib" path="${jaxen.jar}"/>
<classpathentry kind="lib" path="${isorelax.jar}"/>
<classpathentry kind="lib" path="${xalanser.jar}"/>
<classpathentry kind="lib" path="${xalan.jar}"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="ebuild"/>
</classpath>
]]>
</echo>
</target>
<!-- =================================================================== -->
<!-- Maven targets -->
<!-- =================================================================== -->
<target name="maven.clean">
<delete dir="${mavendir}" includes="**/*" failonerror="false"/>
</target>
<target name="maven" depends="maven.clean, package"
description="Prepares Maven bundle to load on to Sonatype Nexus for Maven-Central">
<mkdir dir="${mavendir}" />
<mkdir dir="${mavendir}/core" />
<mkdir dir="${mavendir}/test" />
<mkdir dir="${mavendir}/contrib" />
<property name="mavenartifact" value="jdom2" />
<property name="mavenbase" value="${mavenartifact}-${version}" />
<!-- copy the build jar -->
<copy tofile="${mavendir}/core/${mavenbase}.jar" file="${package}/${jarbase}.jar"/>
<copy tofile="${mavendir}/core/${mavenbase}-javadoc.jar" file="${package}/${jarbase}-javadoc.jar"/>
<copy tofile="${mavendir}/core/${mavenbase}-sources.jar" file="${package}/${jarbase}-sources.jar"/>
<!-- load the license in to the ${license} property -->
<loadfile property="license" srcfile="LICENSE.txt" />
<!-- copy/rename the pom template -->
<copy filtering="true" file="maven/maven.pom" tofile="${mavendir}/core/${mavenbase}.pom">
<filterset>
<filter token="artifactID" value="${mavenartifact}"/>
<filter token="version" value="${version}" />
<filter token="jdk" value="${compile.target}" />
<filter token="license" value="${license}" />
</filterset>
</copy>
<exec dir="${mavendir}/core" executable="${gpg}">
<arg value="-abv"/>
<arg value="${mavenbase}.pom"/>
</exec>
<exec dir="${mavendir}/core" executable="${gpg}">
<arg value="-abv"/>
<arg value="${mavenbase}.jar"/>
</exec>
<exec dir="${mavendir}/core" executable="${gpg}">
<arg value="-abv"/>
<arg value="${mavenbase}-sources.jar"/>
</exec>
<exec dir="${mavendir}/core" executable="${gpg}">
<arg value="-abv"/>
<arg value="${mavenbase}-javadoc.jar"/>
</exec>
<jar destfile="${mavendir}/${mavenbase}-maven-bundle.jar"
basedir="${mavendir}/core"
includes="${mavenbase}*" excludes="*maven-bundle*" />
</target>
</project>
<!-- End of file -->
|