Browse Source

fixup -source for OpenJDK7's javac

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1037667 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 14 years ago
parent
commit
40e298139f
5 changed files with 57 additions and 22 deletions
  1. +2
    -0
      WHATSNEW
  2. +3
    -2
      docs/manual/Tasks/javac.html
  3. +9
    -3
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  4. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
  5. +41
    -16
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java

+ 2
- 0
WHATSNEW View File

@@ -273,6 +273,8 @@ Other changes:
* New task <bindtargets> to make a list of targets bound to some
specified extension point.

* Initial support for OpenJDK7 has been added.

Changes from Ant 1.8.0 TO Ant 1.8.1
===================================



+ 3
- 2
docs/manual/Tasks/javac.html View File

@@ -72,11 +72,12 @@ attribute are:</a></p>
<li><code>classic</code> (the standard compiler of JDK 1.1/1.2) &ndash;
<code>javac1.1</code> and
<code>javac1.2</code> can be used as aliases.</li>
<li><code>modern</code> (the standard compiler of JDK 1.3/1.4/1.5/1.6) &ndash;
<li><code>modern</code> (the standard compiler of JDK 1.3/1.4/1.5/1.6/1.7) &ndash;
<code>javac1.3</code> and
<code>javac1.4</code> and
<code>javac1.5</code> and
<code>javac1.6</code> can be used as aliases.</li>
<code>javac1.6</code> and
<code>javac1.7</code> (<em>since Ant 1.8.2</em>) can be used as aliases.</li>
<li><code>jikes</code> (the <a
href="http://jikes.sourceforge.net/" target="_top">Jikes</a>
compiler).</li>


+ 9
- 3
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -79,6 +79,7 @@ public class Javac extends MatchingTask {
private static final String FAIL_MSG
= "Compile failed; see the compiler error output for details.";

private static final String JAVAC17 = "javac1.7";
private static final String JAVAC16 = "javac1.6";
private static final String JAVAC15 = "javac1.5";
private static final String JAVAC14 = "javac1.4";
@@ -143,6 +144,8 @@ public class Javac extends MatchingTask {
return JAVAC15;
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6)) {
return JAVAC16;
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7)) {
return JAVAC17;
} else {
return CLASSIC;
}
@@ -594,7 +597,7 @@ public class Javac extends MatchingTask {
/**
* Sets the target VM that the classes will be compiled for. Valid
* values depend on the compiler, for jdk 1.4 the valid values are
* "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "5" and "6".
* "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "5", "6" and "7".
* @param target the target VM
*/
public void setTarget(String target) {
@@ -758,7 +761,8 @@ public class Javac extends MatchingTask {
}

private String getAltCompilerName(String anImplementation) {
if (JAVAC16.equalsIgnoreCase(anImplementation)
if (JAVAC17.equalsIgnoreCase(anImplementation)
|| JAVAC16.equalsIgnoreCase(anImplementation)
|| JAVAC15.equalsIgnoreCase(anImplementation)
|| JAVAC14.equalsIgnoreCase(anImplementation)
|| JAVAC13.equalsIgnoreCase(anImplementation)) {
@@ -770,7 +774,8 @@ public class Javac extends MatchingTask {
}
if (MODERN.equalsIgnoreCase(anImplementation)) {
String nextSelected = assumedJavaVersion();
if (JAVAC16.equalsIgnoreCase(nextSelected)
if (JAVAC17.equalsIgnoreCase(nextSelected)
|| JAVAC16.equalsIgnoreCase(nextSelected)
|| JAVAC15.equalsIgnoreCase(nextSelected)
|| JAVAC14.equalsIgnoreCase(nextSelected)
|| JAVAC13.equalsIgnoreCase(nextSelected)) {
@@ -965,6 +970,7 @@ public class Javac extends MatchingTask {
protected boolean isJdkCompiler(String compilerImpl) {
return MODERN.equals(compilerImpl)
|| CLASSIC.equals(compilerImpl)
|| JAVAC17.equals(compilerImpl)
|| JAVAC16.equals(compilerImpl)
|| JAVAC15.equals(compilerImpl)
|| JAVAC14.equals(compilerImpl)


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java View File

@@ -119,7 +119,8 @@ public final class CompilerAdapterFactory {
|| compilerType.equalsIgnoreCase("javac1.3")
|| compilerType.equalsIgnoreCase("javac1.4")
|| compilerType.equalsIgnoreCase("javac1.5")
|| compilerType.equalsIgnoreCase("javac1.6")) {
|| compilerType.equalsIgnoreCase("javac1.6")
|| compilerType.equalsIgnoreCase("javac1.7")) {
// does the modern compiler exist?
if (doesModernCompilerExist()) {
return new Javac13();


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

@@ -332,13 +332,12 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
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
// or 1.6.0 either
// added with JDK 1.4.2 - and isn't present in 1.5.0+
cmd.createArgument().setValue("1.3");
} else {
cmd.createArgument().setValue(source);
}
} else if ((assumeJava15() || assumeJava16())
} else if ((assumeJava15() || assumeJava16() || assumeJava17())
&& attributes.getTarget() != null) {
String t = attributes.getTarget();
if (t.equals("1.1") || t.equals("1.2") || t.equals("1.3")
@@ -348,19 +347,12 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
// 1.5.0 doesn't support -source 1.1
s = "1.2";
}
attributes.log("", Project.MSG_WARN);
attributes.log(" WARNING", Project.MSG_WARN);
attributes.log("", Project.MSG_WARN);
attributes.log("The -source switch defaults to 1.5 in JDK 1.5 and 1.6.",
Project.MSG_WARN);
attributes.log("If you specify -target " + t
+ " you now must also specify -source " + s
+ ".", Project.MSG_WARN);
attributes.log("Ant will implicitly add -source " + s
+ " for you. Please change your build file.",
Project.MSG_WARN);
cmd.createArgument().setValue("-source");
cmd.createArgument().setValue(s);
setImplicitSourceSwitch((assumeJava15() || assumeJava16())
? "1.5 in JDK 1.5 and 1.6"
: "1.7 in JDK 1.7",
cmd, s, t);
} else if (assumeJava17() && (t.equals("1.5") || t.equals("1.6"))) {
setImplicitSourceSwitch("1.7 in JDK 1.7", cmd, t, t);
}
}
return cmd;
@@ -619,6 +611,21 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_6));
}

/**
* Shall we assume JDK 1.7 command line switches?
* @return true if JDK 1.7
* @since Ant 1.8.2
*/
protected boolean assumeJava17() {
return "javac1.7".equals(attributes.getCompilerVersion())
|| ("classic".equals(attributes.getCompilerVersion())
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7))
|| ("modern".equals(attributes.getCompilerVersion())
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7))
|| ("extJavac".equals(attributes.getCompilerVersion())
&& JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_7));
}

/**
* Combines a user specified bootclasspath with the system
* bootclasspath taking build.sysclasspath into account.
@@ -647,5 +654,23 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
protected String getNoDebugArgument() {
return assumeJava11() ? null : "-g:none";
}

private void setImplicitSourceSwitch(String defaultDetails, Commandline cmd,
String target, String source) {
attributes.log("", Project.MSG_WARN);
attributes.log(" WARNING", Project.MSG_WARN);
attributes.log("", Project.MSG_WARN);
attributes.log("The -source switch defaults to " + defaultDetails + ".",
Project.MSG_WARN);
attributes.log("If you specify -target " + target
+ " you now must also specify -source " + source
+ ".", Project.MSG_WARN);
attributes.log("Ant will implicitly add -source " + source
+ " for you. Please change your build file.",
Project.MSG_WARN);
cmd.createArgument().setValue("-source");
cmd.createArgument().setValue(source);
}

}


Loading…
Cancel
Save