File: build.xml

package info (click to toggle)
jabref 2.10%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,808 kB
  • ctags: 12,245
  • sloc: java: 90,549; xml: 1,571; python: 270; sh: 207; makefile: 16
file content (708 lines) | stat: -rw-r--r-- 28,418 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
<?xml version="1.0"?>
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Filename: build.xml
   Purpose:  Ant build file for Jabref.

             Ant-Download: http://jakarta.apache.org/ant
             Ant-Manual:   http://jakarta.apache.org/ant/manual/index.html

             Jabref homepage:       http://jabref.sourceforge.net
             Jabref@SourceForge:    http://sourceforge.net/projects/jabref
             Jabref@FreeCode:       http://apps.freecode.com/projects/jabref
             Jabref@Ohloh:          https://www.ohloh.net/p/jabref
             Jabref git repository: git://jabref.git.sourceforge.net/gitroot/jabref/jabref

             Further questions:
               help mailing list:   https://lists.sourceforge.net/lists/listinfo/jabref-users

   Precondition: 1. Ant should be installed.
                 2. JAVA_HOME environment variable contains the path to JDK1.6 or higher
                 3. ANT_HOME environment variable contains the path to ant's home directory

   Language: XML
   Compiler: Ant
   Authors:  Joerg K. Wegner, wegnerj@informatik.uni-tuebingen.de
             Morten O. Alver

   modified: see at git checkout and "gitk build.xml"

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

<project name="JabRef" default="jars" basedir=".">

	<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        PROPERTY SETUP
     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

	<!-- some version information -->
	<property name="jabref.version" value="2.10" />
	<property name="jabref.version.full" value="2.10.0.5" /> <!-- a version number with 4 places. Required by launch4j -->
	<property name="jabref.year" value="2014" />
	<property name="jabref.placeholder.version" value="@version@" />
	<property name="jabref.placeholder.year" value="@year@" />
	<!-- used by replace task -->

	<!-- Set the properties for intermediate directory -->
	<property name="build.jar" value="JabRef-${jabref.version}.jar" />
	<property name="build.dir" value="build" />
	<property name="build.classes" value="${build.dir}/classes" />
	<property name="build.tmp" value="${build.dir}/tmp" />
	<property name="build.osx" value="${build.dir}/classes/osxadapter" />
	<property name="build.lib" value="${build.dir}/lib" />
	<property name="build.win" value="${build.dir}/windows" />
	<property name="build.images" value="${build.dir}/images" />
	<property name="build.fonts" value="${build.dir}/images/font" />
	<property name="build.resource" value="${build.dir}/resource" />
	<property name="build.help" value="${build.dir}/help" />
	<property name="build.javadocs" value="${build.dir}/docs/API" />
	<property name="build.extensions" value="${build.dir}/extensions" />
	<property name="build.extension-javadocs" value="${build.extensions}/API" />
	<property name="build.extension-layout" value="${build.extensions}/layout" />
	<property name="build.openoffice.meta" value="${build.resource}/openoffice" />
	<property name="build.tests" value="${build.dir}/tests" />

	<!-- Set the properties for source directories -->
	<property name="src.dir" value="src" />
	<property name="src.tests" value="src/java/tests" />
	<property name="plugin.dir" value="src/plugins/" />
	<property name="txt.dir" value="src/txt" />
	<property name="java.dir" value="${src.dir}/java" />
	<property name="osx.dir" value="${src.dir}/osx" />
	<property name="win.installer.dir" value="${src.dir}/windows/nsis" />
	<property name="resource.dir" value="${src.dir}/resource" />
	<property name="bin.dir" value="${src.dir}/scripts" />
	<property name="images.dir" value="${src.dir}/images" />
	<property name="fonts.dir" value="${src.dir}/images/font" />
	<property name="help.dir" value="${src.dir}/help" />
	<property name="extensions.dir" value="${src.dir}/extensions" />
	<property name="layout.dir" value="${src.dir}/resource/layout" />
	<property name="lib.dir" value="/usr/share/java" />
	<property name="oo.dir" value="/usr/lib/libreoffice/program/classes" />
	<property name="ure.dir" value="/usr/lib/ure/share/java" />
	<property name="buildlib.dir" value="/usr/share/java" />
	<property name="tests.dir" value="${src.dir}/tests" />

	<property name="osxbin.dir" value="osx" />

	<!-- Load user dependent properties. Has to happen before setting the properties here -->
	<!-- For instance to redefine the NSIS-compiler write
		nsis.executable="d:\\prog\\dev\\NSIS\\makensis.exe"
	  -->
	<property file="user.properties" />

	<property name="nsis.executable" value="C:\Program files\NSIS\makensis.exe"/>
	<property name="nsis.executable.linux" value="makensis"/>
	<property name="launch4j.dir" location="/opt/launch4j" />

	<!-- win.installer can only be build under Windows if the nsis.executable is found -->
	<condition property="is.windows">
	  <and>
	    <isset property="nsis.executable" />
	    <os family="windows" />
	  </and>
	</condition>

	<fileset id="jarsFileset" dir="${lib.dir}">
		<include name="antlr.jar" />
		<include name="antlr3.jar" />
		<include name="antlr3-runtime.jar" />
        <include name="jgoodies-common.jar" />
		<include name="jgoodies-looks.jar" />
		<include name="jgoodies-forms.jar" />
		<include name="spin.jar" />
		<include name="glazedlists.jar" />
		<include name="microba.jar" />
		<include name="pdfbox.jar" />
		<include name="jempbox.jar" />
		<include name="fontbox.jar" />
		<include name="zoom-java.jar" />
    	<include name="mysql-connector-java.jar" />
		<include name="postgresql.jar" />
        <!-- Plugin runtime dependencies -->
		<include name="JPFCodeGenerator-rt.jar" />
		<include name="jpf.jar" />
		<include name="jpf-boot.jar" />
		<include name="commons-logging.jar" />
	</fileset>

    <!-- Openoffice connection dependencies. Compile-time only -->
    <fileset id="ureFileset" dir="${ure.dir}">
        <include name="ridl.jar" />
        <include name="juh.jar" />
        <include name="jurt.jar" />
    </fileset>
    <fileset id="ooFileset" dir="${oo.dir}">
        <include name="unoil.jar" />
    </fileset>

    <!-- Done by MrDlib -->
    <fileset id="splJars" dir="${lib.dir}">
        <include name="spl/**/*.jar" />
        <include name="spl/*.jar" />
    </fileset>
	<fileset id="deletableMeta-InfFiles" dir="${build.tmp}/META-INF">
	        <exclude name="services/**/*" />
	</fileset>
    <!-- Done by MrDlib -->

	<!-- Build classpath -->
	<path id="classpath">
		<pathelement path="${build.classes}" />
		<pathelement path="${build.dir}" />
        <!-- Done by MrDlib -->
        <pathelement path="${lib.dir}/spl" />
        <fileset refid="splJars" />
        <!-- Done by MrDlib -->
		<fileset refid="jarsFileset" />
        <fileset refid="ooFileset" />
        <fileset refid="ureFileset" />
	</path>

	<!-- Classpath for running the code generator -->
	<path id="codegenerator">
		<pathelement location="${lib.dir}/JPFCodeGenerator.jar" />
		<pathelement location="${lib.dir}/jpf.jar" />
		<pathelement location="${lib.dir}/jpf-boot.jar" />
		<pathelement location="${lib.dir}/velocity.jar" />
	</path>

	<!-- Classpath for tests -->
	<path id="classpathTest">
		<path refid="classpath" />
		<pathelement location="${buildlib.dir}/junit.jar" />
	</path>

	<target name="run" depends="build">
		<java classname="net.sf.jabref.JabRefMain" fork="true">
			<classpath refid="classpath" />
		</java>
	</target>

	<!-- Runs project -->
	<target name="runFromJar">
		<java dir="${build.lib}" classname="net.sf.jabref.JabRefMain" fork="true">
			<classpath>
				<pathelement location="${build.lib}/${build.jar}" />
			</classpath>
		</java>
	</target>

	<!-- Only rerun the code generator if plug-in xml or jars are newer than generated java file. -->
	<uptodate property="needsNoRegenerate" targetfile="${java.dir}/net/sf/jabref/plugin/core/generated/_JabRefPlugin.java">
		<srcfiles dir=".">
			<include name="${plugin.dir}/**/plugin.xml" />
			<include name="${lib.dir}/plugin/*.jar" />
		</srcfiles>
	</uptodate>

	<!-- Run the JPF Code Generator -->
	<target name="generate" unless="needsNoRegenerate">
		<java classname="net.sf.jabref.plugin.util.CodeGenerator" fork="true">
			<arg value="${plugin.dir}" />
			<classpath refid="codegenerator" />
		</java>
	</target>

	<!-- Compiles project excluding tests -->
	<target name="compile" depends="generate">
		<mkdir dir="${build.classes}" />
		<javac debug="on" deprecation="on" destdir="${build.classes}" encoding="UTF8" source="1.6" target="1.6">
			<src path="${java.dir}" />
			<exclude name="tests/**" />
			<exclude name="**/JabRefMain.java" />
			<classpath refid="classpath" />
		</javac>
		<javac debug="off" deprecation="on" destdir="${build.classes}" encoding="UTF8" source="1.6" target="1.6">
			<src path="${java.dir}" />
			<include name="**/JabRefMain.java" />
		</javac>
	</target>

	<!-- Compiles project including tests -->
	<target name="compiletest">
		<mkdir dir="${build.classes}" />
		<javac debug="on" destdir="${build.classes}" encoding="UTF8" source="1.6" target="1.6">
			<src path="${java.dir}" />
			<include name="tests/**" />
			<classpath refid="classpathTest" />
		</javac>
	</target>

	<!-- Builds the OSXAdapter -->
	<target name="osx">
		<mkdir dir="${build.classes}" />

		<javac srcdir="${osx.dir}" debug="off" destdir="${build.classes}" target="1.6">
		</javac>
	</target>

	<!-- Copies in the OSXAdapter class, which is compilable only on Mac  -->
	<target name="non_osx">
		<mkdir dir="${build.osx}" />
		<copy file="${osxbin.dir}/OSXAdapter.class" todir="${build.osx}" />
	</target>

	<!-- Jars up project -->
	<target name="jars" depends="build">
		<mkdir dir="${build.lib}" />

		<mkdir dir="${build.tmp}" />
		<jar destfile="${build.lib}/${build.jar}" >
        <!--<jar destfile="${build.lib}/JabRef-${revision}.jar" manifest="${src.dir}/MANIFEST.MF">-->

			<fileset dir="${build.classes}" />
			<fileset dir="${build.tmp}" />
			<fileset dir="${build.dir}">
				<include name="images/**" />
				<include name="help/**" />
				<include name="resource/**" />
			</fileset>

			<!-- Add Plugins -->
			<fileset dir="${src.dir}">
				<include name="plugins/**" />
			</fileset>
             <!-- Done by MrDlib -->
            <fileset dir ="${java.dir}">
                <include name="spl/localization/spljabref.properties"/>
                <include name="spl/gui/ajax-loader.gif"/>
                <include name="spl/gui/mrdlib header.png"/>
            </fileset>
            <!-- Done by MrDlib -->
			<fileset dir="${lib.dir}">
				<include name="EndNote.zip" />
			</fileset>
			<fileset dir="${txt.dir}">
				<include name="gpl2.txt" />
				<include name="gpl3.txt" />
				<include name="lesser.txt" />
				<include name="jgoodies.txt" />
				<include name="README" />
			</fileset>
			<manifest>
				<attribute name="Main-Class" value="net.sf.jabref.JabRefMain" />
                <attribute name="Class-Path" value="." />
			</manifest>
		</jar>

	</target>

	<!-- updates version information with git information.
	     should be used in development builds only

	     Use "ant addgitinfo jars" to generate a jar with version information in the filename
	-->
	<target name="addgitinfo" description="Adds git version information in ${jabref.version} and ${build.jar}">
		<exec executable="git" searchpath="true" outputproperty="git.version" failifexecutionfails="true" errorproperty="">
			<arg value="log" />
			<arg value="-1" />
			<arg value="--pretty=format:%cd - %H" />
			<arg value="--date=iso" />
		</exec>
		<script language="javascript"><![CDATA[
			var gitVersion = project.getProperty("git.version");
			if ((gitVersion != undefined) && (gitVersion.length() > 0)) {
				// convert "2012-12-16 15:44:07 +0100 - a249a226" to "2012-12-16 15.44.07 - a249a226"
				gitVersion = gitVersion.substr(0,13) + "." + gitVersion.substr(14,2) + "." + gitVersion.substr(17, 2) + gitVersion.substr(25);

				// we have to update the properties using JavaScript as properties are normally immutable
				// Properties can be updated using JavaScript and not with the <property>-Task
				var jabrefVersion = project.getProperty("jabref.version");
				jabrefVersion = jabrefVersion + " - " + gitVersion;
				project.setProperty("jabref.version", jabrefVersion);
				project.setProperty("build.jar", "JabRef-" + jabrefVersion + ".jar");
			}
		]]></script>
	</target>

	<!-- copy all necessary files and insert version informations -->
	<target name="build" depends="compile, buildinfos" description="Build project">

		<mkdir dir="${build.resource}" />

		<copy todir="${build.resource}">
			<fileset dir="${resource.dir}">
				<include name="**" />
			</fileset>
		</copy>
		<mkdir dir="${build.images}" />
		<copy todir="${build.images}">
			<fileset dir="${images.dir}">
				<include name="**" />
			</fileset>
		</copy>

		<mkdir dir="${build.help}" />
		<copy todir="${build.help}">
			<fileset dir="${help.dir}" />
		</copy>

		<!-- Insert version informations -->
		<replace dir="${build.help}">
		    <replacefilter
			    token="${jabref.placeholder.version}"
				value="${jabref.version}" />
		    <replacefilter
			    token="${jabref.placeholder.year}"
				value="${jabref.year}" />
			<include name="**/About.html" />
		</replace>
		<replace dir="${build.openoffice.meta}" token="${jabref.placeholder.version}" value="${jabref.version}">
			<include name="meta.xml" />
		</replace>

	</target>

	<!-- Prepare for testing -->
	<target name="buildtest" depends="build, compiletest" description="Build project for testing">

		<mkdir dir="${build.tests}" />
		<copy todir="${build.tests}">
			<fileset dir="${tests.dir}">
				<include name="**" />
			</fileset>
		</copy>
	</target>

	<!-- generate and save some build infos !!! necessary for dynamic build infos !!! -->
	<!-- todo : replace it by the replace task :-),
          src/resource/build.properties = template
          build/resource/build.properties = real info file
	-->
	<target name="buildinfos">
		<tstamp />
		<!-- get date -->
		<buildnumber />
		<!-- generate new build number -> build.number -->
		<echo message="build number = ${build.number}" />
		<!-- write the file, please do not edit this lines -->
		<echo file="${resource.dir}/build.properties">builddate=${TODAY}
build=${build.number}
version=${jabref.version}</echo>
	</target>


	<!-- Creates all docs -->
	<target name="docs" depends="javadocs" description="Generates all the documentation" />

	<!-- Creates javadocs -->
	<target name="javadocs" depends="compile" description="Generates the javadocs">
		<mkdir dir="${build.javadocs}" />
		<javadoc sourcepath="${java.dir}" destdir="${build.javadocs}" author="true" version="true" windowtitle="JabRef API" link="http://docs.oracle.com/javase/6/docs/api/">

			<fileset dir="${java.dir}" defaultexcludes="yes">
				<include name="**/*.java" />
			</fileset>

			<classpath refid="classpath" />
		</javadoc>
	</target>

	<!-- Creates javadocs for the extensions -->
	<target name="extension-javadocs" depends="build" description="Generates the javadocs for the extensions archive">
		<mkdir dir="${build.extension-javadocs}" />
		<copy todir="${build.extension-javadocs}">
			<fileset dir="${help.dir}" defaultexcludes="yes">
				<include name="CustomExports.html" />
				<include name="CustomImports.html" />
			</fileset>
		</copy>

		<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">
			<!--
                 create javadoc only selectively for classes that
                 users extending JabRef are likely to use
              -->
			<fileset dir="${java.dir}" defaultexcludes="yes">
				<include name="net/sf/jabref/imports/ImportFormat.java" />
				<include name="net/sf/jabref/imports/ImportFormatReader.java" />
				<include name="net/sf/jabref/BibtexEntry.java" />
				<include name="net/sf/jabref/BibtexEntryType.java" />
				<include name="net/sf/jabref/AuthorList.java" />
				<include name="net/sf/jabref/AuthorList.java" />
				<include name="net/sf/jabref/export/layout/LayoutFormatter.java" />
			</fileset>

			<classpath refid="classpath" />
		</javadoc>
	</target>

	<!-- Creates javadocs for the extensions -->
	<target name="extensions" depends="extension-javadocs" description="Generates the extensions archive">
		<!-- copy examples -->
		<copy todir="${build.extensions}">
			<fileset dir="${java.dir}">
				<include name="net/sf/jabref/export/layout/format/CurrentDate.java" />
				<include name="net/sf/jabref/export/layout/format/ToLowerCase.java" />
				<include name="net/sf/jabref/export/layout/format/HTMLChars.java" />
				<include name="net/sf/jabref/imports/*Importer.java" />
			</fileset>
		</copy>
		<mkdir dir="${build.extension-layout}" />
		<copy todir="${build.extension-layout}">
			<fileset dir="${layout.dir}" />
		</copy>
		<copy todir="${build.extensions}">
			<fileset dir="${extensions.dir}" />
			<filterset>
				<filter token="version" value="${jabref.version}" />
			</filterset>
		</copy>
		<!-- create extensions-zip file -->
		<zip destfile="${build.dir}/jabref-extensions.zip">
			<zipfileset dir="${build.extensions}" prefix="jabref-extensions" />
		</zip>
	</target>

	<target name="clean" depends="win.installer.clean" description="Clean project">
		<delete dir="${build.dir}" />
	</target>

	<!-- Unpacks jar needed jar files from lib directory into temp directory. -->
	<target name="unjarlib" description="Unpacks jars from library">
		<mkdir dir="${build.tmp}" />
		<unjar dest="${build.tmp}">
			<fileset refid="jarsFileset" />
			<fileset refid="splJars" />
		</unjar>
		<!-- done by MrDlib -->
		<delete includeEmptyDirs="true">
			<fileset refid="deletableMeta-InfFiles" />
		</delete>
		<!-- done by MrDlib -->
		<!-- rename the microba license file -->
		<move file="${build.tmp}/license.txt" tofile="${build.tmp}/microba-license.txt" />
	</target>


	<target name="osxjar" depends="jars">
		<jarbundler dir="${build.lib}"
                    name="JabRef"
                    mainclass="net.sf.jabref.JabRef"
                    jar="${build.lib}/${build.jar}"
                    icon="${images.dir}/JabRef-Logo.icns"
                    version="${jabref.version}"
                    jvmversion="1.6+"
		    vmoptions="-Xms128m -Xmx512m"
                    stubfile="${osxbin.dir}/JavaApplicationStub"
                    signature="JABr">
            <documenttype name="BibTeX file" extensions="bib" role="Editor"
                          iconFile="${images.dir}/JabRef-Logo.icns"/>
        </jarbundler>
        <!-- After running jarbundler we need to hack the Info.plist file: -->
        <replace file="${build.lib}/JabRef.app/Contents/Info.plist" token="&lt;key&gt;CFBundleDocumentTypes&lt;/key&gt;"
            value="&lt;key&gt;NSPrincipalClass&lt;/key&gt;${line.separator}
   &lt;string&gt;NSApplication&lt;/string&gt;${line.separator}
   &lt;key&gt;CFBundleDocumentTypes&lt;/key&gt;"/>
		<zip basedir="${build.lib}"
			destfile="${build.lib}/JabRef-${jabref.version}-OSX.zip"
			excludes="JabRef.app/Contents/MacOS/JavaApplicationStub"
			includes="JabRef.app/"
			level="9">
			<zipfileset dir="${build.lib}" includes="JabRef.app/Contents/MacOS/JavaApplicationStub" filemode="755" />
		</zip>
	</target>


	<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<!-- Build Windows Installer                                                    -->
	<!--                                                                            -->
	<!-- Don't forget to set nsis.executable and launch4j.dir properties            -->
	<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

	<target name="win.installer.clean" description="Delete Installer and Exe-Wrapper + Temp-files">
		<delete failonerror="false" dir="${win.installer.dir}/dist" />
		<delete file="${win.installer.dir}/JabRefSetup.exe" />
	</target>

	<target name="win.installer.win.pre" description="Precondition for win.installer on Windows">
		<fail unless="is.windows" message="Not running on windows or NSIS not found. Please make sure that user.properties exists" />
	</target>

	<target name="win.installer.step1">
		<!-- Gather everything that will go into the installer in dist -->
		<mkdir dir="${win.installer.dir}/dist" />

		<copy file="${build.lib}/${build.jar}" todir="${win.installer.dir}/dist" />

		<available property="win.installer.jar.available" file="${win.installer.dir}/dist/${build.jar}" />

		<fail unless="win.installer.jar.available" message="Did not find jar: ${build.jar}" />

		<copy todir="${win.installer.dir}/dist">
			<fileset dir="${txt.dir}">
				<include name="gpl2.txt" />
				<include name="gpl3.txt" />
				<include name="lesser.txt" />
				<include name="README" />
			</fileset>
		</copy>

		<!-- "Create Exe-Wrapper" -->

		<!-- first of all, update version information -->
		<script language="javascript"><![CDATA[
			// create new property with a maximum length of 50 characters
			var txtFileVersion = project.getProperty("jabref.version");
			if (txtFileVersion.length()>50) {
				txtFileVersion = txtFileVersion.substring(0,50);
			}
			project.setProperty("txtFileVersion", txtFileVersion);
		]]></script>
		<delete file="jabref-launch4j.tmp" />
		<copy file="jabref-launch4j.xml" tofile="jabref-launch4j.tmp" />
		<replace file="jabref-launch4j.tmp">
			<replacefilter token="1.1.1" value="${jabref.version}" />
			<replacefilter token="3.3.3" value="${txtFileVersion}" />
			<replacefilter token="2.2.2.2" value="${jabref.version.full}" />
			<replacefilter token="./" value="${basedir}/" />
		</replace>

	</target>

	<target name="win.installer.step2.linux" description="Create Windows launcher and Windows installer on Linux">
		<!-- 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 -->
		<exec
			executable="${launch4j.dir}/launch4j"
			dir="${launch4j.dir}">
			<arg value="${basedir}/jabref-launch4j.tmp"/>
		</exec>

		<!-- Finally create Windows-Installer -->
		<exec dir="." executable="${nsis.executable.linux}" failonerror="true">
			<arg line="'-DVERSION=${jabref.version}' ${win.installer.dir}/setup.nsi" />
		</exec>
	</target>

	<target name="win.installer.step2.win" description="Create Windows launcher and Windows installer on Windows">
		<!-- 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 -->
		<exec
			executable="${launch4j.dir}/launch4jc.exe"
			dir="${launch4j.dir}">
			<arg value="${basedir}/jabref-launch4j.tmp"/>
		</exec>

		<exec dir="." executable="${nsis.executable}" failonerror="true">
			<arg line="'/DVERSION=${jabref.version}' ${win.installer.dir}/setup.nsi" />
		</exec>
	</target>

	<target name="win.installer.step3">
		<move file="${win.installer.dir}/JabRefSetup.exe" tofile="${build.lib}/JabRef-${jabref.version}-setup.exe" />
		<delete dir="${win.installer.dir}/dist" />
	</target>

	<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">
	</target>

	<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">
		<delete dir="${win.installer.dir}/dist" />

	</target>

	<target name="test" depends="buildtest" description="Runs all unit tests">
		<java fork="yes" classname="junit.textui.TestRunner" failonerror="true">
			<arg value="tests.net.sf.jabref.AllTests" />
			<classpath refid="classpathTest" />
		</java>
	</target>

	<!--+++++++++++++++++++++++++++++++++++++++++++++++++
	   Auxiliary targets
	  +++++++++++++++++++++++++++++++++++++++++++++++++-->

	<target name="profile" depends="jars" description="Profile JabRef">
		<fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>

		<nbprofiledirect>
			<classpath refid="classpath" />
		</nbprofiledirect>

		<property environment="env" />
		<java fork="true" classname="net.sf.jabref.JabRef" dir="${build.dir}" jvm="${profiler.info.jvm}">
			<jvmarg value="${profiler.info.jvmargs.agent}" />
			<jvmarg line="${profiler.info.jvmargs}" />
			<env key="LD_LIBRARY_PATH" path="${profiler.info.agentpath}:${env.LD_LIBRARY_PATH}" />
			<classpath refid="classpath" />
		</java>
	</target>

	<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        What's about the software design ?!;-)
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

	<target name="jalopy" description="SOFTWAREDESIGN: source code formatter using the JOELib convention.">
		<taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
			<classpath>
				<pathelement path="${classpath}" />
				<fileset dir="${lib.dir}">
					<include name="*.jar" />
				</fileset>
				<fileset dir="${buildlib.dir}">
					<include name="*.jar" />
				</fileset>
			</classpath>
		</taskdef>
		<jalopy fileformat="unix" convention="${src.dir}/java/jalopy.format.convention.xml" history="file" historymethod="adler32" loglevel="error" threads="2" classpathref="classpath" backup="bak">
			<fileset dir="${src.dir}">
				<include name="java/net/sf/jabref/**/*.java" />
			</fileset>
		</jalopy>
	</target>

	<target name="compresssrc">
		<!-- 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) -->
		<mkdir dir="${temp.dir}"/>
		<exec executable="git" searchpath="true" failifexecutionfails="true" outputproperty="devnull" errorproperty="devnull">
			<arg value="clone" />
			<arg value="${basedir}/.." />
			<arg value="${temp.dir}" />
		</exec>

		<!-- ensure correct line endings -->
		<exec executable="git" searchpath="true" failifexecutionfails="true" outputproperty="devnull" errorproperty="devnull" dir="${temp.dir}">
			<arg value="config" />
			<arg value="core.autocrlf" />
			<arg value="${git.core.autocrlf}" />
		</exec>
		<exec executable="git" searchpath="true" failifexecutionfails="true" outputproperty="devnull" errorproperty="devnull" dir="${temp.dir}">
			<arg value="rm" />
			<arg value="--cached" />
			<arg value="-r" />
			<arg value="." />
		</exec>
		<exec executable="git" searchpath="true" failifexecutionfails="true" outputproperty="devnull" errorproperty="devnull" dir="${temp.dir}">
			<arg value="reset" />
			<arg value="--hard" />
		</exec>

		<!-- we want to have jabref-${jabref.version} as main directory -->
		<mkdir dir="${distsrc}" />
		<move file="${temp.dir}/jabref" tofile="${distsrc}/jabref-${jabref.version}" />
	</target>

	<target name="zipsrc">
		<tempfile property="temp.dir" destDir="${java.io.tmpdir}" prefix="jabrefsrc"/>
		<property name="distsrc" value="${temp.dir}/distsrc/" />
		<antcall target="compresssrc">
			<param name="git.core.autocrlf" value="true" />
		</antcall>
		<zip destfile="${build.lib}/JabRef-${jabref.version}-src.zip" basedir="${distsrc}" level="9" />
		<delete dir="${temp.dir}" failonerror="no"/>
	</target>

	<target name="bzip2src">
		<tempfile property="temp.dir" destDir="${java.io.tmpdir}" prefix="jabrefsrc"/>
		<property name="distsrc" value="${temp.dir}/distsrc/" />
		<antcall target="compresssrc">
			<param name="git.core.autocrlf" value="false" />
		</antcall>
		<tar destfile="${build.lib}/JabRef-${jabref.version}-src.tar.bz2" basedir="${distsrc}" excludes=".git/" compression="bzip2" />
		<delete dir="${temp.dir}" failonerror="no"/>
	</target>

	<target name="devsnapshot" depends="clean, addgitinfo, non_osx, win.installer, osxjar" description="creates development snapshot binaries" />

	<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}"/>
	<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}" />
</project>