OSDN Git Service

JinParser 1.407.2版に対応。
[jindolf/JinArchiver.git] / antbuild.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!--
4     JinArchiverビルドファイル
5
6     Apache Ant [ http://ant.apache.org/ ] 1.7 以降用に記述されています。
7
8     ※各種IDEのビルドファイルと衝突させないため、
9     意図して一般的でないビルドファイル名にしてあります。
10     ant の -buildfile オプションを使ってください。
11
12     Copyright(c) 2009 olyutorskii
13     $Id: antbuild.xml 879 2009-10-25 15:42:50Z olyutorskii $
14 -->
15
16 <project name="JinArchiver" default="compile">
17
18     <tstamp />
19
20     <description>
21         JinArchive build-file
22     </description>
23
24
25     <property name="title"    value="JinArchiver"                        />
26     <property name="package"  value="jp.sourceforge.jindolf.archiver"         />
27     <property name="jarbase"  value="jinarchiver"                        />
28     <property name="vendor"   value="olyutorskii"                    />
29     <property name="doctitle" value="${title} document"              />
30
31     <property name="entrymain" value="${package}.JinArchiver" />
32
33
34     <property name="src"         location="src/"                   />
35     <property name="testsrc"     location="test/"                  />
36     <property name="build"       location="build/"                 />
37     <property name="classes"     location="${build}/classes/"      />
38     <property name="testclasses" location="${build}/test/classes/" />
39     <property name="dist"        location="dist/"                  />
40     <property name="javadoc"     location="${dist}/javadoc/"       />
41     <property name="scripts"     location="scripts/"               />
42     <property name="depinfo"     location="depend.properties"      />
43
44
45     <property name="build.compiler"          value="modern" />
46     <property name="build.compiler.emacs"    value="true"   />
47     <property name="build.compiler.pedantic" value="true"   />
48
49     <property name="docscope" value="protected" />
50     <property
51         name="jdkhref"
52         value="http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/"
53     />
54 <!--
55         value="http://java.sun.com/j2se/1.5.0/docs/api/"
56         value="http://java.sun.com/javase/6/docs/api/"
57         value="http://java.sun.com/javase/6/docs/ja/api/"
58 -->
59
60
61     <macrodef name="propertycopy">
62         <attribute name="name" />
63         <attribute name="from" />
64         <sequential>
65             <property name="@{name}" value="${@{from}}" />
66         </sequential>
67     </macrodef>
68
69     <macrodef name="defunset">
70         <attribute name="name" />
71         <sequential>
72             <condition property="@{name}" value="">
73                 <not>
74                     <isset property="@{name}" />
75                 </not>
76             </condition>
77         </sequential>
78     </macrodef>
79
80     <property environment="myenv" />
81     <macrodef name="envprop">
82         <attribute name="name" />
83         <attribute name="envname" />
84         <sequential>
85             <condition property="@{name}" value="${myenv.@{envname}}">
86                 <and>
87                     <not>
88                         <isset property="@{name}" />
89                     </not>
90                     <isset property="myenv.@{envname}" />
91                 </and>
92             </condition>
93             <defunset name="@{name}" />
94         </sequential>
95     </macrodef>
96
97     <envprop name="junit.home"      envname="JUNIT_HOME"      />
98     <envprop name="findbugs.home"   envname="FINDBUGS_HOME"   />
99     <envprop name="pmd.home"        envname="PMD_HOME"        />
100     <envprop name="checkstyle.home" envname="CHECKSTYLE_HOME" />
101
102     <property name="findbugs.filter"   location="${scripts}/fbexfilter.xml" />
103     <property name="pmd.rules"         location="${scripts}/pmdrules.xml"   />
104     <property name="checkstyle.checks" location="${scripts}/checks.xml"     />
105
106     <path id="junit.path">
107         <fileset dir="${junit.home}" includes="*.jar, lib/*.jar" />
108     </path>
109
110     <path id="findbugs.path">
111         <fileset dir="${findbugs.home}" includes="*.jar, lib/*.jar" />
112     </path>
113
114     <path id="pmd.path">
115         <fileset dir="${pmd.home}" includes="*.jar, lib/*.jar" />
116     </path>
117
118     <path id="checkstyle.path">
119         <fileset dir="${checkstyle.home}" includes="*.jar, lib/*.jar" />
120     </path>
121
122
123     <propertyset id="pkgversions" dynamic="true">
124         <propertyref regex="^pkg\-version\..*$" />
125     </propertyset>
126
127
128     <fileset id="xmlresources" dir="${src}">
129         <include name="**/*.xsd" />
130         <include name="**/*.xml" />
131     </fileset>
132
133     <fileset id="garbagefiles" dir="${basedir}" defaultexcludes="off">
134         <include name="**/.DS_Store" />
135         <include name="**/Thumbs.db" />
136         <include name="**/core" />
137     </fileset>
138     <defaultexcludes add="**/.DS_Store" />
139     <defaultexcludes add="**/Thumbs.db" />
140     <defaultexcludes add="**/core" />
141
142
143     <target name="init" description="initialize">
144         <echo message="initializing..." />
145     </target>
146
147     <target description="validate XML-resources"
148         name="xmlvalidate" depends="init"
149     >
150         <echo message="validating XML resources..." />
151
152         <xmlvalidate warn="on">
153             <attribute name="http://xml.org/sax/features/validation" value="true" />
154             <attribute name="http://apache.org/xml/features/validation/schema-full-checking" value="true" />
155             <attribute name="http://apache.org/xml/features/validation/dynamic" value="true" />
156             <attribute name="http://apache.org/xml/features/validation/warn-on-undeclared-elemdef" value="true" />
157             <fileset refid="xmlresources" />
158         </xmlvalidate>
159
160         <schemavalidate warn="on" fullchecking="on" >
161             <schema
162                 namespace="http://www.w3.org/2001/XMLSchema"
163                 url="http://www.w3.org/2001/XMLSchema.xsd"
164             />
165             <attribute name="http://xml.org/sax/features/validation" value="true" />
166             <attribute name="http://apache.org/xml/features/validation/schema-full-checking" value="true" />
167             <attribute name="http://apache.org/xml/features/validation/dynamic" value="true" />
168             <attribute name="http://apache.org/xml/features/validation/warn-on-undeclared-elemdef" value="true" />
169             <fileset refid="xmlresources" />
170         </schemavalidate>
171     </target>
172
173     <target description="compile java-files"
174         name="compile" depends="init"
175     >
176         <echo message="compiling Java sources..." />
177
178         <mkdir dir="${classes}" />
179
180         <javac
181             destdir="${classes}"
182             encoding="UTF-8"
183             target="1.5" debug="on"
184             deprecation="on"
185         >
186             <compilerarg compiler="modern" line="-source 1.5" />
187             <compilerarg compiler="modern" line="-Xlint" />
188             <src path="${src}" />
189             <include name="**/*.java" />
190         </javac>
191
192         <copy todir="${classes}">
193             <fileset dir="${src}">
194                 <exclude name="**/*.java" />
195             </fileset>
196         </copy>
197     </target>
198
199     <target description="compile tests pg"
200         name="testcompile" depends="compile"
201     >
202         <echo message="compiling Junit tests..." />
203
204         <mkdir dir="${testclasses}" />
205
206         <javac
207             destdir="${testclasses}"
208             encoding="UTF-8"
209             target="1.5" debug="on"
210             deprecation="on"
211         >
212             <compilerarg compiler="modern" line="-source 1.5" />
213             <compilerarg compiler="modern" line="-Xlint" />
214             <classpath>
215                 <path path="${classes}" />
216                 <path refid="junit.path" />
217             </classpath>
218             <src path="${testsrc}" />
219             <include name="**/*.java" />
220         </javac>
221
222         <copy todir="${testclasses}">
223             <fileset dir="${testsrc}">
224                 <exclude name="**/*.java" />
225             </fileset>
226         </copy>
227     </target>
228
229     <!-- JUnit [ http://www.junit.org/ ] -->
230     <target description="JUnit test"
231         name="test" depends="testcompile"
232     >
233         <echo message="JUnit testing..." />
234
235         <junit
236             printsummary="on"
237             fork="on" forkmode="once"
238             tempdir="${java.io.tmpdir}"
239         >
240             <classpath>
241                 <path path="${classes}" />
242                 <path path="${testclasses}" />
243                 <path refid="junit.path" />
244             </classpath>
245
246             <assertions enableSystemAssertions="true">
247                 <enable />
248             </assertions>
249
250             <batchtest>
251                 <fileset dir="${testsrc}">
252                     <include name="**/*Test.java" />
253                     <include name="**/Test*.java" />
254                 </fileset>
255             </batchtest>
256         </junit>
257     </target>
258
259     <!-- FindBugs [ http://findbugs.sourceforge.net/ ] -->
260     <target description="bytecode analysis"
261         name="findbugs" depends="compile"
262     >
263         <echo message="code analysis with FindBugs..." />
264
265         <taskdef
266             name="findbugs"
267             classpathref="findbugs.path"
268             classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
269         />
270
271         <findbugs
272             home="${findbugs.home}"
273             output="emacs"
274             reportLevel="low"
275             effort="max"
276             excludeFilter="${findbugs.filter}"
277             jvmargs="-Xmx256m"
278         >
279             <sourcePath path="${src}" />
280             <class location="${classes}" />
281         </findbugs>
282     </target>
283
284     <!-- PMD [ http://pmd.sourceforge.net/ ] -->
285     <target description="sourcecode analysis"
286         name="pmd" depends="compile"
287     >
288         <echo message="code analysis with PMD..." />
289
290         <taskdef
291             name="pmd"
292             classpathref="pmd.path"
293             classname="net.sourceforge.pmd.ant.PMDTask"
294         />
295
296         <pmd
297             targetjdk="1.5" encoding="UTF-8"
298             rulesetfiles="${pmd.rules}"
299             shortFilenames="on"
300         >
301             <formatter type="csv" toConsole="true" />
302             <fileset dir="${src}">
303                 <include name="**/*.java" />
304             </fileset>
305         </pmd>
306     </target>
307
308     <!-- Checkstyle [ http://checkstyle.sourceforge.net/ ] -->
309     <target description="check source-code..."
310         name="checkstyle" depends="compile"
311     >
312         <echo message="check code style..." />
313
314         <taskdef
315             classpathref="checkstyle.path"
316             resource="checkstyletask.properties"
317         />
318
319         <checkstyle config="${checkstyle.checks}" classpath="${classes}">
320             <fileset dir="${src}">
321                 <include name="**/*.java" />
322             </fileset>
323         </checkstyle>
324     </target>
325
326     <target description="resolve depend package info"
327         name="resolvedependpkg" depends="init"
328     >
329         <tempfile
330             property="depversion.temp"
331             prefix="version"
332             suffix=".properties"
333             deleteonexit="on"
334             destdir="${java.io.tmpdir}"
335         />
336
337         <concat destfile="${depversion.temp}" fixlastline="on">
338             <fileset dir="${src}">
339                 <include name="**/resources/version.properties" />
340             </fileset>
341         </concat>
342
343         <property file="${depversion.temp}" />
344         <fail unless="pkg-version.${package}">
345             There is no version definition about package [${package}].
346         </fail>
347         <propertycopy name="thisversion" from="pkg-version.${package}" />
348         <echo message="This package was defined as ${thisversion}" />
349
350         <echoproperties destfile="${depversion.temp}" failonerror="on">
351             <propertyset refid="pkgversions" />
352         </echoproperties>
353
354         <concat destfile="${depinfo}">
355             <filterchain>
356                 <striplinecomments>
357                     <comment value="#" />
358                 </striplinecomments>
359             </filterchain>
360
361             <header
362                 trimleading="on" filtering="off"
363                 file="${scripts}/depheader.properties"
364             />
365
366             <fileset file="${depversion.temp}" />
367
368             <footer
369                 trimleading="on" filtering="off"
370                 file="${scripts}/depfooter.properties"
371             />
372         </concat>
373
374         <delete file="${depversion.temp}" />
375     </target>
376
377     <target description="build jar-file"
378         name="jar" depends="sanitize, resolvedependpkg, compile"
379     >
380         <echo message="building JAR archive..." />
381
382         <property
383             name="jarname"
384             location="${dist}/${jarbase}-${thisversion}.jar"
385         />
386
387         <delete file="${jarname}" />
388         <mkdir dir="${dist}" />
389
390         <jar
391             basedir="${classes}"
392             destfile="${jarname}"
393             compress="on"
394             strict="fail"
395         >
396             <manifest>
397                 <attribute
398                     name="Main-Class"
399                     value="${entrymain}"
400                 />
401                 <attribute
402                     name="Implementation-Title"
403                     value="${title}"
404                 />
405                 <attribute
406                     name="Implementation-Vendor"
407                     value="${vendor}"
408                 />
409                 <attribute
410                     name="Implementation-Version"
411                     value="${thisversion}"
412                 />
413                 <attribute
414                     name="Sealed"
415                     value="true"
416                 />
417             </manifest>
418         </jar>
419     </target>
420
421     <target description="build javadoc-documents"
422         name="javadocs" depends="init"
423     >
424         <echo message="generating javadoc HTML pages..." />
425
426         <javadoc
427             doctitle="${doctitle}" windowtitle="${doctitle}"
428             destdir="${javadoc}"
429             source="1.5" encoding="UTF-8"
430             charset="UTF-8" docencoding="UTF-8"
431             access="${docscope}"
432             use="on"
433             failonerror="true"
434         >
435             <package name="${package}" />
436             <link href="${jdkhref}" />
437             <fileset dir="${src}">
438                 <include name="**/*.java" />
439             </fileset>
440         </javadoc>
441     </target>
442
443     <target description="remove garbage files"
444         name="clean-garbage" depends="init"
445     >
446         <echo message="cleaning garbages..." />
447         <delete verbose="true">
448             <fileset refid="garbagefiles" />
449         </delete>
450     </target>
451
452     <target description="invoke main entry"
453         name="invokemain" depends="compile, testcompile"
454     >
455         <echo message="invoke main entry..." />
456
457         <fail unless="mainclass" />
458
459         <defunset name="linearg" />
460
461         <java classname="${mainclass}" fork="true">
462             <arg line="${linearg}" />
463             <classpath>
464                 <pathelement path="${classes}" />
465                 <pathelement path="${testclasses}" />
466             </classpath>
467             <assertions enableSystemAssertions="true">
468                 <enable />
469             </assertions>
470         </java>
471     </target>
472
473     <target description="sanitize files"
474         name="sanitize" depends="clean-garbage"
475     >
476         <echo message="sanitize now..." />
477
478         <fixcrlf
479             srcDir="${src}" includes="**/*.java"
480             encoding="UTF-8" outputencoding="UTF-8"
481             tablength="4" tab="remove" javafiles="true"
482             eof="remove"
483         />
484
485         <fixcrlf
486             srcDir="${testsrc}" includes="**/*.java"
487             encoding="UTF-8" outputencoding="UTF-8"
488             tablength="4" tab="remove" javafiles="true"
489             eof="remove"
490         />
491
492         <fixcrlf
493             srcDir="${src}" includes="**/*.xml,**/*.xsd"
494             encoding="UTF-8" outputencoding="UTF-8"
495             tablength="8" tab="remove"
496             eol="lf"
497             eof="remove"
498         />
499
500         <fixcrlf
501             srcDir="${testsrc}" includes="**/*.xml,**/*.xsd"
502             encoding="UTF-8" outputencoding="UTF-8"
503             tablength="8" tab="remove"
504             eol="lf"
505             eof="remove"
506         />
507
508         <fixcrlf
509             srcDir="${scripts}" includes="**/*.xml,**/*.xsd"
510             encoding="UTF-8" outputencoding="UTF-8"
511             tablength="8" tab="remove"
512             eol="lf"
513             eof="remove"
514         />
515
516         <fixcrlf
517             srcDir="${src}" includes="**/*.properties"
518             encoding="ISO-8859-1" outputencoding="ISO-8859-1"
519             eof="remove"
520         />
521
522         <fixcrlf
523             srcDir="${testsrc}" includes="**/*.properties"
524             encoding="ISO-8859-1" outputencoding="ISO-8859-1"
525             eof="remove"
526         />
527
528         <fixcrlf
529             srcDir="${scripts}" includes="**/*.properties"
530             encoding="ISO-8859-1" outputencoding="ISO-8859-1"
531             eof="remove"
532         />
533
534         <fixcrlf
535             file="${depinfo}"
536             encoding="ISO-8859-1" outputencoding="ISO-8859-1"
537             eof="remove"
538         />
539
540         <chmod type="file" perm="a-x">
541             <fileset dir="${basedir}" includes="**/*" excludes="**/*.sh" />
542         </chmod>
543     </target>
544
545     <target description="clean-up"
546         name="clean" depends="clean-garbage"
547     >
548         <echo message="cleaning now..." />
549         <delete dir="${build}" />
550         <delete dir="${dist}" />
551         <delete dir="${javadoc}" />
552     </target>
553
554     <target description="All"
555         name="all" depends="xmlvalidate, test, jar, javadocs"
556     />
557
558     <target description="synonym for (compile)"
559         name="build" depends="compile"
560     />
561
562     <target description="synonym for (jar)"
563         name="deploy" depends="jar"
564     />
565
566     <target description="synonym for (javadocs)"
567         name="docs" depends="javadocs"
568     />
569
570     <target description="synonym for (all)"
571         name="main" depends="all"
572     />
573
574 </project>
575
576 <!-- EOF -->