ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: <javac.preset>
Date Thu, 28 Oct 2004 13:59:45 GMT
On Thu, 28 Oct 2004, Stefan Bodewig <bodewig@apache.org> wrote:

> Maybe we should change javac to automatically map 1.1 and 1.2 to
> -source 1.3 for JDK 1.4?

Looks trivial.  Does anybody take issues with the appended patch?

Stefan

Index: src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v
retrieving revision 1.49
diff -u -r1.49 DefaultCompilerAdapter.java
--- src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java	6 Oct 2004
22:41:52 -0000	1.49
+++ src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java	28 Oct 2004
13:59:04 -0000
@@ -297,7 +297,15 @@
         setupJavacCommandlineSwitches(cmd, true);
         if (attributes.getSource() != null && !assumeJava13()) {
             cmd.createArgument().setValue("-source");
-            cmd.createArgument().setValue(attributes.getSource());
+            String source = attributes.getSource();
+            if (assumeJava14() && 
+                (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
+                cmd.createArgument().setValue("1.3");
+            } else {
+                cmd.createArgument().setValue(source);
+            }
         }
         return cmd;
     }
@@ -499,6 +507,20 @@
                 && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3))
             || ("extJavac".equals(attributes.getCompilerVersion())
                 && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3));
+    }
+
+    /**
+     * Shall we assume JDK 1.4 command line switches?
+     * @since Ant 1.6.3
+     */
+    protected boolean assumeJava14() {
+        return "javac1.4".equals(attributes.getCompilerVersion())
+            || ("classic".equals(attributes.getCompilerVersion())
+                && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4))
+            || ("modern".equals(attributes.getCompilerVersion())
+                && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4))
+            || ("extJavac".equals(attributes.getCompilerVersion())
+                && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4));
     }
 
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message