This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to branch master
in repository ant.

commit 1ba93646ef6e2712fbdf5aaea43a913cdf12e0d0
Author: Emmanuel Bourg <ebo...@apache.org>
Date:   Wed Nov 29 00:08:26 2017 +0100

    Reworked the source/target patch
---
 debian/patches/0013-auto-adjust-target.patch | 98 ++++++++++++++++------------
 1 file changed, 57 insertions(+), 41 deletions(-)

diff --git a/debian/patches/0013-auto-adjust-target.patch 
b/debian/patches/0013-auto-adjust-target.patch
index d839ec3..5345d7b 100644
--- a/debian/patches/0013-auto-adjust-target.patch
+++ b/debian/patches/0013-auto-adjust-target.patch
@@ -1,7 +1,6 @@
 Description: Adjust the source/target level automatically for Debian builds 
with Java 9
-Author: Emmanuel Bourg <ebo...@apache.org>
+Author: Emmanuel Bourg <ebo...@apache.org>, Chris West (Faux) <deb...@fau.xxx>
 Forwarded: no
-
 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java
 +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java
 @@ -207,7 +207,10 @@
@@ -9,7 +8,7 @@ Forwarded: no
      public String getSource() {
          return source != null
 -            ? source : 
getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE);
-+            ? source : washPlatformVersion(
++            ? source : LanguageLevel.adjust(
 +                    getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE),
 +                    MagicNames.BUILD_JAVAC_SOURCE,
 +                    this);
@@ -21,7 +20,7 @@ Forwarded: no
          return targetAttribute != null
              ? targetAttribute
 -            : getProject().getProperty(MagicNames.BUILD_JAVAC_TARGET);
-+            : washPlatformVersion(
++            : LanguageLevel.adjust(
 +                    getProject().getProperty(MagicNames.BUILD_JAVAC_TARGET),
 +                    MagicNames.BUILD_JAVAC_TARGET,
 +                    this);
@@ -32,59 +31,76 @@ Forwarded: no
          checkParameters();
          resetFileLists();
  
-+        source = washPlatformVersion(source, "javac -source", this);
-+        targetAttribute = washPlatformVersion(targetAttribute, "javac 
-target", this);
++        source = LanguageLevel.adjust(source, "javac -source", this);
++        targetAttribute = LanguageLevel.adjust(targetAttribute, "javac 
-target", this);
 +
          // scan source directories and dest directory to build up
          // compile list
          if (hasPath(src)) {
-@@ -1721,4 +1730,38 @@
-         0x00, 0x00, 0x00, 0x02, 0x00, 0x04
-     };
+--- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
++++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
+@@ -2203,7 +2203,7 @@
+             : getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE);
+         if (sourceArg != null) {
+             toExecute.createArgument().setValue("-source");
+-            toExecute.createArgument().setValue(sourceArg);
++            
toExecute.createArgument().setValue(LanguageLevel.adjust(sourceArg, "javadoc 
-source", this));
+         }
  
-+    /// adjust the source/target level automatically for Debian builds with 
Java >=9
-+    static String washPlatformVersion(String original, String location, 
org.apache.tools.ant.Task logTo) {
-+        if (null == original) {
-+            return original;
-+        }
+         if (linksource && doclet == null) {
+--- /dev/null
++++ b/src/main/org/apache/tools/ant/taskdefs/LanguageLevel.java
+@@ -0,0 +1,53 @@
++package org.apache.tools.ant.taskdefs;
 +
-+        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)
-+                || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)
-+                || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)
-+                || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)
-+                || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) {
++import java.util.Arrays;
++import java.util.List;
++import org.apache.tools.ant.Project;
++import org.apache.tools.ant.Task;
++import org.apache.tools.ant.util.JavaEnvUtils;
 +
-+            // no need to do anything on pre-Java 9 JDKs
-+            return original;
++class LanguageLevel {
++
++    /** The minimum language level supported by the current javac */
++    private static final String MIN_LEVEL = "1.6";
++
++    /** The list of language levels no longer supported by the current javac 
*/
++    private static final List<String> UNSUPPORTED_LEVELS = Arrays.asList(new 
String[]{"1.1", "1.2", "1.3", "1.4", "1.5", "5"});
++
++    /**
++     * Adjust the source/target level automatically for Debian builds with 
Java 9 or later.
++     *
++     * @param level    the source/target level to be adjusted
++     * @param location the command or property referring to the specified 
level
++     * @param logger   the calling task used for logging purpose
++     */
++    static String adjust(String level, String location, Task logger) {
++        if (level == null) {
++            return level;
 +        }
 +
 +        if (System.getenv("DEB_BUILD_ARCH") == null) {
-+
 +            // only do this is it's a Debian package build
-+            return original;
++            return level;
 +        }
 +
-+        List<String> unsupportedLanguageLevels = java.util.Arrays.asList(new 
String[]{"1.1", "1.2", "1.3", "1.4", "1.5", "5"});
++        if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)
++                || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)
++                || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)
++                || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_8)) {
 +
-+        if (!unsupportedLanguageLevels.contains(original)) {
-+            return original;
++            // no need to do anything on pre-Java 9 JDKs
++            return level;
 +        }
 +
-+        if (logTo != null) {
-+            logTo.log("Using " + location + " "  + original + " is no longer 
supported, switching to 1.6", Project.MSG_WARN);
++        if (!UNSUPPORTED_LEVELS.contains(level)) {
++            return level;
 +        }
 +
-+        return "1.6";
++        if (logger != null) {
++            logger.log("Using " + location + " "  + level + " is no longer 
supported, switching to " + MIN_LEVEL, Project.MSG_WARN);
++        }
++
++        return MIN_LEVEL;
 +    }
- }
---- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
-+++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
-@@ -2203,7 +2203,7 @@
-             : getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE);
-         if (sourceArg != null) {
-             toExecute.createArgument().setValue("-source");
--            toExecute.createArgument().setValue(sourceArg);
-+            
toExecute.createArgument().setValue(Javac.washPlatformVersion(sourceArg, 
"javadoc -source", this));
-         }
- 
-         if (linksource && doclet == null) {
++}

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-java/ant.git

_______________________________________________
pkg-java-commits mailing list
pkg-java-comm...@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

Reply via email to