[svn-upgrade] Integrating new upstream version, jabref (2.2)
[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.78 $
26              $Date: 2006/11/29 00:51:22 $
27              $Author: coezbek $
28
29    modified:
30              23.11.2006 c.oezbek
31              - tried to fix classpath issues
32              28.07.2005 r.nagel
33              - insert dynamic build info generation (resource/build.properties)
34              - copy fonts directory, used by the new about dialog
35              - change static "version" into mainfest file into ${jabref.version}
36              09.06.2005 r.nagel
37              - bugfix, first it should be made a rebuild of the build directory
38              and then a jar should be generated from this directory
39              - take all files for the jar archive !!! FROM BUILD directory !!!
40
41 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
42
43 <project name="JabRef" default="jars" basedir=".">
44
45         <!-- ==========================================================================================
46         PROPERTY SETUP
47      ========================================================================================== -->
48
49         <!-- some version information -->
50         <property name="jabref.version" value="2.2" />
51         <property name="jabref.placeholder.version" value="@version@" />
52         <!-- used by replace task -->
53
54
55         <!-- Set the properties for intermediate directory -->
56         <property name="build.jar" value="JabRef-${jabref.version}.jar" />
57         <property name="build.dir" value="build" />
58         <property name="build.classes" value="${build.dir}/classes" />
59         <property name="build.tmp" value="${build.dir}/tmp" />
60         <property name="build.osx" value="${build.dir}/classes/osxadapter" />
61         <property name="build.lib" value="${build.dir}/lib" />
62         <property name="build.win" value="${build.dir}/windows" />
63         <property name="build.images" value="${build.dir}/images" />
64         <property name="build.fonts" value="${build.dir}/images/font" />
65         <property name="build.resource" value="${build.dir}/resource" />
66         <property name="build.help" value="${build.dir}/help" />
67         <property name="build.javadocs" value="${build.dir}/docs/API" />
68         <property name="build.extensions" value="${build.dir}/extensions" />
69         <property name="build.extension-javadocs" value="${build.extensions}/API" />
70         <property name="build.extension-layout" value="${build.extensions}/layout" />
71         <property name="build.openoffice.meta" value="${build.resource}/openoffice" />
72
73         <!-- Set the properties for source directories -->
74         <property name="src.dir" value="src" />
75         <property name="src.tests" value="src/java/tests" />
76         <property name="txt.dir" value="src/txt" />
77         <property name="java.dir" value="${src.dir}/java" />
78         <property name="osx.dir" value="${src.dir}/osx" />
79         <property name="win.installer.dir" value="${src.dir}/windows/nsis" />
80         <property name="resource.dir" value="${src.dir}/resource" />
81         <property name="bin.dir" value="${src.dir}/scripts" />
82         <property name="images.dir" value="${src.dir}/images" />
83         <property name="fonts.dir" value="${src.dir}/images/font" />
84         <property name="help.dir" value="${src.dir}/help" />
85         <property name="extensions.dir" value="${src.dir}/extensions" />
86         <property name="layout.dir" value="${src.dir}/resource/layout" />
87
88         <!-- Set the properties for library directories -->
89         <property name="library.directory" value="lib" />
90
91 <!--    <property name="nsis.executable" value="makensis.exe"/> -->
92
93         <!-- Load user dependent properties -->
94         <!-- For instance to redefine the NSIS-compiler write 
95                 nsis.executable="d:\prog\dev\NSIS\makensis.exe"
96           -->
97         <property file="user.properties" />
98
99         <!-- win.installer can only be build under Windows if the nsis.executable is found -->
100         <condition property="is.windows">
101                 <and>
102                         <os family="windows" />
103                         <isset property="nsis.executable" />
104 <!--                    <available file="${nsis.executable}" /> -->
105                 </and>
106         </condition>
107
108         <taskdef name="jarbundler" classpath="${library.directory}/jarbundler-1.4.jar" classname="com.loomcom.ant.tasks.jarbundler.JarBundler" />
109
110
111         <!-- Build classpath -->
112         <path id="classpath">
113                 <pathelement path="${build.classes}" />
114                 <pathelement path="${build.dir}" />
115                 <pathelement location="${library.directory}/antlr.jar" />
116                 <pathelement location="${library.directory}/antlr-3.0b5.jar" />
117                 <pathelement location="${library.directory}/looks-2.0.4.jar" />
118                 <pathelement location="${library.directory}/forms-1.0.4.jar" />
119                 <pathelement location="${library.directory}/spin.jar" />
120                 <pathelement location="${library.directory}/glazedlists-1.7.0_java14.jar" />
121                 <pathelement location="${library.directory}/microba.jar" />
122                 <pathelement location="${library.directory}/PDFBox-0.7.3-dev-reduced.jar" />
123                 <pathelement location="${library.directory}/JempBox-0.1.0-dev.jar" />
124         </path>
125
126         <target name="run" depends="build">
127                 <java classname="net.sf.jabref.JabRef" fork="true">
128                         <classpath refid="classpath" />
129                 </java>
130         </target>
131
132         <!-- Runs project -->
133         <target name="runFromJar" depends="jars">
134                 <java classname="net.sf.jabref.JabRef" fork="true">
135                         <classpath>
136                                 <pathelement location="${build.lib}/${build.jar}" />
137                         </classpath>
138                 </java>
139         </target>
140
141         <target name="profile" depends="jars" description="Profile JabRef">
142                 <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
143
144                 <nbprofiledirect>
145                         <classpath refid="classpath" />
146                 </nbprofiledirect>
147
148                 <property environment="env" />
149                 <java fork="true" classname="net.sf.jabref.JabRef" dir="${build.dir}" jvm="${profiler.info.jvm}">
150                         <jvmarg value="${profiler.info.jvmargs.agent}" />
151                         <jvmarg line="${profiler.info.jvmargs}" />
152                         <env key="LD_LIBRARY_PATH" path="${profiler.info.agentpath}:${env.LD_LIBRARY_PATH}" />
153                         <classpath refid="classpath" />
154                 </java>
155         </target>
156
157         <!-- Compiles project -->
158         <target name="compile">
159                 <mkdir dir="${build.classes}" />
160                 <javac debug="off" deprecation="on" destdir="${build.classes}" source="1.4" target="1.4">
161                         <src path="${java.dir}" />
162                         <exclude name="tests/**" />
163                         <classpath refid="classpath" />
164                 </javac>
165         </target>
166
167         <!-- Compiles only the tests -->
168         <target name="compiletest">
169                 <mkdir dir="${build.classes}" />
170                 <!--deprecation="on"-->
171                 <javac srcdir="${java.dir}/tests" debug="off" destdir="${build.classes}" source="1.4" target="1.4">
172                         <classpath refid="classpath" />
173                 </javac>
174         </target>
175
176         <!-- Builds the OSXAdapter -->
177         <target name="osx">
178                 <mkdir dir="${build.classes}" />
179
180                 <javac srcdir="${osx.dir}" debug="on" destdir="${build.classes}" target="1.4">
181                 </javac>
182         </target>
183
184         <!-- Copies in the OSXAdapter class, which is compilable only on Mac  -->
185         <target name="non_osx">
186                 <mkdir dir="${build.osx}" />
187                 <copy file="${library.directory}/OSXAdapter.class" todir="${build.osx}" />
188         </target>
189
190         <!-- Jars up project -->
191         <target name="jars" depends="build, unjarlib">
192                 <mkdir dir="${build.lib}" />
193                 <mkdir dir="${build.tmp}" />
194                 <jar destfile="${build.lib}/${build.jar}">
195
196                         <fileset dir="${build.classes}" />
197                         <fileset dir="${build.tmp}" />
198                         <fileset dir="${build.dir}">
199                                 <include name="images/**" />
200                                 <include name="help/**" />
201                                 <include name="help/de/**" />
202                                 <include name="help/no/**" />
203                                 <include name="resource/**" />
204                         </fileset>
205                         <fileset dir="${library.directory}">
206                                 <include name="EndNote.zip" />
207                         </fileset>
208                         <fileset dir="${txt.dir}">
209                                 <include name="gpl.txt" />
210                                 <include name="lesser.txt" />
211                                 <include name="jgoodies.txt" />
212                                 <include name="README" />
213                         </fileset>
214                         <manifest>
215                                 <attribute name="Main-Class" value="net.sf.jabref.JabRef" />
216                         </manifest>
217                 </jar>
218
219         </target>
220
221         <!-- copy all necessary files and insert version informations -->
222         <target name="build" depends="compile, buildinfos" description="Build project">
223
224                 <mkdir dir="${build.resource}" />
225
226                 <copy todir="${build.resource}">
227                         <fileset dir="${resource.dir}">
228                                 <include name="**" />
229                         </fileset>
230                 </copy>
231                 <mkdir dir="${build.images}" />
232                 <copy todir="${build.images}">
233                         <fileset dir="${images.dir}">
234                                 <include name="**" />
235                         </fileset>
236                 </copy>
237
238                 <!-- the fonts are used by the new about dialog
239                 <mkdir dir="${build.fonts}" />
240                 <copy todir="${build.fonts}">
241                         <fileset dir="${fonts.dir}">
242                                 <include name="*" />
243                         </fileset>
244                 </copy> -->
245
246                 <mkdir dir="${build.help}" />
247                 <copy todir="${build.help}">
248                         <fileset dir="${help.dir}">
249                                 <!--<include name="*" />-->
250                         </fileset>
251                 </copy>
252
253                 <!-- Insert version informations -->
254                 <replace dir="${build.help}" token="${jabref.placeholder.version}" value="${jabref.version}">
255                         <include name="**/About.html" />
256                 </replace>
257                 <replace dir="${build.openoffice.meta}" token="${jabref.placeholder.version}" value="${jabref.version}">
258                         <include name="meta.xml" />
259                 </replace>
260
261         </target>
262
263         <!-- generate and save some build infos !!! necessary for dynamic build infos !!! -->
264         <!-- todo : replace it by the replace task :-),
265           src/resource/build.properties = template
266           build/resource/build.properties = real info file
267         -->
268         <target name="buildinfos">
269                 <tstamp />
270                 <!-- get date -->
271                 <buildnumber />
272                 <!-- generate new build number -> build.number -->
273                 <echo message="build number = ${build.number}" />
274                 <!-- write the file, please do not edit this lines -->
275                 <echo file="${resource.dir}/build.properties">builddate=${TODAY}
276 build=${build.number}
277 version=${jabref.version}</echo>
278         </target>
279
280
281         <!-- Creates all docs -->
282         <target name="docs" depends="javadocs" description="Generates all the documentation" />
283
284         <!-- Creates javadocs -->
285         <target name="javadocs" depends="compile" description="Generates the javadocs">
286                 <mkdir dir="${build.javadocs}" />
287                 <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/">
288
289                         <fileset dir="${java.dir}" defaultexcludes="yes">
290                                 <include name="**/*.java" />
291                         </fileset>
292
293                         <classpath refid="classpath" />
294                 </javadoc>
295         </target>
296
297         <!-- Creates javadocs for the extensions -->
298         <target name="extension-javadocs" depends="build" description="Generates the javadocs for the extensions archive">
299                 <mkdir dir="${build.extension-javadocs}" />
300                 <copy todir="${build.extension-javadocs}">
301                         <fileset dir="${help.dir}" defaultexcludes="yes">
302                                 <include name="CustomExports.html" />
303                                 <include name="CustomImports.html" />
304                         </fileset>
305                 </copy>
306
307                 <javadoc sourcepath="${java.dir}" destdir="${build.extension-javadocs}" author="true" version="true" windowtitle="JabRef-Extensions API" link="http://java.sun.com/j2se/1.4.1/docs/api/" Overview="${extensions.dir}/API/overview.html" access="protected">
308                         <!-- 
309                  create javadoc only selectively for classes that 
310                  users extending JabRef are likely to use
311               -->
312                         <fileset dir="${java.dir}" defaultexcludes="yes">
313                                 <include name="net/sf/jabref/imports/ImportFormat.java" />
314                                 <include name="net/sf/jabref/imports/ImportFormatReader.java" />
315                                 <include name="net/sf/jabref/BibtexEntry.java" />
316                                 <include name="net/sf/jabref/BibtexEntryType.java" />
317                                 <include name="net/sf/jabref/AuthorList.java" />
318                                 <include name="net/sf/jabref/AuthorList.java" />
319                                 <include name="net/sf/jabref/export/layout/LayoutFormatter.java" />
320                         </fileset>
321
322                         <classpath refid="classpath" />
323                 </javadoc>
324         </target>
325
326         <!-- Creates javadocs for the extensions -->
327         <target name="extensions" depends="extension-javadocs" description="Generates the extensions archive">
328                 <!-- copy examples -->
329                 <copy todir="${build.extensions}">
330                         <fileset dir="${java.dir}">
331                                 <include name="net/sf/jabref/export/layout/format/CurrentDate.java" />
332                                 <include name="net/sf/jabref/export/layout/format/ToLowerCase.java" />
333                                 <include name="net/sf/jabref/export/layout/format/HTMLChars.java" />
334                                 <include name="net/sf/jabref/imports/*Importer.java" />
335                         </fileset>
336                 </copy>
337                 <mkdir dir="${build.extension-layout}" />
338                 <copy todir="${build.extension-layout}">
339                         <fileset dir="${layout.dir}" />
340                 </copy>
341                 <copy todir="${build.extensions}">
342                         <fileset dir="${extensions.dir}" />
343                         <filterset>
344                                 <filter token="version" value="${jabref.version}" />
345                         </filterset>
346                 </copy>
347                 <!-- create extensions-zip file -->
348                 <zip destfile="${build.dir}/jabref-extensions.zip">
349                         <zipfileset dir="${build.extensions}" prefix="jabref-extensions" />
350                 </zip>
351         </target>
352
353         <target name="clean" depends="win.installer.clean" description="Clean project">
354                 <delete dir="${build.dir}" />
355         </target>
356
357         <!-- Unpacks jar needed jar files from lib directory into temp directory. -->
358         <target name="unjarlib" description="Unpacks jars from library">
359                 <mkdir dir="${build.tmp}" />
360                 <unjar src="${library.directory}/antlr.jar" dest="${build.tmp}" />
361                 <unjar src="${library.directory}/antlr-3.0b5.jar" dest="${build.tmp}" />
362                 <unjar src="${library.directory}/looks-2.0.4.jar" dest="${build.tmp}" />
363                 <unjar src="${library.directory}/forms-1.0.4.jar" dest="${build.tmp}" />
364                 <unjar src="${library.directory}/spin.jar" dest="${build.tmp}" />
365                 <unjar src="${library.directory}/glazedlists-1.7.0_java14.jar" dest="${build.tmp}" />
366                 <unjar src="${library.directory}/microba.jar" dest="${build.tmp}" />
367                 <unjar src="${library.directory}/PDFBox-0.7.3-dev-reduced.jar" dest="${build.tmp}" />
368                 <unjar src="${library.directory}/JempBox-0.1.0-dev.jar" dest="${build.tmp}" />
369                 <delete dir="${build.tmp}/META-INF" />
370                 <!-- rename the microba license file -->
371                 <move file="${build.tmp}/license.txt" tofile="${build.tmp}/microba-license.txt" />
372         </target>
373
374
375         <target name="osxjar">
376                 <jarbundler dir="${build.lib}" name="JabRef" mainclass="net.sf.jabref.JabRef" jars="${build.lib}/${build.jar}" icon="${images.dir}/JabRef-Logo.icns" version="${jabref.version}" jvmversion="1.4+" stubfile="${library.directory}/JavaApplicationStub" />
377         </target>
378
379
380         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
381         <!-- Build Windows Installer                                                    -->
382         <!--                                                                            -->
383         <!-- Don't forget to set nsis.executable property                               -->
384         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
385
386         <target name="win.installer.clean" description="Delete Installer and Exe-Wrapper + Temp-files">
387                 <delete dir="${win.installer.dir}/dist" />
388                 <delete file="${win.installer.dir}/JabRefSetup.exe" />
389         </target>
390
391         <target name="win.installer" if="is.windows" description="Copy files in place to be used by the installer">
392
393                 <!-- Gather everything that will go into the installer in dist -->
394                 <mkdir dir="${win.installer.dir}/dist" />
395
396                 <!--            <copy file="${build.lib}/${jabref.bin}.jar" 
397                 todir="${win.installer.dir}/dist" /> -->
398
399                 <available property="win.installer.jar.available" file="${win.installer.dir}/dist/${build.jar}"/>
400                 
401                 <fail unless="win.installer.jar.available" message="Did not find jar: ${build.jar}"/>
402                 
403                 <copy todir="${win.installer.dir}/dist">
404                         <fileset dir="${txt.dir}">
405                                 <include name="gpl.txt" />
406                                 <include name="lesser.txt" />
407                                 <include name="README" />
408                         </fileset>
409                 </copy>
410
411                 <!-- "Create Exe-Wrapper" -->
412                 <exec dir="." executable="${nsis.executable}" failonerror="true">
413                         <arg line="'/DJARFILE=${build.jar}' '/DVERSION=${jabref.version}' '/DAPPICON=../../../${images.dir}/JabRef.ico' ${win.installer.dir}/launcher.nsi" />
414                 </exec>
415
416                 <!-- Finally create Windows-Installer -->
417                 <exec dir="." executable="${nsis.executable}" failonerror="true">
418                         <arg line="'/DVERSION=${jabref.version}' ${win.installer.dir}/setup.nsi" />
419                 </exec>
420         </target>
421
422         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
423         What's about the software design ?!;-)
424     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
425
426         <target name="pmd" description="SOFTWAREDESIGN: Project Mess Detector !;-)">
427                 <echo>Checking Project Mess Detection (PMD) rulesets.</echo>
428                 <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
429                         <classpath>
430                                 <pathelement path="${classpath}" />
431                                 <fileset dir="${library.directory}">
432                                         <include name="*.jar" />
433                                 </fileset>
434                         </classpath>
435                 </taskdef>
436                 <!-- allowed Pretty Much Done rulsets -->
437                 <!-- rulesets/basic.xml -->
438                 <!-- rulesets/braces.xml -->
439                 <!-- rulesets/codesize.xml-->
440                 <!-- rulesets/controversial.xml-->
441                 <!-- rulesets/coupling.xml-->
442                 <!-- rulesets/design.xml -->
443                 <!-- rulesets/experimental.xml -->
444                 <!-- rulesets/favorites.xml -->
445                 <!-- rulesets/imports.xml -->
446                 <!-- rulesets/naming.xml -->
447                 <!-- rulesets/javabean.xml -->
448                 <!-- rulesets/junit.xml -->
449                 <!-- rulesets/scratchpad.xml -->
450                 <!-- rulesets/strictexception.xml -->
451                 <!-- rulesets/strings.xml -->
452                 <!-- rulesets/unusedcode.xml -->
453
454                 <pmd rulesetfiles="rulesets/unusedcode.xml,rulesets/basic.xml" failonerror="no">
455                         <formatter type="html" toFile="${build.dir}/pmd_report.html" />
456                         <fileset dir="${src.dir}">
457                                 <include name="**/*.java" />
458                         </fileset>
459                 </pmd>
460
461                 <!-- check for duplicated code -->
462                 <echo>WARNING: use environment variable: ANT_OPTS=-Xmx512m or this task will fail.</echo>
463                 <echo>Checking for duplicated code using the Copy/Paste Detector (CPD).</echo>
464                 <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask">
465                         <classpath>
466                                 <pathelement path="${classpath}" />
467                                 <fileset dir="${library.directory}">
468                                         <include name="*.jar" />
469                                 </fileset>
470                         </classpath>
471                 </taskdef>
472                 <cpd format="text" minimumTokenCount="100" outputFile="${build.dir}/duplicated_code_report.txt">
473                         <fileset dir="${src.dir}">
474                                 <include name="**/*.java" />
475                         </fileset>
476                 </cpd>
477         </target>
478
479
480         <target name="javancss" description="SOFTWAREDESIGN: Determining the NCSS and CCN code metrics for JOELib.">
481                 <taskdef name="javancss" classname="javancss.JavancssAntTask">
482                         <classpath>
483                                 <pathelement path="${classpath}" />
484                                 <fileset dir="${library.directory}">
485                                         <include name="*.jar" />
486                                 </fileset>
487                         </classpath>
488                 </taskdef>
489                 <echo>Cyclomatic
490 Complexity             Ease of       Risk
491 Number (CCN)           maintenance
492 (McCabe metric)
493 ---------------------------------------------
494 1-10, simple           easy          minimum
495 11-20, complex         moderate      moderate
496 21-50, more complex    hard          high
497 >50, unstable          very hard     very high
498
499 </echo>
500                 <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" />
501         </target>
502
503         <target name="jalopy" description="SOFTWAREDESIGN: source code formatter using the JOELib convention.">
504                 <taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
505                         <classpath>
506                                 <pathelement path="${classpath}" />
507                                 <fileset dir="${library.directory}">
508                                         <include name="*.jar" />
509                                 </fileset>
510                         </classpath>
511                 </taskdef>
512                 <jalopy fileformat="unix" convention="${src.dir}/java/jalopy.format.convention.xml" history="file" historymethod="adler32" loglevel="error" threads="2" classpathref="classpath" backup="bak">
513                         <fileset dir="${src.dir}">
514                                 <include name="java/net/sf/jabref/**/*.java" />
515                         </fileset>
516                 </jalopy>
517         </target>
518
519         <target name="test">
520                 <junit printsummary="yes" fork="yes" haltonfailure="no">
521                         <batchtest fork="yes" todir="/tmp/testres">
522                                 <fileset dir="${build.classes}">
523                                         <include name="**/*Tester.class" />
524                                         <include name="**/*Test.class" />
525                                 </fileset>
526                         </batchtest>
527                         <classpath refid="classpath" />
528                 </junit>
529         </target>
530
531 </project>