Browse Source

Help people to adapt to JDK 1.5

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277468 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
367d32fa5b
1 changed files with 29 additions and 0 deletions
  1. +29
    -0
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java

+ 29
- 0
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -310,6 +310,21 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
} else { } else {
cmd.createArgument().setValue(source); cmd.createArgument().setValue(source);
} }
} else if (assumeJava15() && attributes.getTarget() != null) {
String t = attributes.getTarget();
if (t.equals("1.1") || t.equals("1.2") || t.equals("1.3")
|| t.equals("1.4")) {
attributes.log("The -source switch defaults to 1.5 in JDK 1.5.",
Project.MSG_WARN);
attributes.log("If you specify -target " + t
+ " you now must also specify -source " + t
+ ".", Project.MSG_WARN);
attributes.log("Ant will implicitly add -source " + t
+ " for you. Please change your build file.",
Project.MSG_WARN);
cmd.createArgument().setValue("-source");
cmd.createArgument().setValue(t);
}
} }
return cmd; return cmd;
} }
@@ -527,6 +542,20 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)); && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4));
} }


/**
* Shall we assume JDK 1.5 command line switches?
* @since Ant 1.6.3
*/
protected boolean assumeJava15() {
return "javac1.5".equals(attributes.getCompilerVersion())
|| ("classic".equals(attributes.getCompilerVersion())
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5))
|| ("modern".equals(attributes.getCompilerVersion())
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5))
|| ("extJavac".equals(attributes.getCompilerVersion())
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5));
}

/** /**
* Combines a user specified bootclasspath with the system * Combines a user specified bootclasspath with the system
* bootclasspath taking build.sysclasspath into account. * bootclasspath taking build.sysclasspath into account.


Loading…
Cancel
Save