Imported Upstream version 2.9.2+ds
[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@Ohloh:          https://www.ohloh.net/p/jabref
13              Jabref git repository: git://jabref.git.sourceforge.net/gitroot/jabref/jabref
14
15              Further questions:
16                help mailing list:   https://lists.sourceforge.net/lists/listinfo/jabref-users
17
18    Precondition: 1. Ant should be installed.
19                  2. JAVA_HOME environment variable contains the path to JDK1.6 or higher
20                  3. ANT_HOME environment variable contains the path to ant's home directory
21
22    Language: XML
23    Compiler: Ant
24    Authors:  Joerg K. Wegner, wegnerj@informatik.uni-tuebingen.de
25              Morten O. Alver
26
27    modified: see at git checkout and "gitk build.xml"
28
29 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
30
31 <project name="JabRef" default="jars" basedir=".">
32
33         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34         PROPERTY SETUP
35      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
36
37         <!-- some version information -->
38         <property name="jabref.version" value="2.9.2" />
39         <property name="jabref.version.full" value="2.9.2.0" /> <!-- a version number with 4 places. Required by launch4j -->
40         <property name="jabref.year" value="2013" />
41         <property name="jabref.placeholder.version" value="@version@" />
42         <property name="jabref.placeholder.year" value="@year@" />
43         <!-- used by replace task -->
44
45         <!-- Set the properties for intermediate directory -->
46         <property name="build.jar" value="JabRef-${jabref.version}.jar" />
47         <property name="build.dir" value="build" />
48         <property name="build.classes" value="${build.dir}/classes" />
49         <property name="build.tmp" value="${build.dir}/tmp" />
50         <property name="build.osx" value="${build.dir}/classes/osxadapter" />
51         <property name="build.lib" value="${build.dir}/lib" />
52         <property name="build.win" value="${build.dir}/windows" />
53         <property name="build.images" value="${build.dir}/images" />
54         <property name="build.fonts" value="${build.dir}/images/font" />
55         <property name="build.resource" value="${build.dir}/resource" />
56         <property name="build.help" value="${build.dir}/help" />
57         <property name="build.javadocs" value="${build.dir}/docs/API" />
58         <property name="build.extensions" value="${build.dir}/extensions" />
59         <property name="build.extension-javadocs" value="${build.extensions}/API" />
60         <property name="build.extension-layout" value="${build.extensions}/layout" />
61         <property name="build.openoffice.meta" value="${build.resource}/openoffice" />
62         <property name="build.tests" value="${build.dir}/tests" />
63
64         <!-- Set the properties for source directories -->
65         <property name="src.dir" value="src" />
66         <property name="src.tests" value="src/java/tests" />
67         <property name="plugin.dir" value="src/plugins/" />
68         <property name="txt.dir" value="src/txt" />
69         <property name="java.dir" value="${src.dir}/java" />
70         <property name="osx.dir" value="${src.dir}/osx" />
71         <property name="win.installer.dir" value="${src.dir}/windows/nsis" />
72         <property name="resource.dir" value="${src.dir}/resource" />
73         <property name="bin.dir" value="${src.dir}/scripts" />
74         <property name="images.dir" value="${src.dir}/images" />
75         <property name="fonts.dir" value="${src.dir}/images/font" />
76         <property name="help.dir" value="${src.dir}/help" />
77         <property name="extensions.dir" value="${src.dir}/extensions" />
78         <property name="layout.dir" value="${src.dir}/resource/layout" />
79         <property name="lib.dir" value="lib" />
80         <property name="buildlib.dir" value="buildlib" />
81         <property name="tests.dir" value="${src.dir}/tests" />
82
83         <property name="osxbin.dir" value="osx" />
84
85         <!-- Load user dependent properties. Has to happen before setting the properties here -->
86         <!-- For instance to redefine the NSIS-compiler write 
87                 nsis.executable="d:\\prog\\dev\\NSIS\\makensis.exe"
88           -->
89         <property file="user.properties" />
90
91         <property name="nsis.executable" value="C:\Program files\NSIS\makensis.exe"/>
92         <property name="nsis.executable.linux" value="makensis"/>
93         <property name="launch4j.dir" location="/opt/launch4j" />
94
95         <!-- win.installer can only be build under Windows if the nsis.executable is found -->
96         <condition property="is.windows">
97           <and>
98             <isset property="nsis.executable" />
99             <os family="windows" />
100           </and>
101         </condition>
102
103         <fileset id="jarsFileset" dir="${lib.dir}">
104                 <include name="antlr.jar" />
105                 <include name="antlr-3.4-complete.jar" />
106         <include name="jgoodies-common-1.4.0.jar" />
107                 <include name="jgoodies-looks-2.5.2.jar" />
108                 <include name="jgoodies-forms-1.6.0.jar" />
109                 <include name="jayatana-1.2.4.jar" />
110                 <include name="spin.jar" />
111                 <include name="glazedlists-1.8.0_java15.jar" />
112                 <include name="microba.jar" />
113                 <include name="pdfbox-1.7.1.jar" />
114                 <include name="jempbox-1.7.1.jar" />
115                 <include name="fontbox-1.7.1.jar" />
116                 <include name="zoom-java.jar" />
117         <include name="mysql-connector-java-5.0.7-bin.jar" />
118                 <include name="postgresql-9.2-1002.jdbc4.jar" />
119         <!-- Plugin runtime dependencies -->
120                 <include name="plugin/JPFCodeGenerator-rt.jar" />
121                 <include name="plugin/jpf.jar" />
122                 <include name="plugin/jpf-boot.jar" />
123                 <include name="plugin/commons-logging.jar" />
124         </fileset>
125
126     <!-- Openoffice connection dependencies. Compile-time only -->
127     <fileset id="ooFileset" dir="${lib.dir}">
128         <include name="oo/unoil.jar" />
129         <include name="oo/ridl.jar" />
130         <include name="oo/juh.jar" />
131         <include name="oo/jurt.jar" />
132     </fileset>
133
134     <!-- Done by MrDlib -->
135     <fileset id="splJars" dir="${lib.dir}">
136         <include name="spl/**/*.jar" />
137         <include name="spl/*.jar" />
138     </fileset>
139         <fileset id="deletableMeta-InfFiles" dir="${build.tmp}/META-INF">
140                 <exclude name="services/**/*" />                
141         </fileset>
142     <!-- Done by MrDlib -->
143
144         <!-- Build classpath -->
145         <path id="classpath">
146                 <pathelement path="${build.classes}" />
147                 <pathelement path="${build.dir}" />
148         <!-- Done by MrDlib -->
149         <pathelement path="${lib.dir}/spl" />
150         <fileset refid="splJars" />
151         <!-- Done by MrDlib -->
152                 <fileset refid="jarsFileset" />
153         <fileset refid="ooFileset" />
154         </path>
155
156         <!-- Classpath for running the code generator -->
157         <path id="codegenerator">
158                 <pathelement location="${lib.dir}/plugin/JPFCodeGenerator.jar" />
159                 <pathelement location="${lib.dir}/plugin/jpf.jar" />
160                 <pathelement location="${lib.dir}/plugin/jpf-boot.jar" />
161                 <pathelement location="${lib.dir}/plugin/velocity-dep-1.5.jar" />
162         </path>
163
164         <!-- Classpath for tests -->
165         <path id="classpathTest">
166                 <path refid="classpath" />
167                 <pathelement location="${buildlib.dir}/junit.jar" />
168         </path>
169
170         <target name="run" depends="build">
171                 <java classname="net.sf.jabref.JabRefMain" fork="true">
172                         <classpath refid="classpath" />
173                 </java>
174         </target>
175
176         <!-- Runs project -->
177         <target name="runFromJar">
178                 <java dir="${build.lib}" classname="net.sf.jabref.JabRefMain" fork="true">
179                         <classpath>
180                                 <pathelement location="${build.lib}/${build.jar}" />
181                         </classpath>
182                 </java>
183         </target>
184
185         <!-- Only rerun the code generator if plug-in xml or jars are newer than generated java file. -->
186         <uptodate property="needsNoRegenerate" targetfile="${java.dir}/net/sf/jabref/plugin/core/generated/_JabRefPlugin.java">
187                 <srcfiles dir=".">
188                         <include name="${plugin.dir}/**/plugin.xml" />
189                         <include name="${lib.dir}/plugin/*.jar" />
190                 </srcfiles>
191         </uptodate>
192
193         <!-- Run the JPF Code Generator -->
194         <target name="generate" unless="needsNoRegenerate">
195                 <java classname="net.sf.jabref.plugin.util.CodeGenerator" fork="true">
196                         <arg value="${plugin.dir}" />
197                         <classpath refid="codegenerator" />
198                 </java>
199         </target>
200
201         <!-- Compiles project excluding tests -->
202         <target name="compile" depends="generate">
203                 <mkdir dir="${build.classes}" />
204                 <javac debug="on" deprecation="on" destdir="${build.classes}" encoding="UTF8"
205                    source="1.6" target="1.6">
206                         <src path="${java.dir}" />
207                         <exclude name="tests/**" />
208                         <exclude name="**/JabRefMain.java" />
209                         <classpath refid="classpath" />
210                 </javac>
211                 <javac debug="off" deprecation="on" destdir="${build.classes}" source="1.6" target="1.6">
212                         <src path="${java.dir}" />
213                         <include name="**/JabRefMain.java" />
214                 </javac>
215         </target>
216
217         <!-- Compiles project including tests -->
218         <target name="compiletest">
219                 <mkdir dir="${build.classes}" />
220                 <javac debug="on" destdir="${build.classes}" source="1.6" target="1.6">
221                         <src path="${java.dir}" />
222                         <include name="tests/**" />
223                         <classpath refid="classpathTest" />
224                 </javac>
225         </target>
226
227         <!-- Builds the OSXAdapter -->
228         <target name="osx">
229                 <mkdir dir="${build.classes}" />
230
231                 <javac srcdir="${osx.dir}" debug="off" destdir="${build.classes}" target="1.6">
232                 </javac>
233         </target>
234
235         <!-- Copies in the OSXAdapter class, which is compilable only on Mac  -->
236         <target name="non_osx">
237                 <mkdir dir="${build.osx}" />
238                 <copy file="${osxbin.dir}/OSXAdapter.class" todir="${build.osx}" />
239         </target>
240
241         <!-- Jars up project -->
242         <target name="jars" depends="build, unjarlib">
243                 <mkdir dir="${build.lib}" />
244         
245                 <mkdir dir="${build.tmp}" />
246                 <jar destfile="${build.lib}/${build.jar}" > 
247         <!--<jar destfile="${build.lib}/JabRef-${revision}.jar" manifest="${src.dir}/MANIFEST.MF">-->
248
249                         <fileset dir="${build.classes}" />
250                         <fileset dir="${build.tmp}" />
251                         <fileset dir="${build.dir}">
252                                 <include name="images/**" />
253                                 <include name="help/**" />
254                                 <include name="resource/**" />
255                         </fileset>
256
257                         <!-- Add Plugins -->
258                         <fileset dir="${src.dir}">
259                                 <include name="plugins/**" />
260                         </fileset>
261              <!-- Done by MrDlib -->
262             <fileset dir ="${java.dir}">
263                 <include name="spl/localization/spljabref.properties"/>
264                 <include name="spl/gui/ajax-loader.gif"/>
265                 <include name="spl/gui/mrdlib header.png"/>
266             </fileset>
267             <!-- Done by MrDlib -->
268                         <fileset dir="${lib.dir}">
269                                 <include name="EndNote.zip" />
270                         </fileset>
271                         <fileset dir="${txt.dir}">
272                                 <include name="gpl2.txt" />
273                                 <include name="gpl3.txt" />
274                                 <include name="lesser.txt" />
275                                 <include name="jgoodies.txt" />
276                                 <include name="README" />
277                         </fileset>
278                         <manifest>
279                                 <attribute name="Main-Class" value="net.sf.jabref.JabRefMain" />
280                 <attribute name="Class-Path" value="." />
281                         </manifest>
282                 </jar>
283
284         </target>
285
286         <!-- updates version information with git information.
287              should be used in development builds only
288
289              Use "ant addgitinfo jars" to generate a jar with version information in the filename
290         -->
291         <target name="addgitinfo" description="Adds git version information in ${jabref.version} and ${build.jar}">
292                 <exec executable="git" searchpath="true" outputproperty="git.version" failifexecutionfails="true" errorproperty="">
293                         <arg value="log" />
294                         <arg value="-1" />
295                         <arg value="--pretty=format:%cd - %H" />
296                         <arg value="--date=iso" />
297                 </exec>
298                 <script language="javascript"><![CDATA[
299                         var gitVersion = project.getProperty("git.version");
300                         if ((gitVersion != undefined) && (gitVersion.length() > 0)) {
301                                 // convert "2012-12-16 15:44:07 +0100 - a249a226" to "2012-12-16 15.44.07 - a249a226"
302                                 gitVersion = gitVersion.substr(0,13) + "." + gitVersion.substr(14,2) + "." + gitVersion.substr(17, 2) + gitVersion.substr(25);
303
304                                 // we have to update the properties using JavaScript as properties are normally immutable
305                                 // Properties can be updated using JavaScript and not with the <property>-Task
306                                 var jabrefVersion = project.getProperty("jabref.version");
307                                 jabrefVersion = jabrefVersion + " - " + gitVersion;
308                                 project.setProperty("jabref.version", jabrefVersion);
309                                 project.setProperty("build.jar", "JabRef-" + jabrefVersion + ".jar");
310                         }
311                 ]]></script>
312         </target>
313
314         <!-- copy all necessary files and insert version informations -->
315         <target name="build" depends="compile, buildinfos" description="Build project">
316
317                 <mkdir dir="${build.resource}" />
318
319                 <copy todir="${build.resource}">
320                         <fileset dir="${resource.dir}">
321                                 <include name="**" />
322                         </fileset>
323                 </copy>
324                 <mkdir dir="${build.images}" />
325                 <copy todir="${build.images}">
326                         <fileset dir="${images.dir}">
327                                 <include name="**" />
328                         </fileset>
329                 </copy>
330
331                 <mkdir dir="${build.help}" />
332                 <copy todir="${build.help}">
333                         <fileset dir="${help.dir}" />
334                 </copy>
335
336                 <!-- Insert version informations -->
337                 <replace dir="${build.help}">
338                     <replacefilter
339                             token="${jabref.placeholder.version}" 
340                                 value="${jabref.version}" />
341                     <replacefilter
342                             token="${jabref.placeholder.year}" 
343                                 value="${jabref.year}" />
344                         <include name="**/About.html" />
345                 </replace>
346                 <replace dir="${build.openoffice.meta}" token="${jabref.placeholder.version}" value="${jabref.version}">
347                         <include name="meta.xml" />
348                 </replace>
349
350         </target>
351
352         <!-- Prepare for testing -->
353         <target name="buildtest" depends="build, compiletest" description="Build project for testing">
354
355                 <mkdir dir="${build.tests}" />
356                 <copy todir="${build.tests}">
357                         <fileset dir="${tests.dir}">
358                                 <include name="**" />
359                         </fileset>
360                 </copy>
361         </target>
362
363         <!-- generate and save some build infos !!! necessary for dynamic build infos !!! -->
364         <!-- todo : replace it by the replace task :-),
365           src/resource/build.properties = template
366           build/resource/build.properties = real info file
367         -->
368         <target name="buildinfos">
369                 <tstamp />
370                 <!-- get date -->
371                 <buildnumber />
372                 <!-- generate new build number -> build.number -->
373                 <echo message="build number = ${build.number}" />
374                 <!-- write the file, please do not edit this lines -->
375                 <echo file="${resource.dir}/build.properties">builddate=${TODAY}
376 build=${build.number}
377 version=${jabref.version}</echo>
378         </target>
379
380
381         <!-- Creates all docs -->
382         <target name="docs" depends="javadocs" description="Generates all the documentation" />
383
384         <!-- Creates javadocs -->
385         <target name="javadocs" depends="compile" description="Generates the javadocs">
386                 <mkdir dir="${build.javadocs}" />
387                 <javadoc sourcepath="${java.dir}" destdir="${build.javadocs}" author="true" version="true" windowtitle="JabRef API" link="http://docs.oracle.com/javase/6/docs/api/">
388
389                         <fileset dir="${java.dir}" defaultexcludes="yes">
390                                 <include name="**/*.java" />
391                         </fileset>
392
393                         <classpath refid="classpath" />
394                 </javadoc>
395         </target>
396
397         <!-- Creates javadocs for the extensions -->
398         <target name="extension-javadocs" depends="build" description="Generates the javadocs for the extensions archive">
399                 <mkdir dir="${build.extension-javadocs}" />
400                 <copy todir="${build.extension-javadocs}">
401                         <fileset dir="${help.dir}" defaultexcludes="yes">
402                                 <include name="CustomExports.html" />
403                                 <include name="CustomImports.html" />
404                         </fileset>
405                 </copy>
406
407                 <javadoc sourcepath="${java.dir}" destdir="${build.extension-javadocs}" author="true" version="true" windowtitle="JabRef-Extensions API" link="http://docs.oracle.com/javase/6/docs/api/" Overview="${extensions.dir}/API/overview.html" access="protected">
408                         <!-- 
409                  create javadoc only selectively for classes that 
410                  users extending JabRef are likely to use
411               -->
412                         <fileset dir="${java.dir}" defaultexcludes="yes">
413                                 <include name="net/sf/jabref/imports/ImportFormat.java" />
414                                 <include name="net/sf/jabref/imports/ImportFormatReader.java" />
415                                 <include name="net/sf/jabref/BibtexEntry.java" />
416                                 <include name="net/sf/jabref/BibtexEntryType.java" />
417                                 <include name="net/sf/jabref/AuthorList.java" />
418                                 <include name="net/sf/jabref/AuthorList.java" />
419                                 <include name="net/sf/jabref/export/layout/LayoutFormatter.java" />
420                         </fileset>
421
422                         <classpath refid="classpath" />
423                 </javadoc>
424         </target>
425
426         <!-- Creates javadocs for the extensions -->
427         <target name="extensions" depends="extension-javadocs" description="Generates the extensions archive">
428                 <!-- copy examples -->
429                 <copy todir="${build.extensions}">
430                         <fileset dir="${java.dir}">
431                                 <include name="net/sf/jabref/export/layout/format/CurrentDate.java" />
432                                 <include name="net/sf/jabref/export/layout/format/ToLowerCase.java" />
433                                 <include name="net/sf/jabref/export/layout/format/HTMLChars.java" />
434                                 <include name="net/sf/jabref/imports/*Importer.java" />
435                         </fileset>
436                 </copy>
437                 <mkdir dir="${build.extension-layout}" />
438                 <copy todir="${build.extension-layout}">
439                         <fileset dir="${layout.dir}" />
440                 </copy>
441                 <copy todir="${build.extensions}">
442                         <fileset dir="${extensions.dir}" />
443                         <filterset>
444                                 <filter token="version" value="${jabref.version}" />
445                         </filterset>
446                 </copy>
447                 <!-- create extensions-zip file -->
448                 <zip destfile="${build.dir}/jabref-extensions.zip">
449                         <zipfileset dir="${build.extensions}" prefix="jabref-extensions" />
450                 </zip>
451         </target>
452
453         <target name="clean" depends="win.installer.clean" description="Clean project">
454                 <delete dir="${build.dir}" />
455         </target>
456
457         <!-- Unpacks jar needed jar files from lib directory into temp directory. -->
458         <target name="unjarlib" description="Unpacks jars from library">
459                 <mkdir dir="${build.tmp}" />
460                 <unjar dest="${build.tmp}">
461                         <fileset refid="jarsFileset" />
462                         <fileset refid="splJars" />
463                 </unjar>
464                 <!-- done by MrDlib -->
465                 <delete includeEmptyDirs="true">
466                         <fileset refid="deletableMeta-InfFiles" />
467                 </delete>
468                 <!-- done by MrDlib -->
469                 <!-- rename the microba license file -->
470                 <move file="${build.tmp}/license.txt" tofile="${build.tmp}/microba-license.txt" />
471         </target>
472
473
474         <target name="osxjar" depends="jars">
475                 <jarbundler dir="${build.lib}"
476                     name="JabRef"
477                     mainclass="net.sf.jabref.JabRef"
478                     jars="${build.lib}/${build.jar}"
479                     icon="${images.dir}/JabRef-Logo.icns"
480                     version="${jabref.version}"
481                     jvmversion="1.6+"
482                     stubfile="${osxbin.dir}/JavaApplicationStub"
483                     signature="JABr">
484             <documenttype name="BibTeX file" extensions="bib" role="Editor"
485                           iconFile="${images.dir}/JabRef-Logo.icns"/>
486         </jarbundler>
487         <!-- After running jarbundler we need to hack the Info.plist file: -->
488         <replace file="${build.lib}/JabRef.app/Contents/Info.plist" token="&lt;key&gt;CFBundleDocumentTypes&lt;/key&gt;"
489             value="&lt;key&gt;NSPrincipalClass&lt;/key&gt;${line.separator}
490    &lt;string&gt;NSApplication&lt;/string&gt;${line.separator}
491    &lt;key&gt;CFBundleDocumentTypes&lt;/key&gt;"/>
492                 <zip basedir="${build.lib}"
493                         destfile="${build.lib}/JabRef-${jabref.version}-OSX.zip"
494                         excludes="JabRef.app/Contents/MacOS/JavaApplicationStub"
495                         includes="JabRef.app/"
496                         level="9">
497                         <zipfileset dir="${build.lib}" includes="JabRef.app/Contents/MacOS/JavaApplicationStub" filemode="755" />
498                 </zip>
499         </target>
500
501
502         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
503         <!-- Build Windows Installer                                                    -->
504         <!--                                                                            -->
505         <!-- Don't forget to set nsis.executable and launch4j.dir properties            -->
506         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
507
508         <target name="win.installer.clean" description="Delete Installer and Exe-Wrapper + Temp-files">
509                 <delete failonerror="false" dir="${win.installer.dir}/dist" />
510                 <delete file="${win.installer.dir}/JabRefSetup.exe" />
511         </target>
512
513         <target name="win.installer.win.pre" description="Precondition for win.installer on Windows">
514                 <fail unless="is.windows" message="Not running on windows or NSIS not found. Please make sure that user.properties exists" />
515         </target>
516
517         <target name="win.installer.step1">
518                 <!-- Gather everything that will go into the installer in dist -->
519                 <mkdir dir="${win.installer.dir}/dist" />
520
521                 <copy file="${build.lib}/${build.jar}" todir="${win.installer.dir}/dist" />
522
523                 <available property="win.installer.jar.available" file="${win.installer.dir}/dist/${build.jar}" />
524
525                 <fail unless="win.installer.jar.available" message="Did not find jar: ${build.jar}" />
526
527                 <copy todir="${win.installer.dir}/dist">
528                         <fileset dir="${txt.dir}">
529                                 <include name="gpl2.txt" />
530                                 <include name="gpl3.txt" />
531                                 <include name="lesser.txt" />
532                                 <include name="README" />
533                         </fileset>
534                 </copy>
535
536                 <!-- "Create Exe-Wrapper" -->
537
538                 <!-- first of all, update version information -->
539                 <script language="javascript"><![CDATA[
540                         // create new property with a maximum length of 50 characters
541                         var txtFileVersion = project.getProperty("jabref.version");
542                         if (txtFileVersion.length()>50) {
543                                 txtFileVersion = txtFileVersion.substring(0,50);
544                         }
545                         project.setProperty("txtFileVersion", txtFileVersion);
546                 ]]></script>
547                 <delete file="jabref-launch4j.tmp" />
548                 <copy file="jabref-launch4j.xml" tofile="jabref-launch4j.tmp" />
549                 <replace file="jabref-launch4j.tmp">
550                         <replacefilter token="1.1.1" value="${jabref.version}" />
551                         <replacefilter token="3.3.3" value="${txtFileVersion}" />
552                         <replacefilter token="2.2.2.2" value="${jabref.version.full}" />
553                         <replacefilter token="./" value="${basedir}/" />
554                 </replace>
555
556         </target>
557
558         <target name="win.installer.step2.linux" description="Create Windows launcher and Windows installer on Linux">
559                 <!-- launch4j ant task does not work as ld.exe gets the wrong path passed - see https://sourceforge.net/tracker/?func=detail&aid=3598164&group_id=95944&atid=613100 -->
560                 <exec
561                         executable="${launch4j.dir}/launch4j"
562                         dir="${launch4j.dir}">
563                         <arg value="${basedir}/jabref-launch4j.tmp"/>
564                 </exec>
565
566                 <!-- Finally create Windows-Installer -->
567                 <exec dir="." executable="${nsis.executable.linux}" failonerror="true">
568                         <arg line="'-DVERSION=${jabref.version}' ${win.installer.dir}/setup.nsi" />
569                 </exec>
570         </target>
571
572         <target name="win.installer.step2.win" description="Create Windows launcher and Windows installer on Windows">
573                 <!-- launch4j ant task does not work as ld.exe gets the wrong path passed - see https://sourceforge.net/tracker/?func=detail&aid=3598164&group_id=95944&atid=613100 -->
574                 <exec
575                         executable="${launch4j.dir}/launch4jc.exe"
576                         dir="${launch4j.dir}">
577                         <arg value="${basedir}/jabref-launch4j.tmp"/>
578                 </exec>
579
580                 <exec dir="." executable="${nsis.executable}" failonerror="true">
581                         <arg line="'/DVERSION=${jabref.version}' ${win.installer.dir}/setup.nsi" />
582                 </exec>
583         </target>
584
585         <target name="win.installer.step3">
586                 <move file="${win.installer.dir}/JabRefSetup.exe" tofile="${build.lib}/JabRef-${jabref.version}-setup.exe" />
587                 <delete dir="${win.installer.dir}/dist" />
588         </target>
589
590         <target name="win.installer" description="Copy files in place to be used by the installer" depends="win.installer.win.pre, jars, win.installer.step1, win.installer.step2.win, win.installer.step3">
591         </target>
592
593         <target name="win.installer.linux" description="Copy files in place to be used by the installer" depends="jars, win.installer.step1, win.installer.step2.linux, win.installer.step3">
594                 <delete dir="${win.installer.dir}/dist" />
595
596         </target>
597
598         <target name="test" depends="buildtest" description="Runs all unit tests">
599                 <java fork="yes" classname="junit.textui.TestRunner" failonerror="true">
600                         <arg value="tests.net.sf.jabref.AllTests" />
601                         <classpath refid="classpathTest" />
602                 </java>
603         </target>
604
605         <!--+++++++++++++++++++++++++++++++++++++++++++++++++
606            Auxiliary targets
607           +++++++++++++++++++++++++++++++++++++++++++++++++-->
608
609         <target name="profile" depends="jars" description="Profile JabRef">
610                 <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
611
612                 <nbprofiledirect>
613                         <classpath refid="classpath" />
614                 </nbprofiledirect>
615
616                 <property environment="env" />
617                 <java fork="true" classname="net.sf.jabref.JabRef" dir="${build.dir}" jvm="${profiler.info.jvm}">
618                         <jvmarg value="${profiler.info.jvmargs.agent}" />
619                         <jvmarg line="${profiler.info.jvmargs}" />
620                         <env key="LD_LIBRARY_PATH" path="${profiler.info.agentpath}:${env.LD_LIBRARY_PATH}" />
621                         <classpath refid="classpath" />
622                 </java>
623         </target>
624
625         <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
626         What's about the software design ?!;-)
627     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
628
629         <target name="jalopy" description="SOFTWAREDESIGN: source code formatter using the JOELib convention.">
630                 <taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
631                         <classpath>
632                                 <pathelement path="${classpath}" />
633                                 <fileset dir="${lib.dir}">
634                                         <include name="*.jar" />
635                                 </fileset>
636                                 <fileset dir="${buildlib.dir}">
637                                         <include name="*.jar" />
638                                 </fileset>
639                         </classpath>
640                 </taskdef>
641                 <jalopy fileformat="unix" convention="${src.dir}/java/jalopy.format.convention.xml" history="file" historymethod="adler32" loglevel="error" threads="2" classpathref="classpath" backup="bak">
642                         <fileset dir="${src.dir}">
643                                 <include name="java/net/sf/jabref/**/*.java" />
644                         </fileset>
645                 </jalopy>
646         </target>
647
648         <taskdef name="jarbundler" classpath="${buildlib.dir}/jarbundler-2.2.0.jar" classname="net.sourceforge.jarbundler.JarBundler" />
649
650         <target name="compresssrc">
651                 <!-- clone current repo into tmp dir. Reason: we want to have a clean src.zip, but do not want to execute "git clean -xdf" to allow developers having some temporary files (and user.properties) -->
652                 <mkdir dir="${temp.dir}"/>
653                 <exec executable="git" searchpath="true" failifexecutionfails="true" outputproperty="devnull" errorproperty="devnull">
654                         <arg value="clone" />
655                         <arg value="${basedir}/.." />
656                         <arg value="${temp.dir}" />
657                 </exec>
658
659                 <!-- ensure correct line endings -->
660                 <exec executable="git" searchpath="true" failifexecutionfails="true" outputproperty="devnull" errorproperty="devnull" dir="${temp.dir}">
661                         <arg value="config" />
662                         <arg value="core.autocrlf" />
663                         <arg value="${git.core.autocrlf}" />
664                 </exec>
665                 <exec executable="git" searchpath="true" failifexecutionfails="true" outputproperty="devnull" errorproperty="devnull" dir="${temp.dir}">
666                         <arg value="rm" />
667                         <arg value="--cached" />
668                         <arg value="-r" />
669                         <arg value="." />
670                 </exec>
671                 <exec executable="git" searchpath="true" failifexecutionfails="true" outputproperty="devnull" errorproperty="devnull" dir="${temp.dir}">
672                         <arg value="reset" />
673                         <arg value="--hard" />
674                 </exec>
675
676                 <!-- we want to have jabref-${jabref.version} as main directory -->
677                 <mkdir dir="${distsrc}" />
678                 <move file="${temp.dir}/jabref" tofile="${distsrc}/jabref-${jabref.version}" />
679         </target>
680
681         <target name="zipsrc">
682                 <tempfile property="temp.dir" destDir="${java.io.tmpdir}" prefix="jabrefsrc"/>
683                 <property name="distsrc" value="${temp.dir}/distsrc/" />
684                 <antcall target="compresssrc">
685                         <param name="git.core.autocrlf" value="true" />
686                 </antcall>
687                 <zip destfile="${build.lib}/JabRef-${jabref.version}-src.zip" basedir="${distsrc}" level="9" />
688                 <delete dir="${temp.dir}" failonerror="no"/>
689         </target>
690
691         <target name="bzip2src">
692                 <tempfile property="temp.dir" destDir="${java.io.tmpdir}" prefix="jabrefsrc"/>
693                 <property name="distsrc" value="${temp.dir}/distsrc/" />
694                 <antcall target="compresssrc">
695                         <param name="git.core.autocrlf" value="false" />
696                 </antcall>
697                 <tar destfile="${build.lib}/JabRef-${jabref.version}-src.tar.bz2" basedir="${distsrc}" excludes=".git/" compression="bzip2" />
698                 <delete dir="${temp.dir}" failonerror="no"/>
699         </target>
700
701         <!-- creates all distribution files in ${build.lib} -->
702         <target name="release" depends="clean, win.installer, non_osx, osxjar, bzip2src, zipsrc" />
703         <target name="release.linux" depends="clean, win.installer.linux, non_osx, osxjar, bzip2src, zipsrc" />
704 </project>