prepare for upload
[debian/jabref.git] / build.xml
index 787f7221b5987f80a3221d35cb0825721ec5714d..d13a9f3826800bdcd25120e4b9a942d47019912e 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -35,8 +35,9 @@
      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
 
        <!-- some version information -->
      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
 
        <!-- some version information -->
-       <property name="jabref.version" value="2.9b2" />
-       <property name="jabref.year" value="2012" />
+       <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 -->
        <property name="jabref.placeholder.version" value="@version@" />
        <property name="jabref.placeholder.year" value="@year@" />
        <!-- used by replace task -->
 
        <property name="osxbin.dir" value="osx" />
 
 
        <property name="osxbin.dir" value="osx" />
 
-       <property name="nsis.executable" value="C:\Program files\NSIS\makensis.exe"/>
-       <property name="nsis.executable.linux" value="makensis"/>
-
-       <!-- 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 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>
        <!-- win.installer can only be build under Windows if the nsis.executable is found -->
        <condition property="is.windows">
          <and>
         <include name="spl/*.jar" />
     </fileset>
        <fileset id="deletableMeta-InfFiles" dir="${build.tmp}/META-INF">
         <include name="spl/*.jar" />
     </fileset>
        <fileset id="deletableMeta-InfFiles" dir="${build.tmp}/META-INF">
-               <exclude name="services/**/*" />                
+               <exclude name="services/**/*" />
        </fileset>
     <!-- Done by MrDlib -->
 
        </fileset>
     <!-- Done by MrDlib -->
 
        <!-- Compiles project excluding tests -->
        <target name="compile" depends="generate">
                <mkdir dir="${build.classes}" />
        <!-- 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">
+               <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>
                        <src path="${java.dir}" />
                        <exclude name="tests/**" />
                        <exclude name="**/JabRefMain.java" />
                        <classpath refid="classpath" />
                </javac>
-               <javac debug="off" deprecation="on" destdir="${build.classes}" source="1.6" target="1.6">
+               <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>
                        <src path="${java.dir}" />
                        <include name="**/JabRefMain.java" />
                </javac>
        <!-- Compiles project including tests -->
        <target name="compiletest">
                <mkdir dir="${build.classes}" />
        <!-- Compiles project including tests -->
        <target name="compiletest">
                <mkdir dir="${build.classes}" />
-               <javac debug="on" destdir="${build.classes}" source="1.6" target="1.6">
+               <javac debug="on" destdir="${build.classes}" encoding="UTF8" source="1.6" target="1.6">
                        <src path="${java.dir}" />
                        <include name="tests/**" />
                        <classpath refid="classpathTest" />
                        <src path="${java.dir}" />
                        <include name="tests/**" />
                        <classpath refid="classpathTest" />
        <!-- Jars up project -->
        <target name="jars" depends="build, unjarlib">
                <mkdir dir="${build.lib}" />
        <!-- Jars up project -->
        <target name="jars" depends="build, unjarlib">
                <mkdir dir="${build.lib}" />
-        
+
                <mkdir dir="${build.tmp}" />
                <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}" />
         <!--<jar destfile="${build.lib}/JabRef-${revision}.jar" manifest="${src.dir}/MANIFEST.MF">-->
 
                        <fileset dir="${build.classes}" />
 
        </target>
 
 
        </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">
 
        <!-- copy all necessary files and insert version informations -->
        <target name="build" depends="compile, buildinfos" description="Build project">
 
                <!-- Insert version informations -->
                <replace dir="${build.help}">
                    <replacefilter
                <!-- Insert version informations -->
                <replace dir="${build.help}">
                    <replacefilter
-                           token="${jabref.placeholder.version}" 
+                           token="${jabref.placeholder.version}"
                                value="${jabref.version}" />
                    <replacefilter
                                value="${jabref.version}" />
                    <replacefilter
-                           token="${jabref.placeholder.year}" 
+                           token="${jabref.placeholder.year}"
                                value="${jabref.year}" />
                        <include name="**/About.html" />
                </replace>
                                value="${jabref.year}" />
                        <include name="**/About.html" />
                </replace>
@@ -375,8 +404,8 @@ version=${jabref.version}</echo>
                </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">
                </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 
+                       <!--
+                 create javadoc only selectively for classes that
                  users extending JabRef are likely to use
               -->
                        <fileset dir="${java.dir}" defaultexcludes="yes">
                  users extending JabRef are likely to use
               -->
                        <fileset dir="${java.dir}" defaultexcludes="yes">
@@ -441,14 +470,15 @@ version=${jabref.version}</echo>
        </target>
 
 
        </target>
 
 
-       <target name="osxjar">
+       <target name="osxjar" depends="jars">
                <jarbundler dir="${build.lib}"
                     name="JabRef"
                     mainclass="net.sf.jabref.JabRef"
                <jarbundler dir="${build.lib}"
                     name="JabRef"
                     mainclass="net.sf.jabref.JabRef"
-                    jars="${build.lib}/${build.jar}"
+                    jar="${build.lib}/${build.jar}"
                     icon="${images.dir}/JabRef-Logo.icns"
                     version="${jabref.version}"
                     icon="${images.dir}/JabRef-Logo.icns"
                     version="${jabref.version}"
-                    jvmversion="1.5+"
+                    jvmversion="1.6+"
+                   vmoptions="-Xms128m -Xmx512m"
                     stubfile="${osxbin.dir}/JavaApplicationStub"
                     signature="JABr">
             <documenttype name="BibTeX file" extensions="bib" role="Editor"
                     stubfile="${osxbin.dir}/JavaApplicationStub"
                     signature="JABr">
             <documenttype name="BibTeX file" extensions="bib" role="Editor"
@@ -459,13 +489,20 @@ version=${jabref.version}</echo>
             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;"/>
             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                                                    -->
        <!--                                                                            -->
        </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">
        <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
 
        <target name="win.installer.clean" description="Delete Installer and Exe-Wrapper + Temp-files">
@@ -473,10 +510,11 @@ version=${jabref.version}</echo>
                <delete file="${win.installer.dir}/JabRefSetup.exe" />
        </target>
 
                <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" />
                <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" />
 
                <!-- Gather everything that will go into the installer in dist -->
                <mkdir dir="${win.installer.dir}/dist" />
 
@@ -496,49 +534,63 @@ version=${jabref.version}</echo>
                </copy>
 
                <!-- "Create Exe-Wrapper" -->
                </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" />
-               </exec>
 
 
-               <!-- Finally create Windows-Installer -->
-               <exec dir="." executable="${nsis.executable}" failonerror="true">
-                       <arg line="'/DVERSION=${jabref.version}' ${win.installer.dir}/setup.nsi" />
-               </exec>
-
-               <delete dir="${win.installer.dir}/dist" />
+               <!-- 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>
 
-       <target name="win.installer.linux" description="Copy files in place to be used by the installer" depends="jars">
-
-               <!-- 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" -->
-               <exec dir="." executable="${nsis.executable.linux}" failonerror="true">
-                 <arg line="'-DJARFILE=${build.jar}' '-DVERSION=${jabref.version}' '-DAPPICON=../../../${images.dir}/JabRef.ico' ${win.installer.dir}/launcher.nsi" />
+       <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>
                </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>
                <delete dir="${win.installer.dir}/dist" />
 
        </target>
@@ -550,8 +602,6 @@ version=${jabref.version}</echo>
                </java>
        </target>
 
                </java>
        </target>
 
-
-
        <!--+++++++++++++++++++++++++++++++++++++++++++++++++
           Auxiliary targets
          +++++++++++++++++++++++++++++++++++++++++++++++++-->
        <!--+++++++++++++++++++++++++++++++++++++++++++++++++
           Auxiliary targets
          +++++++++++++++++++++++++++++++++++++++++++++++++-->
@@ -597,4 +647,59 @@ version=${jabref.version}</echo>
 
        <taskdef name="jarbundler" classpath="${buildlib.dir}/jarbundler-2.2.0.jar" classname="net.sourceforge.jarbundler.JarBundler" />
 
 
        <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>
 </project>