1 <?xml version="1.0" encoding="UTF-8"?>
6 Apache Ant [ http://ant.apache.org/ ] 1.7 以降用に記述されています。
8 ※各種IDEのビルドファイルと衝突させないため、
9 意図して一般的でないビルドファイル名にしてあります。
10 ant の -buildfile オプションを使ってください。
12 Copyright(c) 2009 olyutorskii
13 $Id: antbuild.xml 879 2009-10-25 15:42:50Z olyutorskii $
16 <project name="JinArchiver" default="compile">
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" />
31 <property name="entrymain" value="${package}.JinArchiver" />
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" />
45 <property name="build.compiler" value="modern" />
46 <property name="build.compiler.emacs" value="true" />
47 <property name="build.compiler.pedantic" value="true" />
49 <property name="docscope" value="protected" />
52 value="http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/"
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/"
61 <macrodef name="propertycopy">
62 <attribute name="name" />
63 <attribute name="from" />
65 <property name="@{name}" value="${@{from}}" />
69 <macrodef name="defunset">
70 <attribute name="name" />
72 <condition property="@{name}" value="">
74 <isset property="@{name}" />
80 <property environment="myenv" />
81 <macrodef name="envprop">
82 <attribute name="name" />
83 <attribute name="envname" />
85 <condition property="@{name}" value="${myenv.@{envname}}">
88 <isset property="@{name}" />
90 <isset property="myenv.@{envname}" />
93 <defunset name="@{name}" />
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" />
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" />
106 <path id="junit.path">
107 <fileset dir="${junit.home}" includes="*.jar, lib/*.jar" />
110 <path id="findbugs.path">
111 <fileset dir="${findbugs.home}" includes="*.jar, lib/*.jar" />
115 <fileset dir="${pmd.home}" includes="*.jar, lib/*.jar" />
118 <path id="checkstyle.path">
119 <fileset dir="${checkstyle.home}" includes="*.jar, lib/*.jar" />
123 <propertyset id="pkgversions" dynamic="true">
124 <propertyref regex="^pkg\-version\..*$" />
128 <fileset id="xmlresources" dir="${src}">
129 <include name="**/*.xsd" />
130 <include name="**/*.xml" />
133 <fileset id="garbagefiles" dir="${basedir}" defaultexcludes="off">
134 <include name="**/.DS_Store" />
135 <include name="**/Thumbs.db" />
136 <include name="**/core" />
138 <defaultexcludes add="**/.DS_Store" />
139 <defaultexcludes add="**/Thumbs.db" />
140 <defaultexcludes add="**/core" />
143 <target name="init" description="initialize">
144 <echo message="initializing..." />
147 <target description="validate XML-resources"
148 name="xmlvalidate" depends="init"
150 <echo message="validating XML resources..." />
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" />
160 <schemavalidate warn="on" fullchecking="on" >
162 namespace="http://www.w3.org/2001/XMLSchema"
163 url="http://www.w3.org/2001/XMLSchema.xsd"
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" />
173 <target description="compile java-files"
174 name="compile" depends="init"
176 <echo message="compiling Java sources..." />
178 <mkdir dir="${classes}" />
183 target="1.5" debug="on"
186 <compilerarg compiler="modern" line="-source 1.5" />
187 <compilerarg compiler="modern" line="-Xlint" />
188 <src path="${src}" />
189 <include name="**/*.java" />
192 <copy todir="${classes}">
193 <fileset dir="${src}">
194 <exclude name="**/*.java" />
199 <target description="compile tests pg"
200 name="testcompile" depends="compile"
202 <echo message="compiling Junit tests..." />
204 <mkdir dir="${testclasses}" />
207 destdir="${testclasses}"
209 target="1.5" debug="on"
212 <compilerarg compiler="modern" line="-source 1.5" />
213 <compilerarg compiler="modern" line="-Xlint" />
215 <path path="${classes}" />
216 <path refid="junit.path" />
218 <src path="${testsrc}" />
219 <include name="**/*.java" />
222 <copy todir="${testclasses}">
223 <fileset dir="${testsrc}">
224 <exclude name="**/*.java" />
229 <!-- JUnit [ http://www.junit.org/ ] -->
230 <target description="JUnit test"
231 name="test" depends="testcompile"
233 <echo message="JUnit testing..." />
237 fork="on" forkmode="once"
238 tempdir="${java.io.tmpdir}"
241 <path path="${classes}" />
242 <path path="${testclasses}" />
243 <path refid="junit.path" />
246 <assertions enableSystemAssertions="true">
251 <fileset dir="${testsrc}">
252 <include name="**/*Test.java" />
253 <include name="**/Test*.java" />
259 <!-- FindBugs [ http://findbugs.sourceforge.net/ ] -->
260 <target description="bytecode analysis"
261 name="findbugs" depends="compile"
263 <echo message="code analysis with FindBugs..." />
267 classpathref="findbugs.path"
268 classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
272 home="${findbugs.home}"
276 excludeFilter="${findbugs.filter}"
279 <sourcePath path="${src}" />
280 <class location="${classes}" />
284 <!-- PMD [ http://pmd.sourceforge.net/ ] -->
285 <target description="sourcecode analysis"
286 name="pmd" depends="compile"
288 <echo message="code analysis with PMD..." />
292 classpathref="pmd.path"
293 classname="net.sourceforge.pmd.ant.PMDTask"
297 targetjdk="1.5" encoding="UTF-8"
298 rulesetfiles="${pmd.rules}"
301 <formatter type="csv" toConsole="true" />
302 <fileset dir="${src}">
303 <include name="**/*.java" />
308 <!-- Checkstyle [ http://checkstyle.sourceforge.net/ ] -->
309 <target description="check source-code..."
310 name="checkstyle" depends="compile"
312 <echo message="check code style..." />
315 classpathref="checkstyle.path"
316 resource="checkstyletask.properties"
319 <checkstyle config="${checkstyle.checks}" classpath="${classes}">
320 <fileset dir="${src}">
321 <include name="**/*.java" />
326 <target description="resolve depend package info"
327 name="resolvedependpkg" depends="init"
330 property="depversion.temp"
334 destdir="${java.io.tmpdir}"
337 <concat destfile="${depversion.temp}" fixlastline="on">
338 <fileset dir="${src}">
339 <include name="**/resources/version.properties" />
343 <property file="${depversion.temp}" />
344 <fail unless="pkg-version.${package}">
345 There is no version definition about package [${package}].
347 <propertycopy name="thisversion" from="pkg-version.${package}" />
348 <echo message="This package was defined as ${thisversion}" />
350 <echoproperties destfile="${depversion.temp}" failonerror="on">
351 <propertyset refid="pkgversions" />
354 <concat destfile="${depinfo}">
357 <comment value="#" />
362 trimleading="on" filtering="off"
363 file="${scripts}/depheader.properties"
366 <fileset file="${depversion.temp}" />
369 trimleading="on" filtering="off"
370 file="${scripts}/depfooter.properties"
374 <delete file="${depversion.temp}" />
377 <target description="build jar-file"
378 name="jar" depends="sanitize, resolvedependpkg, compile"
380 <echo message="building JAR archive..." />
384 location="${dist}/${jarbase}-${thisversion}.jar"
387 <delete file="${jarname}" />
388 <mkdir dir="${dist}" />
392 destfile="${jarname}"
402 name="Implementation-Title"
406 name="Implementation-Vendor"
410 name="Implementation-Version"
411 value="${thisversion}"
421 <target description="build javadoc-documents"
422 name="javadocs" depends="init"
424 <echo message="generating javadoc HTML pages..." />
427 doctitle="${doctitle}" windowtitle="${doctitle}"
429 source="1.5" encoding="UTF-8"
430 charset="UTF-8" docencoding="UTF-8"
435 <package name="${package}" />
436 <link href="${jdkhref}" />
437 <fileset dir="${src}">
438 <include name="**/*.java" />
443 <target description="remove garbage files"
444 name="clean-garbage" depends="init"
446 <echo message="cleaning garbages..." />
447 <delete verbose="true">
448 <fileset refid="garbagefiles" />
452 <target description="invoke main entry"
453 name="invokemain" depends="compile, testcompile"
455 <echo message="invoke main entry..." />
457 <fail unless="mainclass" />
459 <defunset name="linearg" />
461 <java classname="${mainclass}" fork="true">
462 <arg line="${linearg}" />
464 <pathelement path="${classes}" />
465 <pathelement path="${testclasses}" />
467 <assertions enableSystemAssertions="true">
473 <target description="sanitize files"
474 name="sanitize" depends="clean-garbage"
476 <echo message="sanitize now..." />
479 srcDir="${src}" includes="**/*.java"
480 encoding="UTF-8" outputencoding="UTF-8"
481 tablength="4" tab="remove" javafiles="true"
486 srcDir="${testsrc}" includes="**/*.java"
487 encoding="UTF-8" outputencoding="UTF-8"
488 tablength="4" tab="remove" javafiles="true"
493 srcDir="${src}" includes="**/*.xml,**/*.xsd"
494 encoding="UTF-8" outputencoding="UTF-8"
495 tablength="8" tab="remove"
501 srcDir="${testsrc}" includes="**/*.xml,**/*.xsd"
502 encoding="UTF-8" outputencoding="UTF-8"
503 tablength="8" tab="remove"
509 srcDir="${scripts}" includes="**/*.xml,**/*.xsd"
510 encoding="UTF-8" outputencoding="UTF-8"
511 tablength="8" tab="remove"
517 srcDir="${src}" includes="**/*.properties"
518 encoding="ISO-8859-1" outputencoding="ISO-8859-1"
523 srcDir="${testsrc}" includes="**/*.properties"
524 encoding="ISO-8859-1" outputencoding="ISO-8859-1"
529 srcDir="${scripts}" includes="**/*.properties"
530 encoding="ISO-8859-1" outputencoding="ISO-8859-1"
536 encoding="ISO-8859-1" outputencoding="ISO-8859-1"
540 <chmod type="file" perm="a-x">
541 <fileset dir="${basedir}" includes="**/*" excludes="**/*.sh" />
545 <target description="clean-up"
546 name="clean" depends="clean-garbage"
548 <echo message="cleaning now..." />
549 <delete dir="${build}" />
550 <delete dir="${dist}" />
551 <delete dir="${javadoc}" />
554 <target description="All"
555 name="all" depends="xmlvalidate, test, jar, javadocs"
558 <target description="synonym for (compile)"
559 name="build" depends="compile"
562 <target description="synonym for (jar)"
563 name="deploy" depends="jar"
566 <target description="synonym for (javadocs)"
567 name="docs" depends="javadocs"
570 <target description="synonym for (all)"
571 name="main" depends="all"