New upstream release.
[debian/jabref.git] / build.xml
index 5b36cd7..fc3641d 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-   Filename: $RCSfile: build.xml,v $
+   Filename: $RCSfile$
    Purpose:  Ant build file for Jabref.
 
              Ant-Download: http://jakarta.apache.org/ant
@@ -22,8 +22,8 @@
    Compiler: Ant
    Authors:  Joerg K. Wegner, wegnerj@informatik.uni-tuebingen.de
              Morten O. Alver
-   Version:  $Revision: 1.82.2.1 $
-             $Date: 2007/06/20 18:51:59 $
+   Version:  $Revision: 2784 $
+             $Date: 2008-10-07 20:06:21 +0200 (Tue, 07 Oct 2008) $
              $Author: mortenalver $
 
    modified:
 
 <project name="JabRef" default="jars" basedir=".">
 
-       <!-- ==========================================================================================
+       <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         PROPERTY SETUP
-     ========================================================================================== -->
+     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
 
        <!-- some version information -->
-       <property name="jabref.version" value="2.3b" />
+       <property name="jabref.version" value="2.4.2" />
        <property name="jabref.placeholder.version" value="@version@" />
        <!-- 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="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="nsis.executable" value="makensis.exe"/>
+       <property name="nsis.executable.linux" value="makensis"/>
 
        <!-- Load user dependent properties -->
        <!-- For instance to redefine the NSIS-compiler write 
 
        <!-- 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.0b5.jar" />
+               <include name="looks-2.2.0.jar" />
+               <include name="forms-1.1.0.jar" />
+               <include name="spin.jar" />
+               <include name="glazedlists-1.7.0_java15.jar" />
+               <include name="microba.jar" />
+               <include name="PDFBox-0.7.3-dev-reduced.jar" />
+               <include name="JempBox-0.2.0.jar" />
+               <include name="zoom-java.jar" />
+       <include name="mysql-connector-java-5.0.7-bin.jar" />
+        <!--<include name="substance-4.1.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>
 
        <!-- 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" />
+               <fileset refid="jarsFileset" />
+       </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="${lib.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">
                        <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.4" target="1.4">
+                       <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}" source="1.5" target="1.5">
+                       <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.5">
                </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="${lib.dir}/OSXAdapter.class" todir="${build.osx}" />
        </target>
 
        <!-- Jars up project -->
                                <include name="help/no/**" />
                                <include name="resource/**" />
                        </fileset>
-                       <fileset dir="${library.directory}">
+
+                       <!-- Add Plugins -->
+                       <fileset dir="${src.dir}">
+                               <include name="plugins/**" />
+                       </fileset>
+
+                       <fileset dir="${lib.dir}">
                                <include name="EndNote.zip" />
                        </fileset>
                        <fileset dir="${txt.dir}">
                                <include name="README" />
                        </fileset>
                        <manifest>
-                               <attribute name="Main-Class" value="net.sf.jabref.JabRef" />
+                               <attribute name="Main-Class" value="net.sf.jabref.JabRefMain" />
                        </manifest>
                </jar>
 
                        </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 -->
 
        </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
@@ -356,15 +393,9 @@ 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}" />
+               <unjar dest="${build.tmp}">
+                       <fileset refid="jarsFileset" />
+               </unjar>
                <delete dir="${build.tmp}/META-INF" />
                <!-- rename the microba license file -->
                <move file="${build.tmp}/license.txt" tofile="${build.tmp}/microba-license.txt" />
@@ -372,7 +403,7 @@ version=${jabref.version}</echo>
 
 
        <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" />
+               <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="${lib.dir}/JavaApplicationStub" />
        </target>
 
 
@@ -389,18 +420,17 @@ version=${jabref.version}</echo>
 
        <target name="win.installer" description="Copy files in place to be used by the installer" depends="jars">
 
-               <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" />
+
                <!-- 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" />
@@ -411,16 +441,77 @@ version=${jabref.version}</echo>
 
                <!-- "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" />
+                 <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" />
+
+       </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="gpl.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" />
+               </exec>
+
+               <!-- Finally create Windows-Installer -->
+               <exec dir="." executable="${nsis.executable.linux}" failonerror="true">
+                       <arg line="'-DVERSION=${jabref.version}' ${win.installer.dir}/setup.nsi" />
+               </exec>
+
                <delete dir="${win.installer.dir}/dist" />
-               
+
+       </target>
+
+       <target name="test" depends="buildtest" description="Runs all unit tests">
+               <java fork="yes" classname="junit.textui.TestRunner" failonerror="true">
+                       <arg value="tests.net.sf.jabref.AllTests" />
+                       <classpath refid="classpathTest" />
+               </java>
+       </target>
+
+
+       <!--+++++++++++++++++++++++++++++++++++++++++++++++++
+          Auxiliary targets
+         +++++++++++++++++++++++++++++++++++++++++++++++++-->
+
+       <target name="profile" depends="jars" description="Profile JabRef">
+               <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
+
+               <nbprofiledirect>
+                       <classpath refid="classpath" />
+               </nbprofiledirect>
+
+               <property environment="env" />
+               <java fork="true" classname="net.sf.jabref.JabRef" dir="${build.dir}" jvm="${profiler.info.jvm}">
+                       <jvmarg value="${profiler.info.jvmargs.agent}" />
+                       <jvmarg line="${profiler.info.jvmargs}" />
+                       <env key="LD_LIBRARY_PATH" path="${profiler.info.agentpath}:${env.LD_LIBRARY_PATH}" />
+                       <classpath refid="classpath" />
+               </java>
        </target>
 
        <!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -432,7 +523,7 @@ version=${jabref.version}</echo>
                <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
                        <classpath>
                                <pathelement path="${classpath}" />
-                               <fileset dir="${library.directory}">
+                               <fileset dir="${lib.dir}">
                                        <include name="*.jar" />
                                </fileset>
                        </classpath>
@@ -468,7 +559,7 @@ version=${jabref.version}</echo>
                <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask">
                        <classpath>
                                <pathelement path="${classpath}" />
-                               <fileset dir="${library.directory}">
+                               <fileset dir="${lib.dir}">
                                        <include name="*.jar" />
                                </fileset>
                        </classpath>
@@ -485,7 +576,7 @@ version=${jabref.version}</echo>
                <taskdef name="javancss" classname="javancss.JavancssAntTask">
                        <classpath>
                                <pathelement path="${classpath}" />
-                               <fileset dir="${library.directory}">
+                               <fileset dir="${lib.dir}">
                                        <include name="*.jar" />
                                </fileset>
                        </classpath>
@@ -508,7 +599,7 @@ Number (CCN)           maintenance
                <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>
                        </classpath>
@@ -520,16 +611,6 @@ 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>
-       </target>
+       <taskdef name="jarbundler" classpath="${lib.dir}/jarbundler-1.4.jar" classname="com.loomcom.ant.tasks.jarbundler.JarBundler" />
 
 </project>