File: build.xml

package info (click to toggle)
xmlgraphics-commons 2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 5,300 kB
  • sloc: java: 35,572; xml: 2,127; makefile: 6
file content (722 lines) | stat: -rw-r--r-- 31,547 bytes parent folder | download
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
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<project default="all" basedir="." name="xmlgraphics-commons">

  <!-- See build.properties and build-local.properties for overriding build settings. -->
  <!-- build-local.properties is not stored in SVN and overrides values from build.properties -->
  <property environment="env"/>
  <property file="${basedir}/build-local.properties"/>
  <property file="${basedir}/build.properties"/>

  <property name="Name" value="Apache XML Graphics Commons"/>
  <property name="name" value="xmlgraphics-commons"/>
  <property name="year" value="1999-2018"/>

  <property name="javac.debug" value="on"/>
  <property name="javac.optimize" value="off"/>
  <property name="javac.deprecation" value="on"/>
  <property name="javac.source" value="1.6"/>
  <property name="javac.target" value="1.6"/>
  <property name="javac.fork" value="no"/>

  <property name="junit.fork" value="on"/>
  <property name="junit.haltonfailure" value="off"/>
  <property name="junit.printsummary" value="off"/>
  <property name="junit.formatter.brief" value="on"/>

  <property name="javadoc.packages" value="org.apache.xmlgraphics.*"/>
  
  <property name="internal-codecs.disabled" value="false"/>
  
  <property name="src.dir" value="${basedir}/src/main"/>
  <property name="src.java.dir" value="${src.dir}/java"/>
  <property name="src.res.dir" value="${src.dir}/resources"/>
  <property name="lib.dir" value="${basedir}/lib"/>
  <property name="optional.lib.dir" value="${lib.dir}/build" />

  <property name="test.dir" value="${basedir}/src/test"/>
  <property name="test.java.dir" value="${test.dir}/java"/>
  <property name="test.res.dir" value="${test.dir}/resources"/>

  <property name="tools.dir" value="${basedir}/src/tools"/>
  <property name="tools.checkstyle.dir" value="${tools.dir}/resources/checkstyle"/>
  <property name="tools.findbugs.dir" value="${tools.dir}/resources/findbugs"/>

  <property name="build.dir" value="${basedir}/build"/>
  <property name="build.classes.dir" value="${build.dir}/classes"/>
  <property name="build.javadocs.dir" value="${build.dir}/javadocs"/>
  
  <property name="dist.bin.dir" value="${basedir}/dist-bin"/>
  <property name="dist.src.dir" value="${basedir}/dist-src"/>
  <property name="dist.bin.result.dir" value="${dist.bin.dir}/${name}-${version}"/>
  <property name="dist.src.result.dir" value="${dist.src.dir}/${name}-${version}"/>
  <property name="samedir" value="${basedir}"/>

  <!-- .NET support (using IKVM) -->
  <property name="ikvm.dir" value="."/>
  <property name="ikvmc" value="${ikvm.dir}/bin/ikvmc.exe"/>

  <tstamp>
    <format property="ts" pattern="yyyyMMdd-HHmmss-z"/>
  </tstamp>

  <path id="libs-build-classpath">
    <fileset dir="${lib.dir}">
      <include name="*.jar"/>
    </fileset>
    <fileset dir="${lib.dir}/build">
      <include name="*.jar"/>
    </fileset>
  </path>

  <path id="libs-run-classpath">
    <path refid="libs-build-classpath"/>
    <fileset dir="${build.dir}">
      <include name="${name}.jar"/>
    </fileset>
  </path>

  <fileset dir="${basedir}" id="dist.bin">
    <include name="examples/**"/>
    <include name="LICENSE"/>
    <include name="NOTICE"/>
    <include name="README"/>
    <include name="KEYS"/>
    <include name="status.xml"/>
  </fileset>

  <fileset dir="${basedir}" id="dist.bin.lib">
    <patternset id="dist.lib">
      <include name="lib/commons-io*"/>
      <include name="lib/commons-logging*"/>
      <include name="lib/README*"/>
    </patternset>
  </fileset>

  <fileset dir="${basedir}" id="dist.src.lib.build">
    <patternset id="dist.lib.build">
      <include name="lib/build/hamcrest.core*"/>
      <include name="lib/build/mockito-core*"/>
      <include name="lib/build/objenesis*"/>
      <include name="lib/build/resolver*"/>
    </patternset>
  </fileset>

  <fileset dir="${basedir}" id="dist.src">
    <include name="src/**"/>
    <include name="test/**"/>
    <patternset refid="dist.lib"/>
    <patternset refid="dist.lib.build"/>
    <include name="examples/**"/>
    <include name="LICENSE"/>
    <include name="NOTICE"/>
    <include name="README"/>
    <include name="KEYS"/>
    <include name="status.xml"/>
    <include name="*.pom"/>
    <include name="pom.xml"/>
    <include name="build.*"/>
    <include name="checkstyle*"/>
    <exclude name="checkstyle-noframes.xsl"/>
  </fileset>

  <!-- =================================================================== -->
  <!-- Initialization target                                               -->
  <!-- =================================================================== -->
  <target name="info">
    <echo message="------------------- ${Name} ${version} [${year}] ----------------"/>
    <echo message="See build.properties and build-local.properties for additional build settings"/>
    <echo message="${ant.version}"/>
    <echo message="VM: ${java.vm.version}, ${java.vm.vendor}"/>
    <echo message="JAVA_HOME: ${env.JAVA_HOME}"/>
  </target>
  
  <target name="init" depends="info, init-avail"/>

  <target name="init-avail">
    <available property="jdk15.present" classname="java.lang.StringBuilder"/>
    <fail message="${Name} requires at least Java 1.5" unless="jdk15.present"/>
    
    <condition property="internal-codecs.eff.disabled">
      <equals arg1="${internal-codecs.disabled}" arg2="true"/>
    </condition>

    <available property="junit.present" classname="junit.framework.TestCase"
        classpathref="libs-build-classpath"/>
    <condition property="junit.message" value="JUnit Support PRESENT">
      <equals arg1="${junit.present}" arg2="true"/>
    </condition>
    <condition property="junit.message" value="JUnit Support NOT Present - Committers are required to have JUnit working">
      <not>
        <equals arg1="${junit.present}" arg2="true"/>
      </not>
    </condition>
    <echo message="${junit.message}"/>

    <condition property="IKVM.present">
      <and>
        <available file="${ikvmc}"/>
        <equals arg1="${internal-codecs.eff.disabled}" arg2="true"/>
      </and>
    </condition>
    <condition property="ikvm.message" value="IKVM Support PRESENT and ENABLED">
      <equals arg1="${IKVM.present}" arg2="true"/>
    </condition>
    <condition property="ikvm.message" value="IKVM Support NOT Present">
      <not>
        <available file="${ikvmc}"/>
      </not>
    </condition>
    <condition property="ikvm.message" value="IKVM Support DISABLED">
      <not>
        <equals arg1="${IKVM.present}" arg2="true"/>
      </not>
    </condition>
    <echo message="${ikvm.message}"/>
  </target>

  <!-- =================================================================== -->
  <!-- Help on usage                                                       -->
  <!-- =================================================================== -->
  <target name="usage">
    <echo message="Use the -projecthelp option instead"/>
  </target>

  <!-- =================================================================== -->
  <!-- Compiles the source directory                                       -->
  <!-- =================================================================== -->
  <target name="compile" depends="compile-java, compile-copy-resources" description="Compiles the source code"/>

  <target name="compile-copy-resources" description="Copies the resource files into the build directory">
    <mkdir dir="${build.classes.dir}"/>
    <copy todir="${build.classes.dir}">
      <fileset dir="${src.res.dir}"/>
    </copy>
  </target>

  <target name="compile-pattern-with-codecs" depends="init" unless="internal-codecs.eff.disabled">
    <echo message="Internal codecs will be compiled."/>
    <patternset id="compile-pattern">
      <include name="**/*.java"/>
    </patternset>
  </target>
  <target name="compile-pattern-without-codecs" depends="init" if="internal-codecs.eff.disabled">
    <echo message="Internal codecs will be skipped."/>
    <patternset id="compile-pattern">
      <include name="**/*.java"/>
      <exclude name="**/image/codec/tiff/**/*.java"/>
      <exclude name="**/image/writer/internal/TIFFImageWriter*.java"/>
    </patternset>
  </target>
  <target name="compile-java" depends="init, compile-pattern-with-codecs, compile-pattern-without-codecs">
    <!-- create directories -->
    <mkdir dir="${build.classes.dir}"/>
    <javac destdir="${build.classes.dir}" fork="${javac.fork}" debug="${javac.debug}"
           deprecation="${javac.deprecation}" optimize="${javac.optimize}"
           source="${javac.source}" target="${javac.target}" includeAntRuntime="true">
      <src path="${src.java.dir}"/>
      <patternset refid="compile-pattern"/>
      <classpath refid="libs-build-classpath"/>
    </javac>
  </target>

  <!-- =================================================================== -->
  <!-- Creates JAR files                                                   -->
  <!-- =================================================================== -->

  <target name="uptodate-jar-main" depends="compile">
    <uptodate property="jar.main.uptodate" targetfile="${build.dir}/${name}.jar">
      <srcfiles dir= "${build.classes.dir}"/>
    </uptodate>
  </target>

  <target name="jar-main" depends="compile,uptodate-jar-main" description="Generates the main jar file" unless="jar.main.uptodate">
    <jar jarfile="${build.dir}/${name}-${version}.jar" basedir="${build.classes.dir}">
      <manifest>
        <attribute name="Implementation-Title" value="${Name}"/>
        <attribute name="Implementation-Version" value="${version}"/>
        <attribute name="Implementation-Vendor" value="The Apache Software Foundation (http://xmlgraphics.apache.org/)"/>
        <attribute name="Build-Id" value="${ts} (${user.name} [${os.name} ${os.version} ${os.arch}, Java ${java.runtime.version}])"/>
      </manifest>
      <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
    </jar>
  </target>

  <target name="package.NET" depends="jar-main" if="IKVM.present" description="Generates the .NET DLL using IKVM">
    <property name="commons-io" value="commons-io-1.1"/>
    <exec executable="${ikvmc}">
      <arg value="-reference:${ikvm.dir}/bin/IKVM.GNU.Classpath.dll"/>
      <arg value="-target:library"/>
      <arg value="-out:${build.dir}\${commons-io}.dll"/>
      <arg value="${lib.dir}\${commons-io}.jar"/>
    </exec>
    <exec executable="${ikvmc}">
      <arg value="-reference:${ikvm.dir}/bin/IKVM.GNU.Classpath.dll"/>
      <arg value="-reference:${build.dir}/${commons-io}.dll"/>
      <!--arg value="-reference:${ikvm.dir}/bin/IKVM.AWT.WinForms.dll"/-->
      <arg value="-target:library"/>
      <arg value="-out:${build.dir}\${name}-${version}.dll"/>
      <arg value="${build.dir}\${name}-${version}.jar"/>
    </exec>
  </target>

  <target name="uptodate-jar-sources" depends="init">
    <uptodate property="jar.sources.uptodate" targetfile="${build.dir}/${name}-${version}-sources.jar">
      <srcfiles dir="${src.java.dir}"/>
    </uptodate>
  </target>

  <target name="jar-sources" depends="uptodate-jar-sources" description="Generates a jar file with all the sources" unless="jar.sources.uptodate">
    <patternset id="java-only">
      <include name="**/*.java"/>
    </patternset>
    <jar jarfile="${build.dir}/${name}-${version}-sources.jar">
      <manifest>
        <attribute name="Build-Id" value="${ts} (${user.name} [${os.name} ${os.version} ${os.arch}, Java ${java.runtime.version}])"/>
      </manifest>
      <fileset dir="${src.java.dir}">
        <patternset refid="java-only"/>
      </fileset>
      <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
    </jar>
  </target>

  <target name="package" depends="jar-main, package.NET" description="Generates the jar files"/>

  <!-- =================================================================== -->
  <!-- Testing                                                             -->
  <!-- =================================================================== -->
  <target name="junit-init" depends="init-avail">
    <condition property="junit.formatter.brief.use">
      <istrue value="${junit.formatter.brief}"/>
    </condition>
  </target>
  <target name="junit-compile" depends="package,junit-init" if="junit.present">
    <mkdir dir="${build.dir}/test-classes"/>
    <mkdir dir="${build.dir}/test-reports"/>
    <javac destdir="${build.dir}/test-classes" fork="${javac.fork}"
           debug="${javac.debug}" deprecation="${javac.deprecation}"
           optimize="${javac.optimize}" source="${javac.source}"
           target="${javac.target}" includeAntRuntime="true">
      <src path="${test.java.dir}"/>
      <patternset refid="compile-pattern"/>
      <classpath>
        <path refid="libs-build-classpath"/>
        <fileset dir="${build.dir}">
          <include name="${name}-${version}.jar"/>
        </fileset>
      </classpath>
    </javac>
    <copy todir="${build.dir}/test-classes" includeEmptyDirs="false">
      <fileset dir="${test.res.dir}"/>
      <fileset dir="${test.java.dir}">
        <exclude name="**/*.java"/>
        <exclude name="**/*.html"/>
      </fileset>
    </copy>
  </target>
  <target name="junit-basic" depends="junit-compile" description="Runs the standard JUnit test suite" if="junit.present">
    <echo message="Running basic functionality tests"/>
    <junit haltonerror="no" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="test.junit.error" failureproperty="test.junit.failure" printsummary="${junit.printsummary}">
      <sysproperty key="basedir" value="${basedir}"/>
      <sysproperty key="jawa.awt.headless" value="true"/>
      <jvmarg value="-enableassertions"/>
      <formatter type="brief" usefile="false" if="junit.formatter.brief.use"/>
      <formatter type="plain" usefile="true"/>
      <formatter type="xml" usefile="true"/>
      <classpath>
        <pathelement location="${build.dir}/test-classes"/>
        <path refid="libs-build-classpath"/>
        <fileset dir="build">
          <include name="${name}-${version}.jar"/>
        </fileset>
      </classpath>
      <batchtest fork="${junit.fork}" todir="${build.dir}/test-reports">
        <fileset dir="${test.java.dir}">
          <include name="**/*Test*.java"/>
          <exclude name="**/*TestSuite.java"/>
          <exclude name="**/image/writer/internal/TIFFImageWriter*.java" if="internal-codecs.eff.disabled"/>
        </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="junit" depends="junit-basic" description="Runs all JUnit tests" if="junit.present">
    <fail>
      <condition>
        <or>
          <isset property="test.junit.error"/>
          <isset property="test.junit.failure"/>
        </or>
      </condition>
NOTE:
**************************************************************************
* One or more of the Junit tests had Failures or Errors or were skipped! *
*         Please check the output above for relevant messages.           *
**************************************************************************
    </fail>
    <echo>All Junit tests passed!</echo>
  </target>

  <!-- =================================================================== -->
  <!-- Creates the API documentation                                       -->
  <!-- =================================================================== -->
  <target name="javadocs" depends="init" description="Generates javadocs">
    <property name="javadoc.public"  value="false"/>
    <property name="javadoc.package" value="false"/>
    <property name="javadoc.private" value="false"/>
    <condition property="javadoc.level" value=" (level: private)">
      <equals arg1="${javadoc.private}" arg2="true"/>
    </condition>
    <condition property="javadoc.level" value=" (level: package)">
      <equals arg1="${javadoc.package}" arg2="true"/>
    </condition>
    <condition property="javadoc.level" value=" (level: public)">
      <equals arg1="${javadoc.public}" arg2="true"/>
    </condition>
    <property name="javadoc.level" value=""/>
    <echo message="Producing the javadoc files${javadoc.level}"/>
    <mkdir dir="${build.javadocs.dir}"/>

    <javadoc
        packagenames="${javadoc.packages}"
        destdir="${build.javadocs.dir}"
        author="true"
        version="true"
        windowtitle="${Name} ${version} API"
        doctitle="Apache XML Graphics Commons"
        bottom="Copyright ${year} The Apache Software Foundation. All Rights Reserved."
        overview="${src.dir}/java/org/apache/xmlgraphics/overview.html"
        use="true"
        failonerror="true"
        public="${javadoc.public}"
        package="${javadoc.package}"
        private="${javadoc.private}"
        source="${javac.source}">
      <header><![CDATA[${name} ${version}]]></header>
      <footer><![CDATA[${name} ${version}]]></footer>
      <link offline="false" href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
      <classpath>
        <path refid="libs-build-classpath"/>
        <pathelement path="${java.class.path}"/>
      </classpath>
      <sourcepath>
        <pathelement path="${src.java.dir}"/>
      </sourcepath>
      <group title="Images">
        <package name="org.apache.xmlgraphics.image"/>
        <package name="org.apache.xmlgraphics.image.*"/>
      </group>
      <group title="Java2D">
        <package name="org.apache.xmlgraphics.java2d"/>
        <package name="org.apache.xmlgraphics.java2d.*"/>
      </group>
      <group title="PDF, PostScript...">
        <package name="org.apache.xmlgraphics.ps"/>
        <package name="org.apache.xmlgraphics.ps.*"/>
        <package name="org.apache.xmlgraphics.pdf"/>
        <package name="org.apache.xmlgraphics.pdf.*"/>
      </group>
      <group title="Fonts">
        <package name="org.apache.xmlgraphics.fonts"/>
      </group>
      <group title="XMP Metadata">
        <package name="org.apache.xmlgraphics.xmp"/>
        <package name="org.apache.xmlgraphics.xmp.*"/>
      </group>
      <group title="Utility">
        <package name="org.apache.xmlgraphics.util"/>
        <package name="org.apache.xmlgraphics.util.*"/>
      </group>
    </javadoc>
  </target>

  <target name="jar-javadocs" depends="javadocs">
    <jar jarfile="${build.dir}/${name}-${version}-javadoc.jar">
      <manifest>
        <attribute name="Build-Id" value="${ts} (${user.name} [${os.name} ${os.version} ${os.arch}, Java ${java.runtime.version}])"/>
      </manifest>
      <fileset dir="${build.javadocs.dir}"/>
      <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
    </jar>
  </target>

  <!-- =================================================================== -->
  <!-- Checkstyle                                                          -->
  <!-- =================================================================== -->
  <property name="checkstyle.location" value="${optional.lib.dir}/checkstyle-5.5-all.jar" />
  <property name="checkstyle.config" value="${tools.checkstyle.dir}/checkstyle.xml" />
  <property name="checkstyle.suppressions.file" value="${tools.checkstyle.dir}/suppressions.xml" />
  <path id="checkstyle-classpath">
    <path refid="libs-build-classpath"/>
    <pathelement location="${checkstyle.location}"/>
  </path>
  <condition property="checkstyle.avail">
    <and>
      <available classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
        <classpath refid="checkstyle-classpath"/>
      </available>
      <available file="${checkstyle.config}"/>
    </and>
  </condition>
  <target name="checkstyle-avail" unless="checkstyle.avail">
    <echo message="Checkstyle support NOT present. Please download it from http://checkstyle.sf.net/ and"/>
    <echo message="... please provide ${checkstyle.location}"/>
    <echo message="... please provide ${checkstyle.config}"/>
  </target>
  <target name="checkstyle" depends="package, checkstyle-avail" if="checkstyle.avail" description="Runs Checkstyle for a code quality report">
    <taskdef name="checkstyle" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" classpathref="checkstyle-classpath"/>
    <mkdir dir="${build.dir}"/>
    <checkstyle config="${checkstyle.config}" failonviolation="true" maxWarnings="0">
      <classpath>
        <path refid="checkstyle-classpath"/>
        <pathelement location="${build.classes.dir}"/>
        <pathelement location="${build.sandbox-classes.dir}"/>
        <pathelement location="${build.codegen-classes.dir}"/>
      </classpath>
      <fileset dir="${src.dir}" includes="**/*.java"/>
      <fileset dir="${basedir}/src/test" includes="**/*.java"/>
      <formatter type="xml" toFile="${build.dir}/report_checkstyle.xml"/>
      <formatter type="plain"/>
    </checkstyle>
  </target>

  <!-- =================================================================== -->
  <!-- Creates the distribution                                            -->
  <!-- =================================================================== -->
  <target name="dist" depends="distclean,dist-src,dist-bin,maven-artifacts" description="Generates the distribution package"/>

  <!-- IMPORTANT: .NET binaries must not be included in the distribution. License policy! -->

  <target name="dist-bin" depends="all,javadocs">
    <echo message="Building the binary distribution files (zip,tar)"/>
    <mkdir dir="${dist.bin.result.dir}"/>
    <copy todir="${dist.bin.result.dir}">
      <fileset refid="dist.bin"/>
      <fileset refid="dist.bin.lib"/>
    </copy>
    <copy todir="${dist.bin.result.dir}/javadocs">
      <fileset dir="${build.javadocs.dir}"/>
    </copy>
    <mkdir dir="${dist.bin.result.dir}/build"/>
    <copy todir="${dist.bin.result.dir}/build" file="build/${name}-${version}.jar"/>

    <!--property name="bin.suffix" value="bin-jdk${java.specification.version}"/-->
    <property name="bin.suffix" value="bin"/>
    <zip zipfile="${name}-${version}-${bin.suffix}.zip" basedir="${dist.bin.dir}" includes="**"/>
    <tar longfile="gnu"
         destfile="${name}-${version}-${bin.suffix}.tar">
      <tarfileset dir="${dist.bin.dir}">
        <include name="**"/>
      </tarfileset>
    </tar>
    <gzip zipfile="${name}-${version}-${bin.suffix}.tar.gz" src="${name}-${version}-${bin.suffix}.tar"/>
    <delete file="${name}-${version}-${bin.suffix}.tar"/>
  </target>

  <target name="dist-src" depends="all">
    <echo message="Building the source distribution files (zip,tar)"/>
    <mkdir dir="${dist.src.result.dir}"/>
    <copy todir="${dist.src.result.dir}">
      <fileset refid="dist.src"/>
    </copy>

    <zip zipfile="${name}-${version}-src.zip">
      <zipfileset dir="${dist.src.dir}" filemode="644" dirmode="755">
        <include name="**"/>
      </zipfileset>
    </zip>
    <tar longfile="gnu"
         destfile="${name}-${version}-src.tar" >
      <tarfileset dir="${dist.src.dir}" mode="644" dirmode="755">
        <include name="**"/>
      </tarfileset>
    </tar>
    <gzip zipfile="${name}-${version}-src.tar.gz" src="${name}-${version}-src.tar"/>
    <delete file="${name}-${version}-src.tar"/>
  </target>

  <target name="release-dist" depends="dist" description="Generates the distribution package and signs the release">
    <!--property name="bin.suffix" value="bin-jdk${java.specification.version}"/-->
    <property name="bin.suffix" value="bin"/>
    <input message="Passphrase for your default private key (attention: passphrase will be echoed in clear text on the display!)" addproperty="pwd"/>
    <antcall target="sha512">
      <param name="sign.archive" value="${name}-${version}-src.zip"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${name}-${version}-src.zip"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="sha512">
      <param name="sign.archive" value="${name}-${version}-src.tar.gz"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${name}-${version}-src.tar.gz"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="sha512">
      <param name="sign.archive" value="${name}-${version}-${bin.suffix}.zip"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${name}-${version}-${bin.suffix}.zip"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="sha512">
      <param name="sign.archive" value="${name}-${version}-${bin.suffix}.tar.gz"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${name}-${version}-${bin.suffix}.tar.gz"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
  </target>

  <target name="sha512">
    <property name="sha512.exec" value="sha512sum"/>
    <property name="sha512.options" value=""/>
    <exec executable="${sha512.exec}" output="${sign.archive}.sha512">
      <arg line="${sha512.options} ${sign.archive}"/>
    </exec>
  </target>

  <target name="sign-file">
    <property name="gpg.exec" value="gpg"/>
    <property name="gpg.options" value="--armor --detach-sign --force-v3-sigs --batch --verbose --passphrase-fd 0"/>
    <delete file="${sign.archive}.asc"/>
    <exec executable="${gpg.exec}" inputstring="${pwd}">
      <arg line="${gpg.options} ${sign.archive}"/>
    </exec>
  </target>
  
  <!-- =================================================================== -->
  <!-- Maven artifacts                                                     -->
  <!-- =================================================================== -->
  <target name="maven-artifacts" depends="jar-main, jar-sources, jar-javadocs" description="Builds a Maven artifact that can be uploaded to a Maven repository">
    <filter  token="version" value="${version}"/>
    <mkdir dir="${build.dir}/maven"/>
    <copy file="${basedir}/xmlgraphics-commons-pom-template.pom" tofile="${build.dir}/maven/pom.xml" filtering="true"/>
    <fileset id="bundle-files" dir="${build.dir}">
      <patternset>
      <include name="${name}-${version}.jar"/>
      <include name="${name}-${version}-sources.jar"/>
      <include name="${name}-${version}-javadoc.jar"/>
      </patternset>
      <patternset>
      <include name="maven/pom.xml"/>
      </patternset>
    </fileset>
    <checksum algorithm="sha-512" fileext=".sha512">
      <fileset refid="bundle-files"/>
    </checksum>
    <input message="Passphrase for your default private key (attention: passphrase will be echoed in clear text on the display!)" addproperty="pwd"/>
    <antcall target="sign-file">
      <param name="sign.archive" value="${build.dir}/${name}-${version}.jar"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${build.dir}/${name}-${version}-sources.jar"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${build.dir}/${name}-${version}-javadoc.jar"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${build.dir}/maven/pom.xml"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <jar jarfile="${build.dir}/${name}-${version}-bundle.jar">
      <manifest>
        <attribute name="Build-Id" value="${ts} (${user.name} [${os.name} ${os.version} ${os.arch}, Java ${java.runtime.version}])"/>
      </manifest>
      <fileset dir="${build.dir}">
        <patternset>
          <include name="${name}-${version}.jar*"/>
          <include name="${name}-${version}-sources.jar*"/>
          <include name="${name}-${version}-javadoc.jar*"/>
        </patternset>
      </fileset>
      <fileset dir="${build.dir}/maven">
        <patternset>
          <include name="pom.xml*"/>
        </patternset>
      </fileset>
      <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
    </jar>
    <move file="${build.dir}/${name}-${version}-bundle.jar" todir="${basedir}"/>
  </target>
  
  <!-- =================================================================== -->
  <!-- Clean targets                                                       -->
  <!-- =================================================================== -->
  <target name="clean" description="Cleans the build directory">
    <delete dir="${build.dir}"/>
  </target>

  <target name="distclean" depends="clean" description="Cleans the distribution target directories">
    <delete dir="${dist.src.dir}"/>
    <delete dir="${dist.bin.dir}"/>
    <delete>
      <fileset dir="${basedir}" includes="${name}-*.tar.gz*"/>
      <fileset dir="${basedir}" includes="${name}-*.zip*"/>
      <fileset dir="${basedir}" includes="${name}-*-bundle.jar*"/>
    </delete>
  </target>
  
  <!-- =================================================================== -->
  <!-- Default Target                                                      -->
  <!-- =================================================================== -->

  <target name="all" depends="package, junit"/> <!-- "all" target for us Makefile converts ;-) -->

  <!-- =================================================================== -->
  <!-- Special target for Gump                                             -->
  <!-- =================================================================== -->

  <target name="gump" depends="all, javadocs"/>

<!-- =================================================================== -->
<!-- Findbugs                                                            -->
<!-- =================================================================== -->
  <property name="findbugs.lib" value="${findbugs.home.dir}/lib"/>
  <path id="libs-findbugs">
    <fileset dir="${findbugs.lib}">
      <include name="*.jar"/>
    </fileset>
  </path>
  <target name="findbugs-avail" unless="findbugs.home.dir">
    <echo message="Findbugs Support NOT Present. Please download it from http://findbugs.sf.net/ and set findbugs.home.dir in build-local.properties"/>
  </target>
  <target name="findbugs" depends="init, findbugs-avail, compile-java" if="findbugs.home.dir">
    <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="libs-findbugs"/>
    <findbugs home="${findbugs.home.dir}" output="text" reportLevel="low" effort="max" excludeFilter="${tools.findbugs.dir}/exclusions.xml" jvmargs="-Xmx1024m" warningsProperty="findbugs.warnings">
      <sourcePath path="${src.java.dir}"/>
      <class location="${build.classes.dir}"/>
      <auxClasspath>
        <path refid="libs-build-classpath"/>
        <path>
          <fileset dir="${ant.library.dir}">
            <include name="ant.jar"/>
            <include name="ant-launcher.jar"/>
          </fileset>
        </path>
      </auxClasspath>
    </findbugs>
    <fail if="findbugs.warnings"/>
  </target>  

</project>