source: trunk/components/java.xml @ 5645

Revision 5645, 6.8 KB checked in by curtis, 11 years ago (diff)

Fix JAR manifests.

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