You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2012/01/29 20:49:01 UTC

svn commit: r1237438 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java

Author: bodewig
Date: Sun Jan 29 19:49:01 2012
New Revision: 1237438

URL: http://svn.apache.org/viewvc?rev=1237438&view=rev
Log:
extract handling of -source 1.1 and 1.2

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java?rev=1237438&r1=1237437&r2=1237438&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java Sun Jan 29 19:49:01 2012
@@ -341,21 +341,11 @@ public abstract class DefaultCompilerAda
         if (attributes.getSource() != null && !assumeJava13()) {
             cmd.createArgument().setValue("-source");
             String source = attributes.getSource();
-            if (source.equals("1.1") || source.equals("1.2")) {
-                // support for -source 1.1 and -source 1.2 has been
-                // added with JDK 1.4.2 - and isn't present in 1.5.0+
-                cmd.createArgument().setValue("1.3");
-            } else {
-                cmd.createArgument().setValue(source);
-            }
+            cmd.createArgument().setValue(adjustSourceValue(source));
         } else if (!assumeJava13() && !assumeJava14()
                    && attributes.getTarget() != null) {
             String t = attributes.getTarget();
-                String s = t;
-                if (t.equals("1.1") || t.equals("1.2")) {
-                    // 1.5.0 doesn't support -source 1.1 or 1.2
-                    s = "1.3";
-                }
+            String s = adjustSourceValue(t);
             if (mustSetSourceForTarget(t)) {
                 setImplicitSourceSwitch(cmd, t, s);
             }
@@ -712,5 +702,17 @@ public abstract class DefaultCompilerAda
                 && !assumeJava15() && !assumeJava16())
             || (t.equals("7") && !assumeJava17());
     }
+
+
+    /**
+     * Turn the task's attribute for -source into soemthing that is
+     * understood by all javac's after 1.4.
+     *
+     * <p>support for -source 1.1 and -source 1.2 has been added with
+     * JDK 1.4.2 but isn't present in 1.5.0+</p>
+     */
+    private String adjustSourceValue(String source) {
+        return (source.equals("1.1") || source.equals("1.2")) ? "1.3" : source;
+    }
 }