New upstream release.
[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.10b2" />
39         <property name="jabref.version.full" value="2.10.0.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" source="1.6" target="1.6">
205                         <src path="${java.dir}" />
206                         <exclude name="tests/**" />
207                         <exclude name="**/JabRefMain.java" />
208                         <classpath refid="classpath" />
209                 </javac>
210                 <javac debug="off" deprecation="on" destdir="${build.classes}" encoding="UTF8" source="1.6" target="1.6">
211                         <src path="${java.dir}" />
212                         <include name="**/JabRefMain.java" />
213                 </javac>
214         </target>
215
216         <!-- Compiles project including tests -->
217         <target name="compiletest">
218                 <mkdir dir="${build.classes}" />
219                 <javac debug="on" destdir="${build.classes}" encoding="UTF8" source="1.6" target="1.6">
220                         <src path="${java.dir}" />
221                         <include name="tests/**" />
222                         <classpath refid="classpathTest" />
223                 </javac>
224         </target>
225
226         <!-- Builds the OSXAdapter -->
227         <target name="osx">
228                 <mkdir dir="${build.classes}" />
229
230                 <javac srcdir="${osx.dir}" debug="off" destdir="${build.classes}" target="1.6">
231                 </javac>
232         </target>
233
234         <!-- Copies in the OSXAdapter class, which is compilable only on Mac  -->
235         <target name="non_osx">
236                 <mkdir dir="${build.osx}" />
237                 <copy file="${osxbin.dir}/OSXAdapter.class" todir="${build.osx}" />
238         </target>
239
240         <!-- Jars up project -->
241         <target name="jars" depends="build, unjarlib">
242                 <mkdir dir="${build.lib}" />
243
244                 <mkdir dir="${build.tmp}" />
245                 <jar destfile="${build.lib}/${build.jar}" >
246         <!--<jar destfile="${build.lib}/JabRef-${revision}.jar" manifest="${src.dir}/MANIFEST.MF">-->
247
248                         <fileset dir="${build.classes}" />
249                         <fileset dir="${build.tmp}" />
250                         <fileset dir="${build.dir}">
251                                 <include name="images/**" />
252                                 <include name="help/**" />
253                                 <include name="resource/**" />
254                         </fileset>
255
256                         <!-- Add Plugins -->
257                         <fileset dir="${src.dir}">
258                                 <include name="plugins/**" />
259                         </fileset>
260              <!-- Done by MrDlib -->
261             <fileset dir ="${java.dir}">
262                 <include name="spl/localization/spljabref.properties"/>
263                 <include name="spl/gui/ajax-loader.gif"/>
264                 <include name="spl/gui/mrdlib header.png"/>
265             </fileset>
266             <!-- Done by MrDlib -->
267                         <fileset dir="${lib.dir}">
268                                 <include name="EndNote.zip" />
269                         </fileset>
270                         <fileset dir="${txt.dir}">
271                                 <include name="gpl2.txt" />
272                                 <include name="gpl3.txt" />
273                                 <include name="lesser.txt" />
274                                 <include name="jgoodies.txt" />
275                                 <include name="README" />
276                         </fileset>
277                         <manifest>
278                                 <attribute name="Main-Class" value="net.sf.jabref.JabRefMain" />
279                 <attribute name="Class-Path" value="." />
280                         </manifest>
281                 </jar>
282
283         </target>
284
285         <!-- updates version information with git information.
286              should be used in development builds only
287
288              Use "ant addgitinfo jars" to generate a jar with version information in the filename
289         -->
290         <target name="addgitinfo" description="Adds git version information in ${jabref.version} and ${build.jar}">
291                 <exec executable="git" searchpath="true" outputproperty="git.version" failifexecutionfails="true" errorproperty="">
292                         <arg value="log" />
293                         <arg value="-1" />
294                         <arg value="--pretty=format:%cd - %H" />
295                         <arg value="--date=iso" />
296                 </exec>
297                 <script language="javascript"><![CDATA[
298                         var gitVersion = project.getProperty("git.version");
299                         if ((gitVersion != undefined) && (gitVersion.length() > 0)) {
300                                 // convert "2012-12-16 15:44:07 +0100 - a249a226" to "2012-12-16 15.44.07 - a249a226"
301                                 gitVersion = gitVersion.substr(0,13) + "." + gitVersion.substr(14,2) + "." + gitVersion.substr(17, 2) + gitVersion.substr(25);
302
303                                 // we have to update the properties using JavaScript as properties are normally immutable
304                                 // Properties can be updated using JavaScript and not with the <property>-Task
305                                 var jabrefVersion = project.getProperty("jabref.version");
306                                 jabrefVersion = jabrefVersion + " - " + gitVersion;
307                                 project.setProperty("jabref.version", jabrefVersion);
308                                 project.setProperty("build.jar", "JabRef-" + jabrefVersion + ".jar");
309                         }
310                 ]]></script>
311         </target>
312
313         <!-- copy all necessary files and insert version informations -->
314         <target name="build" depends="compile, buildinfos" description="Build project">
315
316                 <mkdir dir="${build.resource}" />
317
318                 <copy todir="${build.resource}">
319                         <fileset dir="${resource.dir}">
320                                 <include name="**" />
321                         </fileset>
322                 </copy>
323                 <mkdir dir="${build.images}" />
324                 <copy todir="${build.images}">
325                         <fileset dir="${images.dir}">
326                                 <include name="**" />
327                         </fileset>
328                 </copy>
329
330                 <mkdir dir="${build.help}" />
331                 <copy todir="${build.help}">
332                         <fileset dir="${help.dir}" />
333                 </copy>
334
335                 <!-- Insert version informations -->
336                 <replace dir="${build.help}">
337                     <replacefilter
338                             token="${jabref.placeholder.version}"
339                                 value="${jabref.version}" />
340                     <replacefilter
341                             token="${jabref.placeholder.year}"
342                                 value="${jabref.year}" />
343                         <include name="**/About.html" />
344                 </replace>
345                 <replace dir="${build.openoffice.meta}" token="${jabref.placeholder.version}" value="${jabref.version}">
346                         <include name="meta.xml" />
347                 </replace>
348
349         </target>
350
351         <!-- Prepare for testing -->
352         <target name="buildtest" depends="build, compiletest" description="Build project for testing">
353
354                 <mkdir dir="${build.tests}" />
355                 <copy todir="${build.tests}">
356                         <fileset dir="${tests.dir}">
357                                 <include name="**" />
358                         </fileset>
359                 </copy>
360         </target>
361
362         <!-- generate and save some build infos !!! necessary for dynamic build infos !!! -->
363         <!-- todo : replace it by the replace task :-),
364           src/resource/build.properties = template
365           build/resource/build.properties = real info file
366         -->
367         <target name="buildinfos">
368                 <tstamp />
369                 <!-- get date -->
370                 <buildnumber />
371                 <!-- generate new build number -> build.number -->
372                 <echo message="build number = ${build.number}" />
373                 <!-- write the file, please do not edit this lines -->
374                 <echo file="${resource.dir}/build.properties">builddate=${TODAY}
375 build=${build.number}
376 version=${jabref.version}</echo>
377         </target>
378
379
380         <!-- Creates all docs -->
381         <target name="docs" depends="javadocs" description="Generates all the documentation" />
382
383         <!-- Creates javadocs -->
384         <target name="javadocs" depends="compile" description="Generates the javadocs">
385                 <mkdir dir="${build.javadocs}" />
386                 <javadoc sourcepath="${java.dir}" destdir="${build.javadocs}" author="true" version="true" windowtitle="JabRef API" link="http://docs.oracle.com/javase/6/docs/api/">
387
388                         <fileset dir="${java.dir}" defaultexcludes="yes">
389                                 <include name="**/*.java" />
390                         </fileset>
391
392                         <classpath refid="classpath" />
393                 </javadoc>
394         </target>
395
396         <!-- Creates javadocs for the extensions -->
397         <target name="extension-javadocs" depends="build" description="Generates the javadocs for the extensions archive">
398                 <mkdir dir="${build.extension-javadocs}" />
399                 <copy todir="${build.extension-javadocs}">
400                         <fileset dir="${help.dir}" defaultexcludes="yes">
401                                 <include name="CustomExports.html" />
402                                 <include name="CustomImports.html" />
403                         </fileset>
404                 </copy>
405
406                 <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">
407                         <!--
408                  create javadoc only selectively for classes that
409                  users extending JabRef are likely to use
410               -->
411                         <fileset dir="${java.dir}" defaultexcludes="yes">
412                                 <include name="net/sf/jabref/imports/ImportFormat.java" />
413                                 <include name="net/sf/jabref/imports/ImportFormatReader.java" />
414                                 <include name="net/sf/jabref/BibtexEntry.java" />
415                                 <include name="net/sf/jabref/BibtexEntryType.java" />
416                                 <include name="net/sf/jabref/AuthorList.java" />
417                                 <include name="net/sf/jabref/AuthorList.java" />
418                                 <include name="net/sf/jabref/export/layout/LayoutFormatter.java" />
419                         </fileset>
420
421                         <classpath refid="classpath" />
422                 </javadoc>
423         </target>
424
425         <!-- Creates javadocs for the extensions -->
426         <target name="extensions" depends="extension-javadocs" description="Generates the extensions archive">
427                 <!-- copy examples -->
428                 <copy todir="${build.extensions}">
429                         <fileset dir="${java.dir}">
430                                 <include name="net/sf/jabref/export/layout/format/CurrentDate.java" />
431                                 <include name="net/sf/jabref/export/layout/format/ToLowerCase.java" />
432                                 <include name="net/sf/jabref/export/layout/format/HTMLChars.java" />
433                                 <include name="net/sf/jabref/imports/*Importer.java" />
434                         </fileset>
435                 </copy>
436                 <mkdir dir="${build.extension-layout}" />
437                 <copy todir="${build.extension-layout}">
438                         <fileset dir="${layout.dir}" />
439                 </copy>
440                 <copy todir="${build.extensions}">
441                         <fileset dir="${extensions.dir}" />
442                         <filterset>
443                                 <filter token="version" value="${jabref.version}" />
444                         </filterset>
445                 </copy>
446                 <!-- create extensions-zip file -->
447                 <zip destfile="${build.dir}/jabref-extensions.zip">
448                         <zipfileset dir="${build.extensions}" prefix="jabref-extensions" />
449                 </zip>
450         </target>
451
452         <target name="clean" depends="win.installer.clean" description="Clean project">
453                 <delete dir="${build.dir}" />
454         </target>
455
456         <!-- Unpacks jar needed jar files from lib directory into temp directory. -->
457         <target name="unjarlib" description="Unpacks jars from library">
458                 <mkdir dir="${build.tmp}" />
459                 <unjar dest="${build.tmp}">
460                         <fileset refid="jarsFileset" />
461                         <fileset refid="splJars" />
462                 </unjar>
463                 <!-- done by MrDlib -->
464                 <delete includeEmptyDirs="true">
465                         <fileset refid="deletableMeta-InfFiles" />
466                 </delete>
467                 <!-- done by MrDlib -->
468                 <!-- rename the microba license file -->
469                 <move file="${build.tmp}/license.txt" tofile="${build.tmp}/microba-license.txt" />
470         </target>
471
472
473         <target name="osxjar" depends="jars">
474                 <jarbundler dir="${build.lib}"
475                     name="JabRef"
476                     mainclass="net.sf.jabref.JabRef"
477                     jar="${build.lib}/${build.jar}"
478                     icon="${images.dir}/JabRef-Logo.icns"
479                     version="${jabref.version}"
480                     jvmversion="1.6+"
481                     vmoptions="-Xms128m -Xmx512m"
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         <target name="devsnapshot" depends="clean, addgitinfo, non_osx, win.installer, osxjar" description="creates development snapshot binaries" />
702
703         <target name="release" depends="clean, win.installer, non_osx, osxjar, bzip2src, zipsrc" description="Do a release on Windows. Creates all distribution files in ${build.lib}"/>
704         <target name="release.linux" depends="clean, win.installer.linux, non_osx, osxjar, bzip2src, zipsrc" description="Do a release on Linux. Creates all distribution files in ${build.lib}" />
705 </project>