2 <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 Filename: $RCSfile: build.xml,v $
4 Purpose: Ant build file for Jabref.
6 Ant-Download: http://jakarta.apache.org/ant
7 Ant-Manual: http://jakarta.apache.org/ant/manual/index.html
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
15 help mailing list: must be inserted
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
23 Authors: Joerg K. Wegner, wegnerj@informatik.uni-tuebingen.de
25 Version: $Revision: 1.54.2.3 $
26 $Date: 2006/02/02 09:31:59 $
27 $Author: mortenalver $
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}
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 !!!
39 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
41 <project name="JabRef" default="jars" basedir=".">
43 <!-- ==========================================================================================
45 ========================================================================================== -->
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 -->
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"/>
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" />
82 <!-- Set the properties for library directories -->
83 <property name="library.directory" value="lib" />
86 <taskdef name="jarbundler"
87 classpath="${library.directory}/jarbundler-1.4.jar"
88 classname="com.loomcom.ant.tasks.jarbundler.JarBundler" />
91 <!-- Build 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" />
101 <!-- Runs project (e.g. in NetBeans 4) -->
102 <target name="run" depends="jars">
103 <java classname="net.sf.jabref.JabRef" fork="true">
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" />
117 <!-- Target used for profiling with the Netbeans profiler. -->
118 <!--<target name="profile" depends="jars">
119 <nbprofile classname="net.sf.jabref.JabRef">
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" />
130 <target name="profile" depends="jars" description="Profile JabRef">
131 <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
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" />
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}"/>
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" />
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/**"/>
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" />
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">
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" />
196 <!-- Builds the OSXAdapter -->
198 <mkdir dir="${build.classes}" />
200 <javac srcdir="${osx.dir}" debug="on" destdir="${build.classes}" target="1.4">
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}" />
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/**" />
225 <fileset dir="${library.directory}">
226 <include name="EndNote.zip" />
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" />
237 <attribute name="Main-Class" value="net.sf.jabref.JabRef" />
243 <!-- copy all necessary files and insert version informations -->
244 <target name="build" depends="compile, buildinfos" description="Build project">
245 <mkdir dir="${build.bin}" />
247 <mkdir dir="${build.resource}" />
248 <copy todir="${build.resource}">
249 <fileset dir="${resource.dir}">
250 <include name="**" />
253 <mkdir dir="${build.images}" />
254 <copy todir="${build.images}">
255 <fileset dir="${images.dir}">
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}">
268 <mkdir dir="${build.help}" />
269 <copy todir="${build.help}">
270 <fileset dir="${help.dir}">
271 <!--<include name="*" />-->
275 <!-- Insert version informations -->
276 <replace dir="${build.help}"
277 token="${jabref.placeholder.version}"
278 value="${jabref.version}">
279 <include name="**/About.html"/>
281 <replace dir="${build.openoffice.meta}"
282 token="${jabref.placeholder.version}"
283 value="${jabref.version}">
284 <include name="meta.xml"/>
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}">
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
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>
314 <!-- Creates all docs -->
315 <target name="docs" depends="javadocs" description="Generates all the documentation" />
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/">
322 <fileset dir="${java.dir}" defaultexcludes="yes">
323 <include name="**/*.java" />
326 <classpath refid="classpath" />
330 <target name="clean" description="Clean project">
331 <delete dir="${build.dir}" />
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}" />
346 <delete dir="${build.tmp}/META-INF"/>
350 <target name="osxjar">
351 <jarbundler dir="${build.lib}"
353 mainclass="net.sf.jabref.JabRef"
354 jars="${build.lib}/${jabref.bin}.jar"
355 icon="${images.dir}/JabRef-Logo.icns"
356 version="${jabref.version}"
358 stubfile="${library.directory}/JavaApplicationStub" />
363 <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
364 What's about the software design ?!;-)
365 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
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">
371 <pathelement path="${classpath}" />
372 <fileset dir="${library.directory}">
373 <include name="*.jar" />
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 -->
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" />
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">
407 <pathelement path="${classpath}" />
408 <fileset dir="${library.directory}">
409 <include name="*.jar" />
413 <cpd format="text" minimumTokenCount="100" outputFile="${build.dir}/duplicated_code_report.txt">
414 <fileset dir="${src.dir}">
415 <include name="**/*.java" />
421 <target name="javancss" description="SOFTWAREDESIGN: Determining the NCSS and CCN code metrics for JOELib.">
422 <taskdef name="javancss" classname="javancss.JavancssAntTask">
424 <pathelement path="${classpath}" />
425 <fileset dir="${library.directory}">
426 <include name="*.jar" />
431 Complexity Ease of Risk
432 Number (CCN) maintenance
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
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" />
444 <target name="jalopy" description="SOFTWAREDESIGN: source code formatter using the JOELib convention.">
445 <taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
447 <pathelement path="${classpath}" />
448 <fileset dir="${library.directory}">
449 <include name="*.jar" />
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" />
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" />
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" />
479 <!--<test name="tests.net.sf.jabref.export.layout.format.AuthorLastFirstAbbreviatorTester"/>-->