depend on default-jre (at least Java 6)
[debian/jabref.git] / build.xml
index 412dca6dbcab9047147102166e6a0e6d55d5532a..d13a9f3826800bdcd25120e4b9a942d47019912e 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,57 +1,47 @@
 <?xml version="1.0"?>
 <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-   Filename: $RCSfile$
+   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@FreshMeat:   http://freshmeat.net
-             Jabref-CVSRoot:     :pserver:anonymous@cvs.jabref.sourceforge.net:/cvsroot/jabref
+             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:      must be inserted
+               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.5 or higher
+                 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
-   Version:  $Revision: 2301 $
-             $Date: 2007-08-27 20:51:07 +0200 (Mon, 27 Aug 2007) $
-             $Author: mortenalver $
-
-   modified:
-             23.11.2006 c.oezbek
-             - tried to fix classpath issues
-             28.07.2005 r.nagel
-             - insert dynamic build info generation (resource/build.properties)
-             - copy fonts directory, used by the new about dialog
-             - change static "version" into mainfest file into ${jabref.version}
-             09.06.2005 r.nagel
-             - bugfix, first it should be made a rebuild of the build directory
-             and then a jar should be generated from this directory
-             - take all files for the jar archive !!! FROM BUILD directory !!!
+
+   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.3b2" />
+       <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.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="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="lib" />
+       <property name="buildlib.dir" value="buildlib" />
+       <property name="tests.dir" value="${src.dir}/tests" />
 
-       <!-- Set the properties for library directories -->
-       <property name="library.directory" value="lib" />
-
-<!--    <property name="nsis.executable" value="makensis.exe"/> -->
+       <property name="osxbin.dir" value="osx" />
 
-       <!-- Load user dependent properties -->
-       <!-- For instance to redefine the NSIS-compiler write 
-               nsis.executable="d:\prog\dev\NSIS\makensis.exe"
+       <!-- 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>
-                       <os family="windows" />
-                       <isset property="nsis.executable" />
-               </and>
+         <and>
+           <isset property="nsis.executable" />
+           <os family="windows" />
+         </and>
        </condition>
 
-       <taskdef name="jarbundler" classpath="${library.directory}/jarbundler-1.4.jar" classname="com.loomcom.ant.tasks.jarbundler.JarBundler" />
-
+       <fileset id="jarsFileset" dir="${lib.dir}">
+               <include name="antlr.jar" />
+               <include name="antlr-3.4-complete.jar" />
+        <include name="jgoodies-common-1.4.0.jar" />
+               <include name="jgoodies-looks-2.5.2.jar" />
+               <include name="jgoodies-forms-1.6.0.jar" />
+               <include name="jayatana-1.2.4.jar" />
+               <include name="spin.jar" />
+               <include name="glazedlists-1.8.0_java15.jar" />
+               <include name="microba.jar" />
+               <include name="pdfbox-1.7.1.jar" />
+               <include name="jempbox-1.7.1.jar" />
+               <include name="fontbox-1.7.1.jar" />
+               <include name="zoom-java.jar" />
+       <include name="mysql-connector-java-5.0.7-bin.jar" />
+               <include name="postgresql-9.2-1002.jdbc4.jar" />
+        <!-- Plugin runtime dependencies -->
+               <include name="plugin/JPFCodeGenerator-rt.jar" />
+               <include name="plugin/jpf.jar" />
+               <include name="plugin/jpf-boot.jar" />
+               <include name="plugin/commons-logging.jar" />
+       </fileset>
+
+    <!-- Openoffice connection dependencies. Compile-time only -->
+    <fileset id="ooFileset" dir="${lib.dir}">
+        <include name="oo/unoil.jar" />
+        <include name="oo/ridl.jar" />
+        <include name="oo/juh.jar" />
+        <include name="oo/jurt.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}" />
-               <pathelement location="${library.directory}/antlr.jar" />
-               <pathelement location="${library.directory}/antlr-3.0b5.jar" />
-               <pathelement location="${library.directory}/looks-2.0.4.jar" />
-               <pathelement location="${library.directory}/forms-1.0.4.jar" />
-               <pathelement location="${library.directory}/spin.jar" />
-               <pathelement location="${library.directory}/glazedlists-1.7.0_java15.jar" />
-               <pathelement location="${library.directory}/microba.jar" />
-               <pathelement location="${library.directory}/PDFBox-0.7.3-dev-reduced.jar" />
-               <pathelement location="${library.directory}/JempBox-0.1.0-dev.jar" />
+        <!-- Done by MrDlib -->
+        <pathelement path="${lib.dir}/spl" />
+        <fileset refid="splJars" />
+        <!-- Done by MrDlib -->
+               <fileset refid="jarsFileset" />
+        <fileset refid="ooFileset" />
+       </path>
+
+       <!-- Classpath for running the code generator -->
+       <path id="codegenerator">
+               <pathelement location="${lib.dir}/plugin/JPFCodeGenerator.jar" />
+               <pathelement location="${lib.dir}/plugin/jpf.jar" />
+               <pathelement location="${lib.dir}/plugin/jpf-boot.jar" />
+               <pathelement location="${lib.dir}/plugin/velocity-dep-1.5.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.JabRef" fork="true">
+               <java classname="net.sf.jabref.JabRefMain" fork="true">
                        <classpath refid="classpath" />
                </java>
        </target>
 
        <!-- Runs project -->
-       <target name="runFromJar" depends="jars">
-               <java classname="net.sf.jabref.JabRef" fork="true">
+       <target name="runFromJar">
+               <java dir="${build.lib}" classname="net.sf.jabref.JabRefMain" fork="true">
                        <classpath>
                                <pathelement location="${build.lib}/${build.jar}" />
                        </classpath>
                </java>
        </target>
 
-       <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" />
+       <!-- 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 -->
-       <target name="compile">
+       <!-- Compiles project excluding tests -->
+       <target name="compile" depends="generate">
                <mkdir dir="${build.classes}" />
-               <javac debug="on" deprecation="on" destdir="${build.classes}" source="1.5" target="1.5">
+               <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 only the tests -->
+       <!-- Compiles project including tests -->
        <target name="compiletest">
                <mkdir dir="${build.classes}" />
-               <!--deprecation="on"-->
-               <javac srcdir="${java.dir}/tests" debug="off" destdir="${build.classes}" source="1.5" target="1.5">
-                       <classpath refid="classpath" />
+               <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>
 
        <target name="osx">
                <mkdir dir="${build.classes}" />
 
-               <javac srcdir="${osx.dir}" debug="on" destdir="${build.classes}" target="1.5">
+               <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="${library.directory}/OSXAdapter.class" todir="${build.osx}" />
+               <copy file="${osxbin.dir}/OSXAdapter.class" todir="${build.osx}" />
        </target>
 
        <!-- Jars up project -->
        <target name="jars" depends="build, unjarlib">
                <mkdir dir="${build.lib}" />
+
                <mkdir dir="${build.tmp}" />
-               <jar destfile="${build.lib}/${build.jar}">
+               <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="help/de/**" />
-                               <include name="help/no/**" />
                                <include name="resource/**" />
                        </fileset>
-                       <fileset dir="${library.directory}">
+
+                       <!-- 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="gpl.txt" />
+                               <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.JabRef" />
+                               <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">
 
                        </fileset>
                </copy>
 
-               <!-- the fonts are used by the new about dialog
-               <mkdir dir="${build.fonts}" />
-               <copy todir="${build.fonts}">
-                       <fileset dir="${fonts.dir}">
-                               <include name="*" />
-                       </fileset>
-               </copy> -->
-
                <mkdir dir="${build.help}" />
                <copy todir="${build.help}">
-                       <fileset dir="${help.dir}">
-                               <!--<include name="*" />-->
-                       </fileset>
+                       <fileset dir="${help.dir}" />
                </copy>
 
                <!-- Insert version informations -->
-               <replace dir="${build.help}" token="${jabref.placeholder.version}" value="${jabref.version}">
+               <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}">
 
        </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
@@ -283,7 +383,7 @@ version=${jabref.version}</echo>
        <!-- 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://java.sun.com/j2se/1.4.1/docs/api/">
+               <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" />
@@ -303,9 +403,9 @@ version=${jabref.version}</echo>
                        </fileset>
                </copy>
 
-               <javadoc sourcepath="${java.dir}" destdir="${build.extension-javadocs}" author="true" version="true" windowtitle="JabRef-Extensions API" link="http://java.sun.com/j2se/1.4.1/docs/api/" Overview="${extensions.dir}/API/overview.html" access="protected">
-                       <!-- 
-                 create javadoc only selectively for classes that 
+               <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">
@@ -356,30 +456,53 @@ version=${jabref.version}</echo>
        <!-- Unpacks jar needed jar files from lib directory into temp directory. -->
        <target name="unjarlib" description="Unpacks jars from library">
                <mkdir dir="${build.tmp}" />
-               <unjar src="${library.directory}/antlr.jar" dest="${build.tmp}" />
-               <unjar src="${library.directory}/antlr-3.0b5.jar" dest="${build.tmp}" />
-               <unjar src="${library.directory}/looks-2.0.4.jar" dest="${build.tmp}" />
-               <unjar src="${library.directory}/forms-1.0.4.jar" dest="${build.tmp}" />
-               <unjar src="${library.directory}/spin.jar" dest="${build.tmp}" />
-               <unjar src="${library.directory}/glazedlists-1.7.0_java15.jar" dest="${build.tmp}" />
-               <unjar src="${library.directory}/microba.jar" dest="${build.tmp}" />
-               <unjar src="${library.directory}/PDFBox-0.7.3-dev-reduced.jar" dest="${build.tmp}" />
-               <unjar src="${library.directory}/JempBox-0.1.0-dev.jar" dest="${build.tmp}" />
-               <delete dir="${build.tmp}/META-INF" />
+               <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">
-               <jarbundler dir="${build.lib}" name="JabRef" mainclass="net.sf.jabref.JabRef" jars="${build.lib}/${build.jar}" icon="${images.dir}/JabRef-Logo.icns" version="${jabref.version}" jvmversion="1.4+" stubfile="${library.directory}/JavaApplicationStub" />
+       <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 property                               -->
+       <!-- Don't forget to set nsis.executable and launch4j.dir properties            -->
        <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
 
        <target name="win.installer.clean" description="Delete Installer and Exe-Wrapper + Temp-files">
@@ -387,128 +510,130 @@ version=${jabref.version}</echo>
                <delete file="${win.installer.dir}/JabRefSetup.exe" />
        </target>
 
-       <target name="win.installer" description="Copy files in place to be used by the installer" depends="jars">
+       <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>
 
-               <fail unless="is.windows" message="Not running on windows or NSIS not found. Please make sure that user.properties exists"/>
-               
+       <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" />
+               <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}" />
 
-               <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="gpl.txt" />
+                               <include name="gpl2.txt" />
+                               <include name="gpl3.txt" />
                                <include name="lesser.txt" />
                                <include name="README" />
                        </fileset>
                </copy>
 
                <!-- "Create Exe-Wrapper" -->
-               <exec dir="." executable="${nsis.executable}" failonerror="true">
-                       <arg line="'/DJARFILE=${build.jar}' '/DVERSION=${jabref.version}' '/DAPPICON=../../../${images.dir}/JabRef.ico' ${win.installer.dir}/launcher.nsi" />
+
+               <!-- 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>
 
-       <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-        What's about the software design ?!;-)
-    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
+       <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="pmd" description="SOFTWAREDESIGN: Project Mess Detector !;-)">
-               <echo>Checking Project Mess Detection (PMD) rulesets.</echo>
-               <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
-                       <classpath>
-                               <pathelement path="${classpath}" />
-                               <fileset dir="${library.directory}">
-                                       <include name="*.jar" />
-                               </fileset>
-                       </classpath>
-               </taskdef>
-               <!-- allowed Pretty Much Done rulsets -->
-               <!-- rulesets/basic.xml -->
-               <!-- rulesets/braces.xml -->
-               <!-- rulesets/codesize.xml-->
-               <!-- rulesets/controversial.xml-->
-               <!-- rulesets/coupling.xml-->
-               <!-- rulesets/design.xml -->
-               <!-- rulesets/experimental.xml -->
-               <!-- rulesets/favorites.xml -->
-               <!-- rulesets/imports.xml -->
-               <!-- rulesets/naming.xml -->
-               <!-- rulesets/javabean.xml -->
-               <!-- rulesets/junit.xml -->
-               <!-- rulesets/scratchpad.xml -->
-               <!-- rulesets/strictexception.xml -->
-               <!-- rulesets/strings.xml -->
-               <!-- rulesets/unusedcode.xml -->
-
-               <pmd rulesetfiles="rulesets/unusedcode.xml,rulesets/basic.xml" failonerror="no">
-                       <formatter type="html" toFile="${build.dir}/pmd_report.html" />
-                       <fileset dir="${src.dir}">
-                               <include name="**/*.java" />
-                       </fileset>
-               </pmd>
+       <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" />
 
-               <!-- check for duplicated code -->
-               <echo>WARNING: use environment variable: ANT_OPTS=-Xmx512m or this task will fail.</echo>
-               <echo>Checking for duplicated code using the Copy/Paste Detector (CPD).</echo>
-               <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask">
-                       <classpath>
-                               <pathelement path="${classpath}" />
-                               <fileset dir="${library.directory}">
-                                       <include name="*.jar" />
-                               </fileset>
-                       </classpath>
-               </taskdef>
-               <cpd format="text" minimumTokenCount="100" outputFile="${build.dir}/duplicated_code_report.txt">
-                       <fileset dir="${src.dir}">
-                               <include name="**/*.java" />
-                       </fileset>
-               </cpd>
        </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>
 
-       <target name="javancss" description="SOFTWAREDESIGN: Determining the NCSS and CCN code metrics for JOELib.">
-               <taskdef name="javancss" classname="javancss.JavancssAntTask">
-                       <classpath>
-                               <pathelement path="${classpath}" />
-                               <fileset dir="${library.directory}">
-                                       <include name="*.jar" />
-                               </fileset>
-                       </classpath>
-               </taskdef>
-               <echo>Cyclomatic
-Complexity             Ease of       Risk
-Number (CCN)           maintenance
-(McCabe metric)
----------------------------------------------
-1-10, simple           easy          minimum
-11-20, complex         moderate      moderate
-21-50, more complex    hard          high
->50, unstable          very hard     very high
+       <!--+++++++++++++++++++++++++++++++++++++++++++++++++
+          Auxiliary targets
+         +++++++++++++++++++++++++++++++++++++++++++++++++-->
+
+       <target name="profile" depends="jars" description="Profile JabRef">
+               <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
 
-</echo>
-               <javancss srcdir="${src.dir}" includes="**/*.java" excludes="jama/**/*.java, jmat/**/*.java, cformat/**/*.java" abortOnFail="false" ccnPerFuncMax="30" generateReport="true" outputfile="${build.dir}/javancss_report.plain" format="plain" packageMetrics="true" classMetrics="false" functionMetrics="false" />
+               <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="${library.directory}">
+                               <fileset dir="${lib.dir}">
+                                       <include name="*.jar" />
+                               </fileset>
+                               <fileset dir="${buildlib.dir}">
                                        <include name="*.jar" />
                                </fileset>
                        </classpath>
@@ -520,16 +645,61 @@ Number (CCN)           maintenance
                </jalopy>
        </target>
 
-       <target name="test">
-               <junit printsummary="yes" fork="yes" haltonfailure="no">
-                       <batchtest fork="yes" todir="/tmp/testres">
-                               <fileset dir="${build.classes}">
-                                       <include name="**/*Tester.class" />
-                                       <include name="**/*Test.class" />
-                               </fileset>
-                       </batchtest>
-                       <classpath refid="classpath" />
-               </junit>
+       <taskdef name="jarbundler" classpath="${buildlib.dir}/jarbundler-2.2.0.jar" classname="net.sourceforge.jarbundler.JarBundler" />
+
+       <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>