source: trunk/common.xml @ 4609

Revision 4609, 7.6 KB checked in by curtis, 11 years ago (diff)
  • Update Eclipse projects to match the latest codebase.
  • Add Eclipse classpath checking to dependency scanner script.
  • Move Bio-Formats code generation framework into its own component.
Line 
1<!--
2common.xml
3
4Ant build file for logic common to every component.
5Download Apache Ant from http://ant.apache.org/.
6Type "ant -p" for a list of targets.
7-->
8
9<project>
10  <property file="${user.home}/.ant-global.properties"/>
11  <property file="${root.dir}/global.properties"/>
12  <property file="${root.dir}/common.properties"/>
13
14  <condition property="isUnix"><os family="unix"/></condition>
15
16  <!-- Non-core ant tasks -->
17
18  <!-- NB - We do not reference ${artifact.dir}/loci-checks.jar directly,
19    as doing so causes loci-checks.jar to be locked by some file systems
20    (Windows in particular), which causes the clean and clean-jars targets
21    to fail. -->
22  <taskdef resource="checkstyletask.properties"
23    classpath="${lib.dir}/checkstyle-all-4.2.jar:${lib.dir}/loci-checks.jar"/>
24
25  <taskdef resource="net/sf/antcontrib/antcontrib.properties"
26    classpath="${lib.dir}/ant-contrib-1.0b1.jar"/>
27  <!-- HACK - some environments do not install the antcontrib tasks properly
28  from antcontrib.properties above; also load them from antlib.xml -->
29  <taskdef resource="net/sf/antcontrib/antlib.xml"
30    classpath="${lib.dir}/ant-contrib-1.0b1.jar"/>
31
32  <taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties"
33    classpath="${lib.dir}/findbugs-ant.jar"/>
34
35  <!--
36  <taskdef resource="proguard/ant/task.properties"
37    classpath="${lib.dir}/proguard.jar"/>
38  -->
39
40  <!-- Main build targets -->
41
42  <target name="dev-compile" description="compile classes in-place (no copy)">
43    <javac debug="true" deprecation="true"
44      source="${component.java-version}"
45      target="${component.java-version}"
46      srcdir="${src.dir}" destdir="${src.dir}"
47      classpath="${component.classpath}"
48      includes="${component.source}"/>
49  </target>
50
51  <target name="dev-clean" description="remove classes in-place (no copy)">
52    <delete>
53      <fileset dir="${src.dir}" includes="**/*.class"/>
54    </delete>
55  </target>
56
57  <target name="compile" depends="copy-source"
58    description="compile classes">
59    <javac debug="true" deprecation="true"
60      source="${component.java-version}"
61      target="${component.java-version}"
62      srcdir="${dest.dir}" destdir="${classes.dir}"
63      classpath="${component.classpath}"
64      includes="${component.source}"/>
65  </target>
66
67  <!-- CTR TODO FINISH THIS
68  <target name="exec" depends="compile" description="execute package">
69     <java classname="component.manifest-main"
70       classpath="${}"
71  </target>
72  -->
73
74  <target name="findbugs" depends="compile"
75    description="check source code for bugs">
76    <if>
77      <isset property="findbugs.home"/>
78      <then>
79        <findbugs home="${findbugs.home}" jvmargs="-Xmx512m"
80          output="xml" outputFile="${build.dir}/findbugs.xml">
81          <auxClasspath path="${component.classpath}"/>
82          <sourcePath path="${dest.dir}"/>
83          <class location="${classes.dir}"/>
84        </findbugs>
85        <java jar="${findbugs.home}/findbugs.jar" fork="true">
86          <arg value="${build.dir}/findbugs.xml"/>
87        </java>
88      </then>
89      <else>
90        <echo>Please set the findbugs.home property to point to your</echo>
91        <echo>FindBugs installation's lib directory. E.g.:</echo>
92        <echo>  ant -Dfindbugs.home=${user.home}/findbugs/lib findbugs</echo>
93      </else>
94    </if>
95  </target>
96
97  <target name="style" depends="compile"
98    description="check source code style">
99    <checkstyle config="${root.dir}/checkstyle.xml" failOnViolation="false"
100      classpath="${classes.dir}:${component.classpath}">
101      <fileset dir="${dest.dir}" includes="${component.source}"/>
102    </checkstyle>
103  </target>
104
105  <target name="jar" depends="compile"
106    description="generate JAR file">
107    <mkdir dir="${artifact.dir}"/>
108    <jar jarfile="${artifact.dir}/${component.jar}" basedir="${classes.dir}">
109      <manifest>
110        <attribute name="Main-Class" value="${component.manifest-main}"/>
111        <attribute name="Class-Path" value="${component.manifest-cp}"/>
112      </manifest>
113    </jar>
114  </target>
115
116  <target name="docs" depends="compile"
117    description="generate javadocs">
118    <javadoc sourcepath="${dest.dir}" destdir="${docs.dir}/api"
119      classpath="${component.classpath}:${classes.dir}"
120      author="true" version="true" use="true"
121      nodeprecated="true" windowtitle="Bio-Formats API">
122      <packageset dir="${dest.dir}"/>
123      <doctitle><![CDATA[<h1>Bio-Formats</h1>]]></doctitle>
124      <bottom><![CDATA[${copyright.begin} ${YEAR} ${copyright.end}]]></bottom>
125      <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
126      <link href="http://hudson.openmicroscopy.org.uk/job/OMEJAVA/javadoc/"/>
127      <link href="http://rsbweb.nih.gov/ij/developer/api/"/>
128      <link href="http://www.ssec.wisc.edu/~dglo/docs/"/>
129      <!--<link href="http://www.jdocs.com/formlayout/1.0.4/api/"/>-->
130      <!--<link href="http://www.jdocs.com/looks/1.2.2/api/"/>-->
131    </javadoc>
132  </target>
133
134  <target name="clean" description="remove all build files except artifacts">
135    <delete dir="${build.dir}"/>
136  </target>
137
138  <target name="clean-classes" description="remove classes from build folder">
139    <delete dir="${classes.dir}"/>
140  </target>
141
142  <target name="clean-dist"
143    description="remove distribution bundles from build folder">
144    <delete dir="${dist.dir}"/>
145  </target>
146
147  <target name="clean-docs" description="remove javadocs from build folder">
148    <delete dir="${docs.dir}"/>
149  </target>
150
151  <target name="clean-src" description="remove source files from build folder">
152    <delete dir="${dest.dir}"/>
153  </target>
154
155  <target name="clean-jar" description="remove JAR file from artifacts folder">
156    <delete>
157      <fileset dir="${artifact.dir}" includes="${component.jar}"/>
158    </delete>
159  </target>
160
161  <!-- Internal build targets -->
162
163  <target name="init">
164    <tstamp>
165      <format property="DATE" pattern="d MMMMM yyyy"/>
166      <format property="YEAR" pattern="yyyy"/>
167    </tstamp>
168    <!-- determine SVN revision number -->
169    <if>
170      <isset property="svn.revision"/>
171      <else>
172        <!--
173        Thanks to Chris Collins for this code snippet:
174          http://ccollins.wordpress.com/2008/01/30/
175            getting-subversion-revision-in-ant/
176        -->
177        <property name="revision" value="HEAD"/>
178        <exec executable="svn" outputproperty="svn.log"
179          failifexecutionfails="false">
180          <arg line="info ${base.dir} -r ${revision}"/>
181        </exec>
182        <if>
183          <isset property="svn.log"/>
184          <then>
185            <!--<echo>${svn.log}</echo>-->
186            <propertyregex property="svn.revision"
187              input="${svn.log}" select="\1">
188              <regexp pattern="Revision: ([0-9]*)"/>
189            </propertyregex>
190            <echo>SVN revision: ${svn.revision}</echo>
191          </then>
192        </if>
193      </else>
194    </if>
195  </target>
196
197  <target name="copy-source" depends="init">
198    <!-- copy binary resources without filtering -->
199    <copy todir="${dest.dir}" preservelastmodified="true">
200      <fileset dir="${src.dir}" includes="${component.resources-bin}"/>
201    </copy>
202    <!-- copy source files and text resources with filtering -->
203    <filter token="date" value="${DATE}"/>
204    <filter token="year" value="${YEAR}"/>
205    <filter token="svn.revision" value="${svn.revision}"/>
206    <filter token="visbio.version" value="${visbio.version}"/>
207    <copy todir="${dest.dir}" filtering="true" preservelastmodified="true">
208      <fileset dir="${src.dir}"
209        includes="${component.source} ${component.resources-text}"/>
210    </copy>
211    <!-- copy resources to classes folder -->
212    <copy todir="${classes.dir}" preservelastmodified="true">
213      <fileset dir="${dest.dir}" excludes="${component.source}"/>
214    </copy>
215  </target>
216
217</project>
Note: See TracBrowser for help on using the repository browser.