From 0ceef36b9097f2061ce321b85b654eba2bd82e52 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Sun, 29 Jan 2012 19:49:01 +0000 Subject: [PATCH] extract handling of -source 1.1 and 1.2 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1237438 13f79535-47bb-0310-9956-ffa450edef68 --- .../compilers/DefaultCompilerAdapter.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index e2d571380..dad66610a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -341,21 +341,11 @@ public abstract class DefaultCompilerAdapter 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 DefaultCompilerAdapter && !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. + * + *

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+

+ */ + private String adjustSourceValue(String source) { + return (source.equals("1.1") || source.equals("1.2")) ? "1.3" : source; + } }