update version in changelog
[debian/jabref.git] / build.xml
1 <?xml version="1.0"?>
2 <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3    Filename: build.xml
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@FreeCode:       http://apps.freecode.com/projects/jabref
12              Jabref git repository: git://jabref.git.sourceforge.net/gitroot/jabref/jabref
13
14              Further questions:
15                help mailing list:   https://lists.sourceforge.net/lists/listinfo/jabref-users
16
17    Precondition: 1. Ant should be installed.
18                  2. JAVA_HOME environment variable contains the path to JDK1.5 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
26    modified: see at git checkout and "gitk build.xml"
27
28 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
29
30 <project name="JabRef" default="jars" basedir=".">
31
32         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33         PROPERTY SETUP
34      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
35
36         <!-- some version information -->
37         <property name="jabref.version" value="2.9b" />
38         <property name="jabref.year" value="2012" />
39         <property name="jabref.placeholder.version" value="@version@" />
40         <property name="jabref.placeholder.year" value="@year@" />
41         <!-- used by replace task -->
42
43         <!-- Set the properties for intermediate directory -->
44         <property name="build.jar" value="JabRef-${jabref.version}.jar" />
45         <property name="build.dir" value="build" />
46         <property name="build.classes" value="${build.dir}/classes" />
47         <property name="build.tmp" value="${build.dir}/tmp" />
48         <property name="build.osx" value="${build.dir}/classes/osxadapter" />
49         <property name="build.lib" value="${build.dir}/lib" />
50         <property name="build.win" value="${build.dir}/windows" />
51         <property name="build.images" value="${build.dir}/images" />
52         <property name="build.fonts" value="${build.dir}/images/font" />
53         <property name="build.resource" value="${build.dir}/resource" />
54         <property name="build.help" value="${build.dir}/help" />
55         <property name="build.javadocs" value="${build.dir}/docs/API" />
56         <property name="build.extensions" value="${build.dir}/extensions" />
57         <property name="build.extension-javadocs" value="${build.extensions}/API" />
58         <property name="build.extension-layout" value="${build.extensions}/layout" />
59         <property name="build.openoffice.meta" value="${build.resource}/openoffice" />
60         <property name="build.tests" value="${build.dir}/tests" />
61
62         <!-- Set the properties for source directories -->
63         <property name="src.dir" value="src" />
64         <property name="src.tests" value="src/java/tests" />
65         <property name="plugin.dir" value="src/plugins/" />
66         <property name="txt.dir" value="src/txt" />
67         <property name="java.dir" value="${src.dir}/java" />
68         <property name="osx.dir" value="${src.dir}/osx" />
69         <property name="win.installer.dir" value="${src.dir}/windows/nsis" />
70         <property name="resource.dir" value="${src.dir}/resource" />
71         <property name="bin.dir" value="${src.dir}/scripts" />
72         <property name="images.dir" value="${src.dir}/images" />
73         <property name="fonts.dir" value="${src.dir}/images/font" />
74         <property name="help.dir" value="${src.dir}/help" />
75         <property name="extensions.dir" value="${src.dir}/extensions" />
76         <property name="layout.dir" value="${src.dir}/resource/layout" />
77         <property name="lib.dir" value="lib" />
78         <property name="tests.dir" value="${src.dir}/tests" />
79
80         <property name="nsis.executable" value="C:\Program files\NSIS\makensis.exe"/>
81         <property name="nsis.executable.linux" value="makensis"/>
82
83         <!-- Load user dependent properties -->
84         <!-- For instance to redefine the NSIS-compiler write 
85                 nsis.executable="d:\prog\dev\NSIS\makensis.exe"
86           -->
87         <property file="user.properties" />
88
89         <!-- win.installer can only be build under Windows if the nsis.executable is found -->
90         <condition property="is.windows">
91           <and>
92             <isset property="nsis.executable" />
93             <os family="windows" />
94           </and>
95         </condition>
96
97         <fileset id="jarsFileset" dir="${lib.dir}">
98                 <include name="antlr.jar" />
99                 <include name="antlr-3.0b5.jar" />
100         <include name="jgoodies-common-1.3.1.jar" />
101                 <include name="jgoodies-looks-2.5.1.jar" />
102                 <include name="jgoodies-forms-1.5.1.jar" />
103                 <include name="spin.jar" />
104                 <include name="glazedlists-1.8.0_java15.jar" />
105                 <include name="microba.jar" />
106                 <include name="pdfbox-1.6.0.jar" />
107                 <include name="jempbox-1.6.0.jar" />
108                 <include name="fontbox-1.6.0.jar" />
109                 <include name="zoom-java.jar" />
110         <include name="mysql-connector-java-5.0.7-bin.jar" />
111                 <include name="postgresql-9.1-902.jdbc4.jar" />
112         <!--<include name="substance-4.1.jar" />-->
113         <!-- Plugin runtime dependencies -->
114                 <include name="plugin/JPFCodeGenerator-rt.jar" />
115                 <include name="plugin/jpf.jar" />
116                 <include name="plugin/jpf-boot.jar" />
117                 <include name="plugin/commons-logging.jar" />
118         </fileset>
119
120     <!-- Openoffice connection dependencies. Compile-time only -->
121     <fileset id="ooFileset" dir="${lib.dir}">
122         <include name="oo/unoil.jar" />
123         <include name="oo/ridl.jar" />
124         <include name="oo/juh.jar" />
125         <include name="oo/jurt.jar" />
126     </fileset>
127
128     <!-- Done by MrDlib -->
129     <fileset id="splJars" dir="${lib.dir}">
130         <include name="spl/**/*.jar" />
131         <include name="spl/*.jar" />
132     </fileset>
133         <fileset id="deletableMeta-InfFiles" dir="${build.tmp}/META-INF">
134                 <exclude name="services/**/*" />                
135         </fileset>
136     <!-- Done by MrDlib -->
137
138         <!-- Build classpath -->
139         <path id="classpath">
140                 <pathelement path="${build.classes}" />
141                 <pathelement path="${build.dir}" />
142         <!-- Done by MrDlib -->
143         <pathelement path="${lib.dir}/spl" />
144         <fileset refid="splJars" />
145         <!-- Done by MrDlib -->
146                 <fileset refid="jarsFileset" />
147         <fileset refid="ooFileset" />
148         </path>
149
150         <!-- Classpath for running the code generator -->
151         <path id="codegenerator">
152                 <pathelement location="${lib.dir}/plugin/JPFCodeGenerator.jar" />
153                 <pathelement location="${lib.dir}/plugin/jpf.jar" />
154                 <pathelement location="${lib.dir}/plugin/jpf-boot.jar" />
155                 <pathelement location="${lib.dir}/plugin/velocity-dep-1.5.jar" />
156         </path>
157
158         <!-- Classpath for tests -->
159         <path id="classpathTest">
160                 <path refid="classpath" />
161                 <pathelement location="${lib.dir}/junit.jar" />
162         </path>
163
164         <target name="run" depends="build">
165                 <java classname="net.sf.jabref.JabRefMain" fork="true">
166                         <classpath refid="classpath" />
167                 </java>
168         </target>
169
170         <!-- Runs project -->
171         <target name="runFromJar">
172                 <java dir="${build.lib}" classname="net.sf.jabref.JabRefMain" fork="true">
173                         <classpath>
174                                 <pathelement location="${build.lib}/${build.jar}" />
175                         </classpath>
176                 </java>
177         </target>
178
179         <!-- Only rerun the code generator if plug-in xml or jars are newer than generated java file. -->
180         <uptodate property="needsNoRegenerate" targetfile="${java.dir}/net/sf/jabref/plugin/core/generated/_JabRefPlugin.java">
181                 <srcfiles dir=".">
182                         <include name="${plugin.dir}/**/plugin.xml" />
183                         <include name="${lib.dir}/plugin/*.jar" />
184                 </srcfiles>
185         </uptodate>
186
187         <!-- Run the JPF Code Generator -->
188         <target name="generate" unless="needsNoRegenerate">
189                 <java classname="net.sf.jabref.plugin.util.CodeGenerator" fork="true">
190                         <arg value="${plugin.dir}" />
191                         <classpath refid="codegenerator" />
192                 </java>
193         </target>
194
195         <!-- Compiles project excluding tests -->
196         <target name="compile" depends="generate">
197                 <mkdir dir="${build.classes}" />
198                 <javac debug="on" deprecation="on" destdir="${build.classes}" encoding="UTF8"
199                    source="1.5" target="1.5">
200                         <src path="${java.dir}" />
201                         <exclude name="tests/**" />
202                         <exclude name="**/JabRefMain.java" />
203                         <classpath refid="classpath" />
204                 </javac>
205                 <javac debug="off" deprecation="on" destdir="${build.classes}" source="1.4" target="1.4">
206                         <src path="${java.dir}" />
207                         <include name="**/JabRefMain.java" />
208                 </javac>
209         </target>
210
211         <!-- Compiles project including tests -->
212         <target name="compiletest">
213                 <mkdir dir="${build.classes}" />
214                 <javac debug="on" destdir="${build.classes}" source="1.5" target="1.5">
215                         <src path="${java.dir}" />
216                         <include name="tests/**" />
217                         <classpath refid="classpathTest" />
218                 </javac>
219         </target>
220
221         <!-- Builds the OSXAdapter -->
222         <target name="osx">
223                 <mkdir dir="${build.classes}" />
224
225                 <javac srcdir="${osx.dir}" debug="off" destdir="${build.classes}" target="1.5">
226                 </javac>
227         </target>
228
229         <!-- Copies in the OSXAdapter class, which is compilable only on Mac  -->
230         <target name="non_osx">
231                 <mkdir dir="${build.osx}" />
232                 <copy file="${lib.dir}/OSXAdapter.class" todir="${build.osx}" />
233         </target>
234
235         <!-- Jars up project -->
236         <target name="jars" depends="build, unjarlib">
237                 <mkdir dir="${build.lib}" />
238         
239                 <mkdir dir="${build.tmp}" />
240                 <jar destfile="${build.lib}/${build.jar}" > 
241         <!--<jar destfile="${build.lib}/JabRef-${revision}.jar" manifest="${src.dir}/MANIFEST.MF">-->
242
243                         <fileset dir="${build.classes}" />
244                         <fileset dir="${build.tmp}" />
245                         <fileset dir="${build.dir}">
246                                 <include name="images/**" />
247                                 <include name="help/**" />
248                                 <include name="resource/**" />
249                         </fileset>
250
251                         <!-- Add Plugins -->
252                         <fileset dir="${src.dir}">
253                                 <include name="plugins/**" />
254                         </fileset>
255              <!-- Done by MrDlib -->
256             <fileset dir ="${java.dir}">
257                 <include name="spl/localization/spljabref.properties"/>
258                 <include name="spl/gui/ajax-loader.gif"/>
259                 <include name="spl/gui/mrdlib header.png"/>
260             </fileset>
261             <!-- Done by MrDlib -->
262                         <fileset dir="${lib.dir}">
263                                 <include name="EndNote.zip" />
264                         </fileset>
265                         <fileset dir="${txt.dir}">
266                                 <include name="gpl2.txt" />
267                                 <include name="gpl3.txt" />
268                                 <include name="lesser.txt" />
269                                 <include name="jgoodies.txt" />
270                                 <include name="README" />
271                         </fileset>
272                         <manifest>
273                                 <attribute name="Main-Class" value="net.sf.jabref.JabRefMain" />
274                 <attribute name="Class-Path" value="." />
275                         </manifest>
276                 </jar>
277
278         </target>
279
280         <!-- copy all necessary files and insert version informations -->
281         <target name="build" depends="compile, buildinfos" description="Build project">
282
283                 <mkdir dir="${build.resource}" />
284
285                 <copy todir="${build.resource}">
286                         <fileset dir="${resource.dir}">
287                                 <include name="**" />
288                         </fileset>
289                 </copy>
290                 <mkdir dir="${build.images}" />
291                 <copy todir="${build.images}">
292                         <fileset dir="${images.dir}">
293                                 <include name="**" />
294                         </fileset>
295                 </copy>
296
297                 <mkdir dir="${build.help}" />
298                 <copy todir="${build.help}">
299                         <fileset dir="${help.dir}" />
300                 </copy>
301
302                 <!-- Insert version informations -->
303                 <replace dir="${build.help}">
304                     <replacefilter
305                             token="${jabref.placeholder.version}" 
306                                 value="${jabref.version}" />
307                     <replacefilter
308                             token="${jabref.placeholder.year}" 
309                                 value="${jabref.year}" />
310                         <include name="**/About.html" />
311                 </replace>
312                 <replace dir="${build.openoffice.meta}" token="${jabref.placeholder.version}" value="${jabref.version}">
313                         <include name="meta.xml" />
314                 </replace>
315
316         </target>
317
318         <!-- Prepare for testing -->
319         <target name="buildtest" depends="build, compiletest" description="Build project for testing">
320
321                 <mkdir dir="${build.tests}" />
322                 <copy todir="${build.tests}">
323                         <fileset dir="${tests.dir}">
324                                 <include name="**" />
325                         </fileset>
326                 </copy>
327         </target>
328
329         <!-- generate and save some build infos !!! necessary for dynamic build infos !!! -->
330         <!-- todo : replace it by the replace task :-),
331           src/resource/build.properties = template
332           build/resource/build.properties = real info file
333         -->
334         <target name="buildinfos">
335                 <tstamp />
336                 <!-- get date -->
337                 <buildnumber />
338                 <!-- generate new build number -> build.number -->
339                 <echo message="build number = ${build.number}" />
340                 <!-- write the file, please do not edit this lines -->
341                 <echo file="${resource.dir}/build.properties">builddate=${TODAY}
342 build=${build.number}
343 version=${jabref.version}</echo>
344         </target>
345
346
347         <!-- Creates all docs -->
348         <target name="docs" depends="javadocs" description="Generates all the documentation" />
349
350         <!-- Creates javadocs -->
351         <target name="javadocs" depends="compile" description="Generates the javadocs">
352                 <mkdir dir="${build.javadocs}" />
353                 <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/">
354
355                         <fileset dir="${java.dir}" defaultexcludes="yes">
356                                 <include name="**/*.java" />
357                         </fileset>
358
359                         <classpath refid="classpath" />
360                 </javadoc>
361         </target>
362
363         <!-- Creates javadocs for the extensions -->
364         <target name="extension-javadocs" depends="build" description="Generates the javadocs for the extensions archive">
365                 <mkdir dir="${build.extension-javadocs}" />
366                 <copy todir="${build.extension-javadocs}">
367                         <fileset dir="${help.dir}" defaultexcludes="yes">
368                                 <include name="CustomExports.html" />
369                                 <include name="CustomImports.html" />
370                         </fileset>
371                 </copy>
372
373                 <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">
374                         <!-- 
375                  create javadoc only selectively for classes that 
376                  users extending JabRef are likely to use
377               -->
378                         <fileset dir="${java.dir}" defaultexcludes="yes">
379                                 <include name="net/sf/jabref/imports/ImportFormat.java" />
380                                 <include name="net/sf/jabref/imports/ImportFormatReader.java" />
381                                 <include name="net/sf/jabref/BibtexEntry.java" />
382                                 <include name="net/sf/jabref/BibtexEntryType.java" />
383                                 <include name="net/sf/jabref/AuthorList.java" />
384                                 <include name="net/sf/jabref/AuthorList.java" />
385                                 <include name="net/sf/jabref/export/layout/LayoutFormatter.java" />
386                         </fileset>
387
388                         <classpath refid="classpath" />
389                 </javadoc>
390         </target>
391
392         <!-- Creates javadocs for the extensions -->
393         <target name="extensions" depends="extension-javadocs" description="Generates the extensions archive">
394                 <!-- copy examples -->
395                 <copy todir="${build.extensions}">
396                         <fileset dir="${java.dir}">
397                                 <include name="net/sf/jabref/export/layout/format/CurrentDate.java" />
398                                 <include name="net/sf/jabref/export/layout/format/ToLowerCase.java" />
399                                 <include name="net/sf/jabref/export/layout/format/HTMLChars.java" />
400                                 <include name="net/sf/jabref/imports/*Importer.java" />
401                         </fileset>
402                 </copy>
403                 <mkdir dir="${build.extension-layout}" />
404                 <copy todir="${build.extension-layout}">
405                         <fileset dir="${layout.dir}" />
406                 </copy>
407                 <copy todir="${build.extensions}">
408                         <fileset dir="${extensions.dir}" />
409                         <filterset>
410                                 <filter token="version" value="${jabref.version}" />
411                         </filterset>
412                 </copy>
413                 <!-- create extensions-zip file -->
414                 <zip destfile="${build.dir}/jabref-extensions.zip">
415                         <zipfileset dir="${build.extensions}" prefix="jabref-extensions" />
416                 </zip>
417         </target>
418
419         <target name="clean" depends="win.installer.clean" description="Clean project">
420                 <delete dir="${build.dir}" />
421         </target>
422
423         <!-- Unpacks jar needed jar files from lib directory into temp directory. -->
424         <target name="unjarlib" description="Unpacks jars from library">
425                 <mkdir dir="${build.tmp}" />
426                 <unjar dest="${build.tmp}">
427                         <fileset refid="jarsFileset" />
428                         <fileset refid="splJars" />
429                 </unjar>
430                 <!-- done by MrDlib -->
431                 <delete includeEmptyDirs="true">
432                         <fileset refid="deletableMeta-InfFiles" />
433                 </delete>
434                 <!-- done by MrDlib -->
435                 <!-- rename the microba license file -->
436                 <move file="${build.tmp}/license.txt" tofile="${build.tmp}/microba-license.txt" />
437         </target>
438
439
440         <target name="osxjar">
441                 <jarbundler dir="${build.lib}"
442                     name="JabRef"
443                     mainclass="net.sf.jabref.JabRef"
444                     jars="${build.lib}/${build.jar}"
445                     icon="${images.dir}/JabRef-Logo.icns"
446                     version="${jabref.version}"
447                     jvmversion="1.4+"
448                     stubfile="${lib.dir}/JavaApplicationStub"
449                     signature="JABr">
450             <documenttype name="BibTeX file" extensions="bib" role="Editor"
451                           iconFile="${images.dir}/JabRef-Logo.icns"/>
452         </jarbundler>
453         </target>
454
455
456         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
457         <!-- Build Windows Installer                                                    -->
458         <!--                                                                            -->
459         <!-- Don't forget to set nsis.executable property                               -->
460         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
461
462         <target name="win.installer.clean" description="Delete Installer and Exe-Wrapper + Temp-files">
463                 <delete failonerror="false" dir="${win.installer.dir}/dist" />
464                 <delete file="${win.installer.dir}/JabRefSetup.exe" />
465         </target>
466
467         <target name="win.installer" description="Copy files in place to be used by the installer" depends="jars">
468
469                 <fail unless="is.windows" message="Not running on windows or NSIS not found. Please make sure that user.properties exists" />
470
471                 <!-- Gather everything that will go into the installer in dist -->
472                 <mkdir dir="${win.installer.dir}/dist" />
473
474                 <copy file="${build.lib}/${build.jar}" todir="${win.installer.dir}/dist" />
475
476                 <available property="win.installer.jar.available" file="${win.installer.dir}/dist/${build.jar}" />
477
478                 <fail unless="win.installer.jar.available" message="Did not find jar: ${build.jar}" />
479
480                 <copy todir="${win.installer.dir}/dist">
481                         <fileset dir="${txt.dir}">
482                                 <include name="gpl2.txt" />
483                                 <include name="gpl3.txt" />
484                                 <include name="lesser.txt" />
485                                 <include name="README" />
486                         </fileset>
487                 </copy>
488
489                 <!-- "Create Exe-Wrapper" -->
490                 <exec dir="." executable="${nsis.executable}" failonerror="true">
491                   <arg line="'/DJARFILE=${build.jar}' '/DVERSION=${jabref.version}' '/DAPPICON=../../../${images.dir}/JabRef.ico' ${win.installer.dir}/launcher.nsi" />
492                 </exec>
493
494                 <!-- Finally create Windows-Installer -->
495                 <exec dir="." executable="${nsis.executable}" failonerror="true">
496                         <arg line="'/DVERSION=${jabref.version}' ${win.installer.dir}/setup.nsi" />
497                 </exec>
498
499                 <delete dir="${win.installer.dir}/dist" />
500
501         </target>
502
503         <target name="win.installer.linux" description="Copy files in place to be used by the installer" depends="jars">
504
505                 <!-- Gather everything that will go into the installer in dist -->
506                 <mkdir dir="${win.installer.dir}/dist" />
507
508                 <copy file="${build.lib}/${build.jar}" todir="${win.installer.dir}/dist" />
509
510                 <available property="win.installer.jar.available" file="${win.installer.dir}/dist/${build.jar}" />
511
512                 <fail unless="win.installer.jar.available" message="Did not find jar: ${build.jar}" />
513
514                 <copy todir="${win.installer.dir}/dist">
515                         <fileset dir="${txt.dir}">
516                                 <include name="gpl2.txt" />
517                                 <include name="gpl3.txt" />
518                                 <include name="lesser.txt" />
519                                 <include name="README" />
520                         </fileset>
521                 </copy>
522
523                 <!-- "Create Exe-Wrapper" -->
524                 <exec dir="." executable="${nsis.executable.linux}" failonerror="true">
525                   <arg line="'-DJARFILE=${build.jar}' '-DVERSION=${jabref.version}' '-DAPPICON=../../../${images.dir}/JabRef.ico' ${win.installer.dir}/launcher.nsi" />
526                 </exec>
527
528                 <!-- Finally create Windows-Installer -->
529                 <exec dir="." executable="${nsis.executable.linux}" failonerror="true">
530                         <arg line="'-DVERSION=${jabref.version}' ${win.installer.dir}/setup.nsi" />
531                 </exec>
532
533                 <delete dir="${win.installer.dir}/dist" />
534
535         </target>
536
537         <target name="test" depends="buildtest" description="Runs all unit tests">
538                 <java fork="yes" classname="junit.textui.TestRunner" failonerror="true">
539                         <arg value="tests.net.sf.jabref.AllTests" />
540                         <classpath refid="classpathTest" />
541                 </java>
542         </target>
543
544
545
546         <!--+++++++++++++++++++++++++++++++++++++++++++++++++
547            Auxiliary targets
548           +++++++++++++++++++++++++++++++++++++++++++++++++-->
549
550         <target name="profile" depends="jars" description="Profile JabRef">
551                 <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
552
553                 <nbprofiledirect>
554                         <classpath refid="classpath" />
555                 </nbprofiledirect>
556
557                 <property environment="env" />
558                 <java fork="true" classname="net.sf.jabref.JabRef" dir="${build.dir}" jvm="${profiler.info.jvm}">
559                         <jvmarg value="${profiler.info.jvmargs.agent}" />
560                         <jvmarg line="${profiler.info.jvmargs}" />
561                         <env key="LD_LIBRARY_PATH" path="${profiler.info.agentpath}:${env.LD_LIBRARY_PATH}" />
562                         <classpath refid="classpath" />
563                 </java>
564         </target>
565
566         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
567         What's about the software design ?!;-)
568     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
569
570         <target name="pmd" description="SOFTWAREDESIGN: Project Mess Detector !;-)">
571                 <echo>Checking Project Mess Detection (PMD) rulesets.</echo>
572                 <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
573                         <classpath>
574                                 <pathelement path="${classpath}" />
575                                 <fileset dir="${lib.dir}">
576                                         <include name="*.jar" />
577                                 </fileset>
578                         </classpath>
579                 </taskdef>
580                 <!-- allowed Pretty Much Done rulsets -->
581                 <!-- rulesets/basic.xml -->
582                 <!-- rulesets/braces.xml -->
583                 <!-- rulesets/codesize.xml-->
584                 <!-- rulesets/controversial.xml-->
585                 <!-- rulesets/coupling.xml-->
586                 <!-- rulesets/design.xml -->
587                 <!-- rulesets/experimental.xml -->
588                 <!-- rulesets/favorites.xml -->
589                 <!-- rulesets/imports.xml -->
590                 <!-- rulesets/naming.xml -->
591                 <!-- rulesets/javabean.xml -->
592                 <!-- rulesets/junit.xml -->
593                 <!-- rulesets/scratchpad.xml -->
594                 <!-- rulesets/strictexception.xml -->
595                 <!-- rulesets/strings.xml -->
596                 <!-- rulesets/unusedcode.xml -->
597
598                 <pmd rulesetfiles="rulesets/unusedcode.xml,rulesets/basic.xml" failonerror="no">
599                         <formatter type="html" toFile="${build.dir}/pmd_report.html" />
600                         <fileset dir="${src.dir}">
601                                 <include name="**/*.java" />
602                         </fileset>
603                 </pmd>
604
605                 <!-- check for duplicated code -->
606                 <echo>WARNING: use environment variable: ANT_OPTS=-Xmx512m or this task will fail.</echo>
607                 <echo>Checking for duplicated code using the Copy/Paste Detector (CPD).</echo>
608                 <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask">
609                         <classpath>
610                                 <pathelement path="${classpath}" />
611                                 <fileset dir="${lib.dir}">
612                                         <include name="*.jar" />
613                                 </fileset>
614                         </classpath>
615                 </taskdef>
616                 <cpd format="text" minimumTokenCount="100" outputFile="${build.dir}/duplicated_code_report.txt">
617                         <fileset dir="${src.dir}">
618                                 <include name="**/*.java" />
619                         </fileset>
620                 </cpd>
621         </target>
622
623
624         <target name="javancss" description="SOFTWAREDESIGN: Determining the NCSS and CCN code metrics for JOELib.">
625                 <taskdef name="javancss" classname="javancss.JavancssAntTask">
626                         <classpath>
627                                 <pathelement path="${classpath}" />
628                                 <fileset dir="${lib.dir}">
629                                         <include name="*.jar" />
630                                 </fileset>
631                         </classpath>
632                 </taskdef>
633                 <echo>Cyclomatic
634 Complexity             Ease of       Risk
635 Number (CCN)           maintenance
636 (McCabe metric)
637 ---------------------------------------------
638 1-10, simple           easy          minimum
639 11-20, complex         moderate      moderate
640 21-50, more complex    hard          high
641 >50, unstable          very hard     very high
642
643 </echo>
644                 <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" />
645         </target>
646
647         <target name="jalopy" description="SOFTWAREDESIGN: source code formatter using the JOELib convention.">
648                 <taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
649                         <classpath>
650                                 <pathelement path="${classpath}" />
651                                 <fileset dir="${lib.dir}">
652                                         <include name="*.jar" />
653                                 </fileset>
654                         </classpath>
655                 </taskdef>
656                 <jalopy fileformat="unix" convention="${src.dir}/java/jalopy.format.convention.xml" history="file" historymethod="adler32" loglevel="error" threads="2" classpathref="classpath" backup="bak">
657                         <fileset dir="${src.dir}">
658                                 <include name="java/net/sf/jabref/**/*.java" />
659                         </fileset>
660                 </jalopy>
661         </target>
662
663         <taskdef name="jarbundler" classpath="${lib.dir}/jarbundler-2.2.0.jar" classname="net.sourceforge.jarbundler.JarBundler" />
664
665 </project>