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
@@ -40,6 +40,7 @@
         <property name="taginfo-build.dir" location="${base.dir}/build2"/>
         <property name="checkstyle-build.dir" location="${base.dir}/build2"/>
         <property name="epsg.output" location="${base.dir}/data/projection/custom-epsg"/>
+        <property name="antcontrib.jar" value="/usr/share/java/ant-contrib.jar"/>
         <property name="error_prone_core.jar" location="${tools.dir}/error_prone_core.jar"/>
         <property name="error_prone_javac.jar" location="${tools.dir}/error_prone_javac.jar"/>
         <property name="jformatstring.jar" location="${spotbugs.dir}/jFormatString-3.0.0.jar"/>
@@ -73,10 +74,22 @@
             <isset property="isJava9"/>
         </condition>
         <path id="groovy.classpath">
-            <fileset dir="${tools.dir}/groovy">
-                <include name="*.jar"/>
+            <fileset dir="/usr/share/java/">
+                <include name="groovy-all.jar"/>
+            </fileset>
+        </path>
+        <!-- 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="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"/>
@@ -143,10 +156,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>
@@ -157,8 +169,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>
     <!--
@@ -178,7 +192,7 @@ Build-Date: ${build.tstamp}
         <copy file="README" todir="${build.dir}"/>
         <copy file="LICENSE" todir="${build.dir}"/>
         <!-- create josm-custom.jar -->
-        <delete file="${dist.jar}"/>
+        <propertyregex property="classpathprop" input="${classpathprop-colon}" global="true" regexp=":" replace=" "/>
         <jar destfile="${dist.jar}" basedir="${build.dir}" level="${clevel}">
             <!-- add attribute excludes="**/*BZip2*,**/*Bzip2*" to create a non-bzip2 supporting jar -->
             <manifest>
@@ -188,6 +202,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}"/>
                 <!-- Java 9 stuff. Entries are safely ignored by Java 8 -->
                 <attribute name="Add-Exports" value="java.base/sun.security.util java.base/sun.security.x509 java.desktop/com.apple.eawt java.desktop/com.sun.imageio.spi javafx.graphics/com.sun.javafx.application jdk.deploy/com.sun.deploy.config" />
                 <attribute name="Add-Opens" value="java.base/java.lang java.base/java.nio java.base/jdk.internal.loader java.base/jdk.internal.ref java.desktop/javax.imageio.spi java.desktop/javax.swing.text.html java.prefs/java.util.prefs" />
@@ -262,43 +278,21 @@ Build-Date: ${build.tstamp}
     </target>
     <target name="javacc" depends="init" unless="javacc.notRequired">
         <mkdir dir="${mapcss.dir}/parsergen"/>
-        <java classname="javacc" fork="true" failonerror="true">
-            <classpath path="${javacc.home}/javacc.jar"/>
+        <exec append="false" executable="javacc" failifexecutionfails="true">
             <arg value="-DEBUG_PARSER=false"/>
             <arg value="-DEBUG_TOKEN_MANAGER=false"/>
             <arg value="-JDK_VERSION=${java.lang.version}"/>
             <arg value="-GRAMMAR_ENCODING=UTF-8"/>
             <arg value="-OUTPUT_DIRECTORY=${mapcss.dir}/parsergen"/>
             <arg value="${mapcss.dir}/MapCSSParser.jj"/>
-        </java>
+        </exec>
     </target>
     <target name="compile-cots" depends="init">
         <!-- COTS -->
-        <javac srcdir="${src.dir}" includes="com/**,javax/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/tukaani/**" nowarn="on" encoding="iso-8859-1"
+        <javac srcdir="${src.dir}" classpathref="classpath" includes="com/**,javax/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/tukaani/**" nowarn="on" encoding="iso-8859-1"
             destdir="${build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on" includeAntRuntime="false" createMissingPackageInfoClass="false">
             <!-- get rid of "internal proprietary API" warning -->
             <compilerarg value="-XDignore.symbol.file"/>
-            <exclude name="org/apache/commons/compress/PasswordRequiredException.java"/>
-            <exclude name="org/apache/commons/compress/archivers/**"/>
-            <exclude name="org/apache/commons/compress/changes/**"/>
-            <exclude name="org/apache/commons/compress/compressors/bzip2/BZip2Utils.java"/>
-            <exclude name="org/apache/commons/compress/compressors/brotli/**"/>
-            <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/lz4/**"/>
-            <exclude name="org/apache/commons/compress/compressors/lzma/**"/>
-            <exclude name="org/apache/commons/compress/compressors/lz77support/**"/>
-            <exclude name="org/apache/commons/compress/compressors/pack200/**"/>
-            <exclude name="org/apache/commons/compress/compressors/snappy/**"/>
-            <exclude name="org/apache/commons/compress/compressors/xz/XZUtils.java"/>
-            <exclude name="org/apache/commons/compress/compressors/z/**"/>
-            <exclude name="org/apache/commons/compress/compressors/zstandard/**"/>
-            <exclude name="org/apache/commons/compress/parallel/**"/>
-            <exclude name="org/apache/commons/compress/utils/ArchiveUtils.java"/>
             <exclude name="org/apache/commons/jcs/JCS.java"/>
             <exclude name="org/apache/commons/jcs/access/GroupCacheAccess.java"/>
             <exclude name="org/apache/commons/jcs/access/PartitionedCacheAccess.java"/>
@@ -319,22 +313,15 @@ 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" />
     </target>
     <target name="compile-jmapviewer" depends="init">
         <!-- JMapViewer -->
-        <javac sourcepath="" srcdir="${src.dir}" fork="yes"
+        <javac sourcepath="" srcdir="${src.dir}" fork="yes" classpathref="classpath"
             excludes="com/**,javax/**,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/**,org/tukaani/**"
             destdir="${build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
-            <compilerarg value="-J-Xbootclasspath/p:${error_prone_javac.jar}" unless:set="isJava9"/>
-            <compilerarg line="-XDcompilePolicy=simple"/>
-            <compilerarg value="-processorpath"/>
-            <compilerarg pathref="processor.path"/>
             <compilerarg value="-Xlint:cast"/>
             <compilerarg value="-Xlint:deprecation"/>
             <compilerarg value="-Xlint:dep-ann"/>
@@ -348,19 +335,14 @@ 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="-Xplugin:ErrorProne -Xep:CatchAndPrintStackTrace:OFF -Xep:ReferenceEquality:OFF -Xep:StringSplitter:OFF"/>
             <compilerarg line="-Xmaxwarns 1000"/>
         </javac>
     </target>
     <target name="compile" depends="init,javacc,compile-cots,compile-jmapviewer">
         <!-- JOSM -->
-        <javac sourcepath="" srcdir="${src.dir}" fork="yes"
+        <javac sourcepath="" srcdir="${src.dir}" fork="yes" classpathref="classpath"
             excludes="com/**,javax/**,oauth/**,org/apache/commons/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/**,org/tukaani/**"
             destdir="${build.dir}" target="${java.lang.version}" source="${java.lang.version}" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
-            <compilerarg value="-J-Xbootclasspath/p:${error_prone_javac.jar}" unless:set="isJava9"/>
-            <compilerarg line="-XDcompilePolicy=simple"/>
-            <compilerarg value="-processorpath"/>
-            <compilerarg pathref="processor.path"/>
             <compilerarg value="-Xlint:cast"/>
             <compilerarg value="-Xlint:deprecation"/>
             <compilerarg value="-Xlint:dep-ann"/>
@@ -374,7 +356,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="-Xplugin:ErrorProne -Xep:ReferenceEquality:OFF -Xep:ImmutableEnumChecker:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:FloatingPointLiteralPrecision:OFF -Xep:ShortCircuitBoolean:OFF -Xep:StringSplitter:OFF -Xep:JdkObsolete:OFF -Xep:UnnecessaryParentheses:OFF -Xep:EqualsGetClass:OFF -Xep:ThreadPriorityCheck:OFF -Xep:UndefinedEquals:OFF"/>
             <compilerarg line="-Xmaxwarns 1000"/>
             <exclude name="org/openstreetmap/josm/io/audio/fx/*.java" if:set="noJavaFX"/>
         </javac>
@@ -389,6 +370,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"
@@ -424,6 +406,7 @@ Build-Date: ${build.tstamp}
         <delete dir="${src.dir}/org/openstreetmap/josm/data/imagery/types"/>
         <delete file="${epsg.output}"/>
         <delete file="${pmd.dir}/cache"/>
+        <ant target="clean" dir="i18n"/>
     </target>
     <macrodef name="init-test-preferences">
         <attribute name="testfamily"/>
@@ -996,6 +979,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="https://josm.openstreetmap.de/maps"/>
@@ -14,8 +14,8 @@
     <property name="po.build.dir" value="${i18n.build.dir}"/>
     <property name="ant.build.javac.target" value="1.5"/>
     <property name="gettext.keywords" value="-k -ktrc:1c,2 -kmarktrc:1c,2 -ktr -kmarktr -ktrn:1,2 -ktrnc:1c,2,3"/>
-    <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"/>
     <property name="grand.jar" value="lib/grand-1.9.5.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}"/>
@@ -90,7 +90,7 @@
             <arg line="po/core.pot po/maplist.pot po/presets.pot"/>
         </exec>
     </target>
-    <target name="po/core.pot" description="Extracts message keys from the JOSM core source code" depends="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="${gettext.keywords} --exclude-file=excludes.pot">
             <fileset dir="${josm.build.dir}/src" includes="**/*.java"/>
             <fileset dir="${i18n.build.dir}" includes="specialmessages.java"/>
@@ -121,9 +121,14 @@
             <fileset dir="${i18n.build.dir}" includes="trans_tag2link.java"/>
         </gettext-extract>
     </target>
-    <target name="build" depends="pot">
-        <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">
@@ -141,9 +146,9 @@
         <antcall target="coretrans"/>
         <antcall target="pluginlisttrans"/>
     </target>
-    <target name="coretrans" depends="po/core+maplist+presets.pot">
+    <target name="coretrans" depends="po/core.pot">
         <exec executable="perl" failonerror="true">
-            <arg line="i18n.pl --potfile=po/core+maplist+presets.pot --basedir=${i18n.install.dir}/ po/*.po"/>
+            <arg line="i18n.pl --potfile=po/core.pot --basedir=${i18n.install.dir}/ po/*.po"/>
         </exec>
     </target>
     <target name="pluginlisttrans" depends="po/pluginlist.pot">
@@ -186,15 +191,14 @@
             </else>
         </if>
     </target>
+    <target name="dist" depends="build">
+        <copy todir="../build">
+            <fileset dir="build"/>
+        </copy>
+    </target>
     <target name="clean">
         <delete dir="${i18n.build.dir}"/>
-        <delete file="build.dot"/>
-        <delete file="build.png"/>
-        <delete>
-            <fileset dir="po" includes="*.*~" defaultexcludes="false"/>
-            <fileset dir="po" includes="*.po" defaultexcludes="false"/>
-            <fileset dir="po" includes="*.pot" defaultexcludes="false"/>
-        </delete>
+        <delete file="build-timestamp"/>
     </target>
     <target name="test" depends="pot">
         <mkdir dir="${i18n.build.dir}/test"/>
