From d8b308dd9d65b2adb24ab549b8e326b4187ff807 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Thu, 28 May 2020 14:06:37 +0000
Subject: [PATCH] Build: Force Java 7 for mavencentral jars used by Android

---
 build.properties |  2 +-
 build.xml        | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/build.properties b/build.properties
index 8da666c6cb..9fc97cdb78 100644
--- a/build.properties
+++ b/build.properties
@@ -43,7 +43,7 @@ sloccount.report.file=sloccount.sc
 require.gettext=true
 
 # Compile for this version of Java
-javac.version=1.8
+#javac.version=1.8
 
 # Additional classpath if required
 #javac.classpath=/PATH/TO/pack200.jar
diff --git a/build.xml b/build.xml
index 3218c0c1e5..1dc6aa5f1f 100644
--- a/build.xml
+++ b/build.xml
@@ -2341,8 +2341,21 @@
         <echo message="... and mtn cert t:i2p-${release.number} branch i2p.i2p.release" />
     </target>
 
+    <target name="forceJava7">
+        <!-- must be set for Android -->
+        <fail message="javac.version is set to ${javac.version} - must be 1.7 for Android" >
+            <condition>
+              <and>
+                <isset property="javac.version" />
+                <not><equals arg1="${javac.version}" arg2="1.7"/></not>
+              </and>
+            </condition>
+        </fail>
+        <property name="javac.version" value="1.7" />
+    </target>
+
     <!-- depends on buildCoreTest so that the router unit test javadocs can find the core unit test classes -->
-    <target name="mavenCentral.deps" depends="buildRouter, buildStreaming, buildCoreTest">
+    <target name="mavenCentral.deps" depends="forceJava7, buildRouter, buildStreaming, buildCoreTest">
         <ant dir="core/java/">
             <target name="javadocJar" />
             <target name="sourcesJar" />
@@ -2360,6 +2373,8 @@
             <target name="sourcesJar" />
         </ant>
         <ant dir="apps/jetty/">
+            <!-- not used in Android -->
+            <property name="javac.version" value="1.8" />
             <target name="servletJar" />
             <target name="servletJavadocJar" />
             <target name="servletSourcesJar" />
-- 
GitLab