From: Giovanni Mascellani <gio@debian.org>
Subject: Adjustments to the ant build file
Forwarded: not-needed
Last-Update: 2011-08-07

Adjustements to the ant build.xml files, mainly to use system-provided
JARs and not depend on Internet connection.

---
 build.xml      |   40 +++++++++++++++++++++++-----------------
 i18n/build.xml |   33 ++++++++++++++++-----------------
 2 files changed, 39 insertions(+), 34 deletions(-)

--- a/build.xml
+++ b/build.xml
@@ -14,6 +14,7 @@
     <property name="build.dir" location="build"/>
     <property name="javacc.home" location="tools"/>
     <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/>
+    <property name="antcontrib.jar" value="/usr/share/java/ant-contrib.jar"/>
     <property name="imagerytypes.dir" location="${src.dir}/org/openstreetmap/josm/data/imagery/types"/>
     <!-- build parameter: compression level (ant -Dclevel=N)
              N ranges from 0 (no compression) to 9 (maximum compression)
@@ -25,6 +26,19 @@
     <condition property="isWindows">
         <os family="Windows"/>
     </condition>
+    <!-- Java classpath addition (all jar files to compile tests with this) -->
+    <path id="classpath">
+        <fileset dir="/usr/share/java">
+            <include name="gettext-commons.jar"/>
+            <include name="metadata-extractor.jar"/>
+            <include name="svgSalamander.jar"/>
+            <include name="signpost-core.jar"/>
+            <include name="ant.jar"/>
+            <include name="commons-codec.jar"/>
+            <include name="jmapviewer.jar"/>
+        </fileset>
+    </path>
+    <property name="classpathprop-colon" refid="classpath"/>
 
     <!--
       ** Used by Eclipse ant builder for updating
@@ -71,10 +85,9 @@
     <!--
       ** Creates the REVISION file to be included in the distribution
     -->
-    <target name="create-revision" depends="init-svn-revision-xml, init-git-revision-xml">
+    <target name="create-revision">
         <property name="revision.dir" value="${build.dir}"/>
-        <xmlproperty file="REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
-        <delete file="REVISION.XML"/>
+        <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
         <tstamp>
             <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
         </tstamp>
@@ -87,6 +100,7 @@
 Revision: ${version.entry.commit.revision}
 Is-Local-Build: true
 Build-Date: ${build.tstamp}
+Debian-Release: ${debian.version}
 </echo>
     </target>
     <!--
@@ -106,7 +120,8 @@ Build-Date: ${build.tstamp}
         <copy file="README" todir="build"/>
         <copy file="LICENSE" todir="build"/>
         <!-- create josm-custom.jar -->
-        <delete file="dist/josm-custom.jar"/>
+        <propertyregex property="classpathprop" input="${classpathprop-colon}" global="true"
+          regexp=":" replace=" "/>
         <jar destfile="dist/josm-custom.jar" basedir="build" level="${clevel}">
             <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
             <manifest>
@@ -116,6 +131,8 @@ Build-Date: ${build.tstamp}
                 <attribute name="Permissions" value="all-permissions"/>
                 <attribute name="Codebase" value="josm.openstreetmap.de"/>
                 <attribute name="Application-Name" value="JOSM - Java OpenStreetMap Editor"/>
+                <attribute name="Debian-Release" value="${debian.version}"/>
+                <attribute name="Class-Path" value="${classpathprop}"/>
             </manifest>
             <zipfileset dir="images" prefix="images"/>
             <zipfileset dir="data" prefix="data"/>
@@ -179,10 +196,7 @@ Build-Date: ${build.tstamp}
     </target>
     <target name="javacc" depends="init" unless="javacc.notRequired">
         <mkdir dir="${mapcss.dir}/parsergen"/>
-        <exec append="false" executable="java" failifexecutionfails="true">
-            <arg value="-cp"/>
-            <arg value="${javacc.home}/javacc.jar"/>
-            <arg value="javacc"/>
+        <exec append="false" executable="javacc" failifexecutionfails="true">
             <arg value="-DEBUG_PARSER=false"/>
             <arg value="-DEBUG_TOKEN_MANAGER=false"/>
             <arg value="-JDK_VERSION=1.7"/>
@@ -207,14 +221,10 @@ Build-Date: ${build.tstamp}
         </exec>
     </target>
     <target name="compile" depends="init,javacc,jaxb">
-        <!-- COTS -->
-        <javac srcdir="${src.dir}" includes="com/**,oauth/**,org/apache/commons/codec/**,org/glassfish/**" nowarn="on"
-            destdir="build" target="1.7" source="1.7" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="iso-8859-1">
-            <!-- get rid of "internal proprietary API" warning -->
-            <compilerarg value="-XDignore.symbol.file"/>
-        </javac>
+        <!-- I18N -->
+        <ant dir="i18n" />
         <!-- JMapViewer/JOSM -->
-        <javac srcdir="${src.dir}" excludes="com/**,oauth/**,org/apache/commons/codec/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java" 
+        <javac srcdir="${src.dir}" classpathref="classpath" excludes="com/**,oauth/**,org/apache/commons/codec/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java"
             destdir="build" target="1.7" source="1.7" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
             <compilerarg value="-Xlint:cast"/>
             <compilerarg value="-Xlint:deprecation"/>
@@ -243,6 +253,7 @@ Build-Date: ${build.tstamp}
         </uptodate>
         <mkdir dir="build"/>
         <mkdir dir="dist"/>
+        <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${antcontrib.jar}"/>
     </target>
     <target name="javadoc">
         <javadoc destdir="javadoc" 
@@ -264,6 +275,7 @@ Build-Date: ${build.tstamp}
         <delete dir="dist"/>
         <delete dir="${mapcss.dir}/parsergen"/>
         <delete dir="${imagerytypes.dir}"/>
+        <ant target="clean" dir="i18n"/>
     </target>
     <path id="test.classpath">
         <fileset dir="${test.dir}/lib">
--- a/i18n/build.xml
+++ b/i18n/build.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <project name="JOSM i18n" default="build" basedir=".">
     <!-- compilation properties -->
-    <property name="josm.build.dir" value="../core"/>
+    <property name="josm.build.dir" value=".."/>
     <property name="josm.presets" value="${josm.build.dir}/data/defaultpresets.xml"/>
     <!--<property name="josm.style" value="${josm.build.dir}/styles/standard/elemstyles.xml"/>-->
     <property name="plugin.dir" value="../plugins"/>
@@ -12,8 +12,8 @@
     <property name="i18n.install.dir" value="${josm.build.dir}/data"/>
     <property name="po.build.dir" value="${i18n.build.dir}"/>
     <property name="ant.build.javac.target" value="1.5"/>
-    <property name="gettexttasks.jar" value="lib/gettext-ant-tasks-0.9.7.jar"/>
-    <property name="antcontrib.jar" value="lib/ant-contrib-1.0b3.jar"/>
+    <property name="gettexttasks.jar" value="/usr/share/java/gettext-ant-tasks.jar"/>
+    <property name="antcontrib.jar" value="/usr/share/java/ant-contrib.jar"/>
     <target name="init" description="Loads the Ant gettext and contrib tasks">
         <taskdef name="gettext-extract" classname="org.xnap.commons.ant.gettext.GettextExtractKeysTask" classpath="${gettexttasks.jar}"/>
         <taskdef name="gettext-merge" classname="org.xnap.commons.ant.gettext.GettextMergeKeysTask" classpath="${gettexttasks.jar}"/>
@@ -81,14 +81,14 @@
             <arg line="--unique po/core.pot ${i18n.build.dir}/core.2.pot ${i18n.build.dir}/plugins.raw.pot"/>
         </exec>
     </target>
-    <target name="build" depends="po/josm.pot,init">
-        <gettext-merge keysFile="josm.pot" poDirectory="po"/>
+    <target name="build.check">
+        <condition property="build.run">
+            <not><available file="build-timestamp"/></not>
+        </condition>
+    </target>
+    <target name="build" depends="build.check,init" if="build.run">
         <antcall target="coretrans"/>
-        <foreach param="path" target="plugintrans">
-            <path>
-                <dirset dir="${plugin.dir}" includes="*" excludes="00_*" />
-            </path>
-        </foreach>
+        <touch file="build-timestamp"/>
     </target>
     <target name="singleplugintrans" depends="po/josm.pot,init">
         <antcall target="plugintrans">
@@ -139,15 +139,14 @@
         </if>
         <delete dir="${po.build.dir}/plugin_${dir}"/>
     </target>
+    <target name="dist" depends="build">
+        <copy todir="../build">
+            <fileset dir="build"/>
+        </copy>
+    </target>
     <target name="clean">
         <delete dir="${i18n.build.dir}"/>
-        <delete file="po/josm.pot"/>
-        <delete>
-            <fileset dir="po" includes="*.*~" defaultexcludes="false"/>
-        </delete>
-        <delete>
-            <fileset dir="po" includes="*.po" defaultexcludes="false"/>
-        </delete>
+        <delete file="build-timestamp"/>
     </target>
     <target name="test">
         <mkdir dir="${i18n.build.dir}/test"/>
