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