source: branches/4.0.0/java.xml @ 4872

Revision 4872, 6.0 KB checked in by melissa, 11 years ago (diff)

Synced 4.0.0 branch with trunk, excluding r4804.

Line 
1<!--
2java.xml
3
4Ant build file for logic common to Java components.
5Download Apache Ant from http://ant.apache.org/.
6Type "ant -p" for a list of targets.
7-->
8
9<project>
10  <import file="common.xml"/>
11
12  <!-- Non-core ant tasks -->
13
14  <!-- NB - We do not reference ${artifact.dir}/loci-checks.jar directly,
15    as doing so causes loci-checks.jar to be locked by some file systems
16    (Windows in particular), which causes the clean and clean-jars targets
17    to fail. -->
18  <taskdef resource="checkstyletask.properties"
19    classpath="${lib.dir}/checkstyle-all-4.2.jar:${lib.dir}/loci-checks.jar"/>
20
21  <taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties"
22    classpath="${lib.dir}/findbugs-ant.jar"/>
23
24  <!--
25  <taskdef resource="proguard/ant/task.properties"
26    classpath="${lib.dir}/proguard.jar"/>
27  -->
28
29  <!-- Main build targets -->
30
31  <target name="compile" depends="copy-source" description="compile classes">
32    <javac debug="true" deprecation="true"
33      source="${component.java-version}"
34      target="${component.java-version}"
35      srcdir="${dest.dir}" destdir="${classes.dir}"
36      classpath="${component.classpath}"
37      includes="${component.source}"/>
38  </target>
39
40  <target name="exec" depends="compile" description="execute package">
41    <java fork="true" classname="${component.main-class}"
42      classpath="${classes.dir}:${component.runtime-cp}"/>
43  </target>
44
45  <target name="findbugs" depends="compile"
46    description="check source code for bugs">
47    <if>
48      <isset property="findbugs.home"/>
49      <then>
50        <findbugs home="${findbugs.home}" jvmargs="-Xmx512m"
51          output="xml" outputFile="${build.dir}/findbugs.xml">
52          <auxClasspath path="${component.classpath}"/>
53          <sourcePath path="${dest.dir}"/>
54          <class location="${classes.dir}"/>
55        </findbugs>
56        <java jar="${findbugs.home}/findbugs.jar" fork="true">
57          <arg value="${build.dir}/findbugs.xml"/>
58        </java>
59      </then>
60      <else>
61<echo>
62Please set the findbugs.home property to point to
63your FindBugs installation's lib directory. E.g.:
64  ant -Dfindbugs.home=${user.home}/findbugs/lib findbugs
65</echo>
66        <fail message="FindBugs not found."/>
67      </else>
68    </if>
69  </target>
70
71  <target name="style" depends="compile"
72    description="check source code style">
73    <checkstyle config="${root.dir}/checkstyle.xml" failOnViolation="false"
74      classpath="${classes.dir}:${component.classpath}">
75      <fileset dir="${dest.dir}" includes="${component.source}"/>
76    </checkstyle>
77  </target>
78
79  <target name="jar" depends="compile"
80    description="generate JAR file">
81    <mkdir dir="${artifact.dir}"/>
82    <jar jarfile="${artifact.dir}/${component.jar}" basedir="${classes.dir}">
83      <manifest>
84        <attribute name="Main-Class" value="${component.main-class}"/>
85        <attribute name="Class-Path" value="${component.manifest-cp}"/>
86      </manifest>
87    </jar>
88  </target>
89
90  <target name="docs" depends="compile"
91    description="generate javadocs">
92    <javadoc sourcepath="${dest.dir}" destdir="${docs.dir}/api"
93      classpath="${component.classpath}:${classes.dir}"
94      author="true" version="true" use="true"
95      nodeprecated="true" windowtitle="Bio-Formats API">
96      <packageset dir="${dest.dir}"/>
97      <doctitle><![CDATA[<h1>Bio-Formats</h1>]]></doctitle>
98      <bottom><![CDATA[${copyright.begin} ${YEAR} ${copyright.end}]]></bottom>
99      <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
100      <link href="http://hudson.openmicroscopy.org.uk/job/OMEJAVA/javadoc/"/>
101      <link href="http://rsbweb.nih.gov/ij/developer/api/"/>
102      <link href="http://www.ssec.wisc.edu/~dglo/docs/"/>
103      <!--<link href="http://www.jdocs.com/formlayout/1.0.4/api/"/>-->
104      <!--<link href="http://www.jdocs.com/looks/1.2.2/api/"/>-->
105    </javadoc>
106  </target>
107
108  <target name="clean-classes" description="remove classes from build folder">
109    <delete dir="${classes.dir}"/>
110  </target>
111
112  <target name="clean-dist"
113    description="remove distribution bundles from build folder">
114    <delete dir="${dist.dir}"/>
115  </target>
116
117  <target name="clean-docs" description="remove javadocs from build folder">
118    <delete dir="${docs.dir}"/>
119  </target>
120
121  <target name="clean-src" description="remove source files from build folder">
122    <delete dir="${dest.dir}"/>
123  </target>
124
125  <target name="clean-jar" description="remove JAR file from artifacts folder">
126    <delete>
127      <fileset dir="${artifact.dir}" includes="${component.jar}"/>
128    </delete>
129  </target>
130
131  <!-- Internal build targets -->
132
133  <target name="init"
134    depends="init-timestamp, init-revision, init-manifest-cp"/>
135
136  <target name="init-manifest-cp">
137    <!-- construct manifest classpath -->
138    <propertyregex property="component.manifest-cp-temp"
139      input="${component.runtime-cp}" replace=""
140      defaultValue="${component.runtime-cp}">
141      <regexp pattern="[^\:]*\/"/>
142    </propertyregex>
143    <propertyregex property="component.manifest-cp"
144      input="${component.manifest-cp-temp}" replace=" "
145      defaultValue="${component.manifest-cp-temp}">
146      <regexp pattern=":"/>
147    </propertyregex>
148    <!--<echo>Manifest-Classpath: ${component.manifest-cp}</echo>-->
149  </target>
150
151  <target name="copy-source" depends="init">
152    <!-- copy binary resources without filtering -->
153    <copy todir="${dest.dir}" preservelastmodified="true">
154      <fileset dir="${src.dir}" includes="${component.resources-bin}"/>
155    </copy>
156    <!-- copy source files and text resources with filtering -->
157    <filter token="date" value="${DATE}"/>
158    <filter token="year" value="${YEAR}"/>
159    <filter token="svn.revision" value="${svn.revision}"/>
160    <filter token="visbio.version" value="${visbio.version}"/>
161    <copy todir="${dest.dir}" filtering="true" preservelastmodified="true">
162      <fileset dir="${src.dir}"
163        includes="${component.source} ${component.resources-text}"/>
164    </copy>
165    <!-- copy resources to classes folder -->
166    <copy todir="${classes.dir}" preservelastmodified="true">
167      <fileset dir="${dest.dir}" excludes="${component.source}"/>
168    </copy>
169  </target>
170
171</project>
Note: See TracBrowser for help on using the repository browser.