Description: Adjustments to the ant build.xml file.
 Mainly to use system-provided JARs and not depend on Internet connection.
 Also adds support to build the translations in the i18n directory.
 The Debian package build is identified using the Build-Name in the REVISION
 file and is not considered local build.
Author: Giovanni Mascellani <gio@debian.org>
Author: Bas Couwenberg <sebastic@debian.org>
Forwarded: not-needed

--- a/build.xml
+++ b/build.xml
@@ -24,7 +24,8 @@
         <property name="mapcss.dir" location="${src.dir}/org/openstreetmap/josm/gui/mappaint/mapcss"/>
         <property name="proj-build.dir" location="${base.dir}/build2"/>
         <property name="epsg.output" location="${base.dir}/data/projection/custom-epsg"/>
-        <property name="groovy.jar" location="${base.dir}/tools/groovy-all-2.4.7.jar"/>
+        <property name="groovy.jar" location="/usr/share/java/groovy-all.jar"/>
+        <property name="antcontrib.jar" value="/usr/share/java/ant-contrib.jar"/>
         <property name="error_prone_ant.jar" location="${base.dir}/tools/error_prone_ant-2.0.14.jar"/>
         <property name="javac.compiler" value="com.google.errorprone.ErrorProneAntCompilerAdapter" />
         <!-- build parameter: compression level (ant -Dclevel=N)
@@ -37,6 +38,19 @@
         <condition property="isJava9">
             <equals arg1="${ant.java.version}" arg2="1.9" />
         </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="svgSalamander.jar"/>
+                <include name="signpost-core.jar"/>
+                <include name="commons-codec.jar"/>
+                <include name="commons-compress.jar"/>
+                <include name="commons-logging.jar"/>
+                <include name="jmapviewer.jar"/>
+            </fileset>
+        </path>
+        <property name="classpathprop-colon" refid="classpath"/>
         <path id="test.classpath">
             <fileset dir="${test.dir}/lib">
                 <include name="**/*.jar"/>
@@ -92,10 +106,9 @@
     <!--
       ** Creates the REVISION file to be included in the distribution
     -->
-    <target name="create-revision" depends="init-properties,init-svn-revision-xml,init-git-revision-xml">
+    <target name="create-revision">
         <property name="revision.dir" value="${build.dir}"/>
-        <xmlproperty file="${base.dir}/REVISION.XML" prefix="version" keepRoot="false" collapseAttributes="true"/>
-        <delete file="${base.dir}/REVISION.XML"/>
+        <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
         <tstamp>
             <format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
         </tstamp>
@@ -106,8 +119,10 @@
         <echo file="${revision.dir}/REVISION">
 # automatically generated by JOSM build.xml - do not edit
 Revision: ${version.entry.commit.revision}
-Is-Local-Build: true
+Is-Local-Build: false
 Build-Date: ${build.tstamp}
+Build-Name: Debian
+Debian-Release: ${debian.version}
 </echo>
     </target>
     <!--
@@ -127,7 +142,7 @@ Build-Date: ${build.tstamp}
         <copy file="README" todir="build"/>
         <copy file="LICENSE" todir="build"/>
         <!-- create josm-custom.jar -->
-        <delete file="${dist.dir}/josm-custom.jar"/>
+        <propertyregex property="classpathprop" input="${classpathprop-colon}" global="true" regexp=":" replace=" "/>
         <jar destfile="${dist.dir}/josm-custom.jar" basedir="${build.dir}" level="${clevel}">
             <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
             <manifest>
@@ -137,6 +152,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"/>
@@ -207,10 +224,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.8"/>
@@ -221,22 +235,10 @@ Build-Date: ${build.tstamp}
     </target>
     <target name="compile" depends="init,javacc">
         <!-- COTS -->
-        <javac srcdir="${src.dir}" includes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**" nowarn="on" encoding="iso-8859-1"
+        <javac srcdir="${src.dir}" classpathref="classpath" includes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**" nowarn="on" encoding="iso-8859-1"
             destdir="build" target="1.8" source="1.8" debug="on" includeAntRuntime="false" createMissingPackageInfoClass="false">
             <!-- get rid of "internal proprietary API" warning -->
             <compilerarg value="-XDignore.symbol.file"/>
-            <exclude name="org/apache/commons/compress/compressors/bzip2/BZip2Utils.java"/>
-            <exclude name="org/apache/commons/compress/compressors/lzma/**"/>
-            <exclude name="org/apache/commons/compress/compressors/xz/**"/>
-            <exclude name="org/apache/commons/compress/compressors/CompressorStreamFactory.java"/>
-            <exclude name="org/apache/commons/compress/compressors/CompressorStreamProvider.java"/>
-            <exclude name="org/apache/commons/compress/compressors/CompressorException.java"/>
-            <exclude name="org/apache/commons/compress/compressors/FileNameUtil.java"/>
-            <exclude name="org/apache/commons/compress/compressors/deflate/**"/>
-            <exclude name="org/apache/commons/compress/compressors/gzip/**"/>
-            <exclude name="org/apache/commons/compress/compressors/lzw/**"/>
-            <exclude name="org/apache/commons/compress/compressors/pack200/**"/>
-            <exclude name="org/apache/commons/compress/compressors/snappy/**"/>
             <exclude name="org/apache/commons/compress/compressors/z/**"/>
             <exclude name="org/apache/commons/jcs/JCS.java"/>
             <exclude name="org/apache/commons/jcs/access/GroupCacheAccess.java"/>
@@ -258,19 +260,13 @@ Build-Date: ${build.tstamp}
             <exclude name="org/apache/commons/jcs/utils/net/**"/>
             <exclude name="org/apache/commons/jcs/utils/props/**"/>
             <exclude name="org/apache/commons/jcs/utils/servlet/**"/>
-            <exclude name="org/apache/commons/logging/impl/AvalonLogger.java"/>
-            <exclude name="org/apache/commons/logging/impl/Jdk13LumberjackLogger.java"/>
-            <exclude name="org/apache/commons/logging/impl/Log4JLogger.java"/>
-            <exclude name="org/apache/commons/logging/impl/LogKitLogger.java"/>
-            <exclude name="org/apache/commons/logging/impl/ServletContextCleaner.java"/>
         </javac>
+        <!-- I18N -->
+        <ant dir="i18n" />
         <!-- JMapViewer -->
-        <javac compiler="${javac.compiler}" sourcepath="" srcdir="${src.dir}" 
+        <javac sourcepath="" srcdir="${src.dir}" classpathref="classpath" 
             excludes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java,org/openstreetmap/gui/jmapviewer/JMapViewerTree.java,org/openstreetmap/gui/jmapviewer/checkBoxTree/**,org/openstreetmap/josm/**,JOSM.java,gnu/**"
             destdir="build" target="1.8" source="1.8" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
-            <compilerclasspath>
-                <pathelement location="${error_prone_ant.jar}"/>
-            </compilerclasspath>
             <compilerarg value="-Xlint:cast"/>
             <compilerarg value="-Xlint:deprecation"/>
             <compilerarg value="-Xlint:dep-ann"/>
@@ -284,16 +280,12 @@ Build-Date: ${build.tstamp}
             <compilerarg value="-Xlint:unchecked"/>
             <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
             <compilerarg value="-XDignore.symbol.file"/>
-            <compilerarg value="-Xep:ReferenceEquality:OFF" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"/>
             <compilerarg line="-Xmaxwarns 1000"/>
         </javac>
         <!-- JOSM -->
-        <javac compiler="${javac.compiler}" sourcepath="" srcdir="${src.dir}" 
+        <javac sourcepath="" srcdir="${src.dir}" classpathref="classpath" 
             excludes="com/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/**"
             destdir="build" target="1.8" source="1.8" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
-            <compilerclasspath>
-                <pathelement location="${error_prone_ant.jar}"/>
-            </compilerclasspath>
             <compilerarg value="-Xlint:cast"/>
             <compilerarg value="-Xlint:deprecation"/>
             <compilerarg value="-Xlint:dep-ann"/>
@@ -307,7 +299,6 @@ Build-Date: ${build.tstamp}
             <compilerarg value="-Xlint:unchecked"/>
             <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
             <compilerarg value="-XDignore.symbol.file"/>
-            <compilerarg value="-Xep:ReferenceEquality:OFF" compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"/>
             <compilerarg line="-Xmaxwarns 1000"/>
         </javac>
 
@@ -321,6 +312,7 @@ Build-Date: ${build.tstamp}
         </uptodate>
         <mkdir dir="${build.dir}"/>
         <mkdir dir="${dist.dir}"/>
+        <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${antcontrib.jar}"/>
     </target>
     <target name="javadoc" depends="init-properties">
         <javadoc destdir="javadoc"
@@ -346,6 +338,7 @@ Build-Date: ${build.tstamp}
         <delete file="${src.dir}/org/w3/_2001/xmlschema/Adapter1.java"/>
         <delete dir="${src.dir}/org/openstreetmap/josm/data/imagery/types"/>
         <delete file="${epsg.output}"/>
+        <ant target="clean" dir="i18n"/>
     </target>
     <macrodef name="init-test-preferences">
         <attribute name="testfamily"/>
@@ -776,6 +769,7 @@ Build-Date: ${build.tstamp}
                 <pathelement path="${base.dir}"/>
                 <pathelement path="${proj-classpath}"/>
                 <pathelement path="${proj-build.dir}"/>
+                <path refid="classpath"/>
             </classpath>
             <arg value="${base.dir}"/>
         </java>
--- 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="plugin.dir" value="../plugins"/>
     <property name="maps.srcfile" value="http://josm.openstreetmap.de/maps"/>
@@ -12,8 +12,8 @@
     <property name="i18n_data.install.dir" value="${josm.build.dir}/data_nodist/trans"/>
     <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}"/>
         <!-- for the <foreach> possibility -->
@@ -55,7 +55,7 @@
         </exec>
         <delete file="po/josm.raw.pot"/>
     </target>
-    <target name="po/core.pot" description="Extracts message keys from the JOSM core source code" depends="trans_.java,init">
+    <target name="po/core.pot" description="Extracts message keys from the JOSM core source code" depends="builddir,init">
         <gettext-extract keysFile="core.pot" poDirectory="po" keywords="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3">
             <fileset dir="${josm.build.dir}/src" includes="**/*.java"/>
             <fileset dir="${i18n.build.dir}" includes="specialmessages.java"/>
@@ -96,9 +96,14 @@
         <delete file="${po.build.dir}/data.pot"/>
         <delete file="${po.build.dir}/plugins.raw.pot"/>
     </target>
-    <target name="build" depends="pot,allpot">
-        <antcall target="buildcore"/>
-        <antcall target="buildplugins"/>
+    <target name="build.check">
+        <condition property="build.run">
+            <not><available file="build-timestamp"/></not>
+        </condition>
+    </target>
+    <target name="build" depends="build.check,po/core.pot" if="build.run">
+        <antcall target="coretrans"/>
+        <touch file="build-timestamp"/>
     </target>
     <target name="buildplugins" depends="init">
         <foreach param="path" target="plugintrans" parallel="true" maxThreads="8">
@@ -147,15 +152,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" depends="pot">
         <mkdir dir="${i18n.build.dir}/test"/>
