d4d96252f659f12ba66f6d8f3e10e0520bf45c40
[debian/jabref.git] / build.xml
1 <?xml version="1.0"?>
2 <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3    Filename: $RCSfile: build.xml,v $
4    Purpose:  Ant build file for Jabref.
5
6              Ant-Download: http://jakarta.apache.org/ant
7              Ant-Manual:   http://jakarta.apache.org/ant/manual/index.html
8
9              Jabref-Homepage:    http://jabref.sourceforge.net
10              Jabref@SourceForge: http://sourceforge.net/projects/jabref
11              Jabref@FreshMeat:   http://freshmeat.net
12              Jabref-CVSRoot:     :pserver:anonymous@cvs.jabref.sourceforge.net:/cvsroot/jabref
13
14              Further questions:
15                help mailing list:      must be inserted
16
17    Precondition: 1. Ant should be installed.
18                  2. JAVA_HOME environment variable contains the path to JDK1.4 or higher
19                  3. ANT_HOME environment variable contains the path to ant's home directory
20
21    Language: XML
22    Compiler: Ant
23    Authors:  Joerg K. Wegner, wegnerj@informatik.uni-tuebingen.de
24              Morten O. Alver
25    Version:  $Revision: 1.54.2.3 $
26              $Date: 2006/02/02 09:31:59 $
27              $Author: mortenalver $
28
29    modified:
30              28.07.2005 r.nagel
31              - insert dynamic build info generation (resource/build.properties)
32              - copy fonts directory, used by the new about dialog
33              - change static "version" into mainfest file into ${jabref.version}
34              09.06.2005 r.nagel
35              - bugfix, first it should be made a rebuild of the build directory
36              and then a jar should be generated from this directory
37              - take all files for the jar archive !!! FROM BUILD directory !!!
38
39 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
40
41 <project name="JabRef" default="jars" basedir=".">
42
43         <!-- ==========================================================================================
44         PROPERTY SETUP
45      ========================================================================================== -->
46
47         <!-- some version information -->
48         <property name="jabref.bin" value="jabref" />
49         <property name="jabref.version" value="2.0.1" />
50         <property name="jabref.placeholder.version" value="@version@" /> <!-- used by replace task -->
51
52
53         <!-- Set the properties for intermediate directory -->
54         <property name="build.dir" value="build" />
55         <property name="build.classes" value="${build.dir}/classes" />
56         <property name="build.tmp" value="${build.dir}/tmp" />
57         <property name="build.osx" value="${build.dir}/classes/osxadapter" />
58         <property name="build.lib" value="${build.dir}/lib" />
59         <property name="build.bin" value="${build.dir}/bin" />
60         <property name="build.win" value="${build.dir}/windows" />
61         <property name="build.images" value="${build.dir}/images" />
62         <property name="build.fonts" value="${build.dir}/images/font" />
63         <property name="build.resource" value="${build.dir}/resource" />
64         <property name="build.help" value="${build.dir}/help" />
65         <property name="build.javadocs" value="${build.dir}/docs/API" />
66         <property name="build.openoffice.meta" value="${build.resource}/openoffice"/>
67
68         <!-- Set the properties for source directories -->
69         <property name="src.dir" value="src" />
70         <property name="src.tests" value="src/java/tests" />
71         <property name="txt.dir" value="src/txt" />
72         <property name="java.dir" value="${src.dir}/java" />
73         <property name="osx.dir" value="${src.dir}/osx" />
74         <property name="win.dir" value="${src.dir}/windows" />
75         <property name="resource.dir" value="${src.dir}/resource" />
76         <property name="bin.dir" value="${src.dir}/scripts" />
77         <property name="images.dir" value="${src.dir}/images" />
78         <property name="fonts.dir" value="${src.dir}/images/font" />
79         <property name="help.dir" value="${src.dir}/help" />
80
81
82         <!-- Set the properties for library directories -->
83         <property name="library.directory" value="lib" />
84
85
86     <taskdef name="jarbundler"
87                   classpath="${library.directory}/jarbundler-1.4.jar"
88                   classname="com.loomcom.ant.tasks.jarbundler.JarBundler" />
89
90
91         <!-- Build classpath -->
92         <path id="classpath">
93                 <pathelement path="${build.classes}" />
94                 <!--<pathelement location="${library.directory}/commons-httpclient-2.0.jar" />
95                 <pathelement location="${library.directory}/commons-logging.jar" />-->
96                 <fileset dir="${library.directory}">
97                         <include name="*.jar" />
98                 </fileset>
99         </path>
100
101     <!-- Runs project (e.g. in NetBeans 4) -->
102     <target name="run" depends="jars">
103         <java classname="net.sf.jabref.JabRef" fork="true">
104         <classpath>
105             <pathelement location="${build.lib}/jabref.jar"/>
106             <!--<pathelement location="${library.directory}/commons-httpclient-2.0.jar" />
107             <pathelement location="${library.directory}/commons-logging.jar" />-->
108             <pathelement location="${library.directory}/antlr.jar" />
109             <pathelement location="${library.directory}/looks-1.2.2.jar" />
110             <pathelement location="${library.directory}/forms-1.0.4.jar" />
111             <pathelement location="${library.directory}/spin.jar" />
112             <pathelement location="${library.directory}/glazedlists-1.5.0_java14.jar" />
113         </classpath>
114          </java>
115     </target>
116
117     <!-- Target used for profiling with the Netbeans profiler. -->
118     <!--<target name="profile" depends="jars">
119         <nbprofile classname="net.sf.jabref.JabRef">
120         <classpath>
121             <pathelement location="${build.lib}/jabref.jar"/>
122             <pathelement location="${library.directory}/antlr.jar" />
123             <pathelement location="${library.directory}/looks-1.2.2.jar" />
124             <pathelement location="${library.directory}/forms-1.0.4.jar" />
125             <pathelement location="${library.directory}/spin.jar" />
126             <pathelement location="${library.directory}/glazedlists-1.5.0_java14.jar" />
127         </classpath>
128          </nbprofile>
129     </target>-->
130     <target name="profile" depends="jars" description="Profile JabRef">
131       <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
132
133       <nbprofiledirect>
134           <classpath>
135             <pathelement location="${build.lib}/jabref.jar"/>
136             <pathelement location="${library.directory}/antlr.jar" />
137             <pathelement location="${library.directory}/looks-1.2.2.jar" />
138             <pathelement location="${library.directory}/forms-1.0.4.jar" />
139             <pathelement location="${library.directory}/spin.jar" />
140             <pathelement location="${library.directory}/glazedlists-1.5.0_java14.jar" />
141         </classpath>
142       </nbprofiledirect>
143
144       <property environment="env"/>
145       <java fork="true" classname="net.sf.jabref.JabRef" dir="${build.dir}"
146                   jvm="${profiler.info.jvm}">
147           <jvmarg value="${profiler.info.jvmargs.agent}"/>
148           <jvmarg line="${profiler.info.jvmargs}"/>
149           <env key="LD_LIBRARY_PATH" path="${profiler.info.agentpath}:${env.LD_LIBRARY_PATH}"/>
150           <classpath>
151             <pathelement location="${build.lib}/jabref.jar"/>
152             <pathelement location="${library.directory}/antlr.jar" />
153             <pathelement location="${library.directory}/looks-1.2.2.jar" />
154             <pathelement location="${library.directory}/forms-1.0.4.jar" />
155             <pathelement location="${library.directory}/spin.jar" />
156             <pathelement location="${library.directory}/glazedlists-1.5.0_java14.jar" />
157         </classpath>
158       </java>
159     </target>
160         <!-- Compiles project -->
161         <target name="compile">
162                 <mkdir dir="${build.classes}" />
163                 <!--deprecation="on"-->
164                 <javac debug="off" deprecation="on" destdir="${build.classes}" source="1.4" target="1.4">
165                         <src path="${java.dir}"/>
166                         <exclude name="tests/**"/>
167                         <classpath>
168                                 <pathelement path="${build.classes}" />
169                                 <!--<pathelement location="${library.directory}/commons-httpclient-2.0.jar" />
170                                 <pathelement location="${library.directory}/commons-logging.jar" />-->
171                                 <pathelement location="${library.directory}/antlr.jar" />
172                                 <pathelement location="${library.directory}/looks-1.2.2.jar" />
173                                 <pathelement location="${library.directory}/forms-1.0.4.jar" />
174                                 <pathelement location="${library.directory}/spin.jar" />
175                             <pathelement location="${library.directory}/glazedlists-1.5.0_java14.jar" />
176                         </classpath>
177                 </javac>
178         </target>
179
180         <!-- Compiles only the tests -->
181         <target name="compiletest">
182                 <mkdir dir="${build.classes}" />
183                 <!--deprecation="on"-->
184                 <javac srcdir="${java.dir}/tests" debug="off" destdir="${build.classes}" source="1.4" target="1.4">
185                         <classpath>
186                                 <pathelement path="${build.classes}" />
187                                 <!--<pathelement location="${library.directory}/commons-httpclient-2.0.jar" />
188                                 <pathelement location="${library.directory}/commons-logging.jar" />-->
189                                 <pathelement location="${library.directory}/antlr.jar" />
190                                 <pathelement location="${library.directory}/looks-1.2.2.jar" />
191                                 <pathelement location="${library.directory}/spin.jar" />
192                         </classpath>
193                 </javac>
194
195         </target>
196         <!-- Builds the OSXAdapter -->
197         <target name="osx">
198                 <mkdir dir="${build.classes}" />
199
200                 <javac srcdir="${osx.dir}" debug="on" destdir="${build.classes}" target="1.4">
201                 </javac>
202         </target>
203
204         <!-- Copies in the OSXAdapter class, which is compilable only on Mac  -->
205         <target name="non_osx">
206                 <mkdir dir="${build.osx}" />
207                 <copy file="${library.directory}/OSXAdapter.class" todir="${build.osx}" />
208         </target>
209
210
211         <!-- Jars up project -->
212         <target name="jars" depends="build">
213                 <mkdir dir="${build.lib}" />
214                 <mkdir dir="${build.tmp}" />
215                 <jar destfile="${build.lib}/jabref.jar">
216                         <fileset dir="${build.classes}" />
217                         <fileset dir="${build.tmp}" />
218                         <fileset dir="${build.dir}">
219                                 <include name="images/**" />
220                                 <include name="help/**" />
221                                 <include name="help/de/**" />
222                                 <include name="help/no/**" />
223                                 <include name="resource/**" />
224                         </fileset>
225                         <fileset dir="${library.directory}">
226                             <include name="EndNote.zip" />
227                         </fileset>
228
229                         <fileset dir="${txt.dir}">
230                                 <include name="gpl.txt" />
231                                 <include name="lesser.txt" />
232                                 <include name="apache-license.txt" />
233                                 <include name="jgoodies.txt" />
234                                 <include name="README" />
235                         </fileset>
236                         <manifest>
237                             <attribute name="Main-Class" value="net.sf.jabref.JabRef" />
238                         </manifest>
239                 </jar>
240
241         </target>
242
243         <!-- copy all necessary files and insert version informations -->
244         <target name="build" depends="compile, buildinfos" description="Build project">
245                 <mkdir dir="${build.bin}" />
246
247                 <mkdir dir="${build.resource}" />
248                 <copy todir="${build.resource}">
249                         <fileset dir="${resource.dir}">
250                                 <include name="**" />
251                         </fileset>
252                 </copy>
253                 <mkdir dir="${build.images}" />
254                 <copy todir="${build.images}">
255                         <fileset dir="${images.dir}">
256                                 <include name="*" />
257                         </fileset>
258                 </copy>
259
260                 <!-- the fonts are used by the new about dialog -->
261                 <mkdir dir="${build.fonts}" />
262                 <copy todir="${build.fonts}">
263                         <fileset dir="${fonts.dir}">
264                                 <include name="*" />
265                         </fileset>
266                 </copy>
267
268                 <mkdir dir="${build.help}" />
269                 <copy todir="${build.help}">
270                         <fileset dir="${help.dir}">
271                                 <!--<include name="*" />-->
272                         </fileset>
273                 </copy>
274
275                 <!-- Insert version informations -->
276                 <replace dir="${build.help}"
277                          token="${jabref.placeholder.version}"
278                          value="${jabref.version}">
279                    <include name="**/About.html"/>
280                 </replace>
281                 <replace dir="${build.openoffice.meta}"
282                          token="${jabref.placeholder.version}"
283                          value="${jabref.version}">
284                    <include name="meta.xml"/>
285                 </replace>
286
287 <!-- WHY ???
288                 <mkdir dir="${build.win}" />
289                 <copy file="${build.lib}/${jabref.bin}.jar" todir="${build.win}" />
290                 <copy todir="${build.win}">
291                         <fileset dir="${win.dir}">
292                                 <include name="*" />
293                         </fileset>
294                 </copy>
295 -->
296         </target>
297
298 <!-- generate and save some build infos !!! necessary for dynamic build infos !!! -->
299 <!-- todo : replace it by the replace task :-),
300           src/resource/build.properties = template
301           build/resource/build.properties = real info file
302 -->
303         <target name="buildinfos">
304                  <tstamp/>        <!-- get date -->
305                  <buildnumber/>   <!-- generate new build number -> build.number -->
306                  <echo message="build number = ${build.number}"/>
307                  <!-- write the file, please do not edit this lines -->
308                  <echo file="${resource.dir}/build.properties">builddate=${TODAY}
309 build=${build.number}
310 version=${jabref.version}</echo>
311         </target>
312
313
314         <!-- Creates all docs -->
315         <target name="docs" depends="javadocs" description="Generates all the documentation" />
316
317         <!-- Creates javadocs -->
318         <target name="javadocs" depends="compile" description="Generates the javadocs">
319                 <mkdir dir="${build.javadocs}" />
320                 <javadoc sourcepath="${java.dir}" destdir="${build.javadocs}" author="true" version="true" windowtitle="JabRef API" link="http://java.sun.com/j2se/1.4.1/docs/api/">
321
322                         <fileset dir="${java.dir}" defaultexcludes="yes">
323                                 <include name="**/*.java" />
324                         </fileset>
325
326                         <classpath refid="classpath" />
327                 </javadoc>
328         </target>
329
330         <target name="clean" description="Clean project">
331                 <delete dir="${build.dir}" />
332         </target>
333
334         <!-- Unpacks jar needed jar files from lib directory into temp directory. -->
335         <target name="unjarlib" description="Unpacks jars from library">
336                 <mkdir dir="${build.tmp}"/>
337                 <!--<unjar src="${library.directory}/commons-httpclient-2.0.jar" dest="${build.tmp}" />
338                 <unjar src="${library.directory}/commons-logging.jar" dest="${build.tmp}" />-->
339                 <unjar src="${library.directory}/antlr.jar" dest="${build.tmp}" />
340                 <!--                <unjar src="${library.directory}/plastic-1.2.1.jar" dest="${build.classes}" />-->
341                 <unjar src="${library.directory}/looks-1.2.2.jar" dest="${build.tmp}" />
342                 <unjar src="${library.directory}/forms-1.0.4.jar" dest="${build.tmp}" />
343                 <unjar src="${library.directory}/spin.jar" dest="${build.tmp}" />
344                 <unjar src="${library.directory}/glazedlists-1.5.0_java14.jar" dest="${build.tmp}" />
345
346             <delete dir="${build.tmp}/META-INF"/>
347         </target>
348
349
350         <target name="osxjar">
351         <jarbundler dir="${build.lib}"
352                     name="JabRef"
353                     mainclass="net.sf.jabref.JabRef"
354                     jars="${build.lib}/${jabref.bin}.jar"
355                     icon="${images.dir}/JabRef-Logo.icns"
356                     version="${jabref.version}"
357                     jvmversion="1.4+"
358                   stubfile="${library.directory}/JavaApplicationStub" />
359
360         </target>
361
362
363         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
364         What's about the software design ?!;-)
365 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
366
367         <target name="pmd" description="SOFTWAREDESIGN: Project Mess Detector !;-)">
368                 <echo>Checking Project Mess Detection (PMD) rulesets.</echo>
369                 <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
370                         <classpath>
371                                 <pathelement path="${classpath}" />
372                                 <fileset dir="${library.directory}">
373                                         <include name="*.jar" />
374                                 </fileset>
375                         </classpath>
376                 </taskdef>
377                 <!-- allowed Pretty Much Done rulsets -->
378                 <!-- rulesets/basic.xml -->
379                 <!-- rulesets/braces.xml -->
380                 <!-- rulesets/codesize.xml-->
381                 <!-- rulesets/controversial.xml-->
382                 <!-- rulesets/coupling.xml-->
383                 <!-- rulesets/design.xml -->
384                 <!-- rulesets/experimental.xml -->
385                 <!-- rulesets/favorites.xml -->
386                 <!-- rulesets/imports.xml -->
387                 <!-- rulesets/naming.xml -->
388                 <!-- rulesets/javabean.xml -->
389                 <!-- rulesets/junit.xml -->
390                 <!-- rulesets/scratchpad.xml -->
391                 <!-- rulesets/strictexception.xml -->
392                 <!-- rulesets/strings.xml -->
393                 <!-- rulesets/unusedcode.xml -->
394
395                 <pmd rulesetfiles="rulesets/unusedcode.xml,rulesets/basic.xml" failonerror="no">
396                         <formatter type="html" toFile="${build.dir}/pmd_report.html" />
397                         <fileset dir="${src.dir}">
398                                 <include name="**/*.java" />
399                         </fileset>
400                 </pmd>
401
402                 <!-- check for duplicated code -->
403                 <echo>WARNING: use environment variable: ANT_OPTS=-Xmx512m or this task will fail.</echo>
404                 <echo>Checking for duplicated code using the Copy/Paste Detector (CPD).</echo>
405                 <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask">
406                         <classpath>
407                                 <pathelement path="${classpath}" />
408                                 <fileset dir="${library.directory}">
409                                         <include name="*.jar" />
410                                 </fileset>
411                         </classpath>
412                 </taskdef>
413                 <cpd format="text" minimumTokenCount="100" outputFile="${build.dir}/duplicated_code_report.txt">
414                         <fileset dir="${src.dir}">
415                                 <include name="**/*.java" />
416                         </fileset>
417                 </cpd>
418         </target>
419
420
421         <target name="javancss" description="SOFTWAREDESIGN: Determining the NCSS and CCN code metrics for JOELib.">
422                 <taskdef name="javancss" classname="javancss.JavancssAntTask">
423                         <classpath>
424                                 <pathelement path="${classpath}" />
425                                 <fileset dir="${library.directory}">
426                                         <include name="*.jar" />
427                                 </fileset>
428                         </classpath>
429                 </taskdef>
430                 <echo>Cyclomatic
431 Complexity             Ease of       Risk
432 Number (CCN)           maintenance
433 (McCabe metric)
434 ---------------------------------------------
435 1-10, simple           easy          minimum
436 11-20, complex         moderate      moderate
437 21-50, more complex    hard          high
438 >50, unstable          very hard     very high
439
440 </echo>
441                 <javancss srcdir="${src.dir}" includes="**/*.java" excludes="jama/**/*.java, jmat/**/*.java, cformat/**/*.java" abortOnFail="false" ccnPerFuncMax="30" generateReport="true" outputfile="${build.dir}/javancss_report.plain" format="plain" packageMetrics="true" classMetrics="false" functionMetrics="false" />
442         </target>
443
444         <target name="jalopy" description="SOFTWAREDESIGN: source code formatter using the JOELib convention.">
445                 <taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
446                         <classpath>
447                                 <pathelement path="${classpath}" />
448                                 <fileset dir="${library.directory}">
449                                         <include name="*.jar" />
450                                 </fileset>
451                         </classpath>
452                 </taskdef>
453                 <jalopy fileformat="unix" convention="${src.dir}/java/jalopy.format.convention.xml" history="file" historymethod="adler32" loglevel="error" threads="2" classpathref="classpath" backup="bak">
454                         <fileset dir="${src.dir}">
455                                 <include name="java/net/sf/jabref/**/*.java" />
456                         </fileset>
457                 </jalopy>
458         </target>
459
460         <target name="test">
461                 <junit printsummary="yes" fork="yes" haltonfailure="no">
462                         <batchtest fork="yes" todir="/tmp/testres">
463                                 <fileset dir="${build.classes}">
464                                         <include name="**/*Tester.class" />
465                                         <include name="**/*Test.class" />
466                                 </fileset>
467                         </batchtest>
468
469                         <classpath>
470                                 <pathelement location="${build.lib}/jabref.jar" />
471                                 <!--<pathelement location="${library.directory}/commons-httpclient-2.0.jar" />
472                                 <pathelement location="${library.directory}/commons-logging.jar" />-->
473                                 <pathelement location="${library.directory}/antlr.jar" />
474                                 <pathelement location="${library.directory}/looks-1.2.2.jar" />
475                                 <pathelement location="${library.directory}/looks-1.2.2.jar" />
476                                 <pathelement location="${library.directory}/spin.jar" />
477                         </classpath>
478
479                         <!--<test name="tests.net.sf.jabref.export.layout.format.AuthorLastFirstAbbreviatorTester"/>-->
480                 </junit>
481         </target>
482
483 </project>