Browse Source

PR 37546:

Use alternative names for the compiler argument line.
(If modern is specified in javac and javac1.5 is used, 
and for javac1.5 a command line is specified, but no
command line is specified for modern, the javac1.5 
command line will be used, if no javac has been specified
and javac 1.4 is used and a comman line is specified for
modern, the command line specified for modern will be used,
etc.)

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@345766 13f79535-47bb-0310-9956-ffa450edef68
master
Jacobus Martinus Kruithof 19 years ago
parent
commit
f6af37217e
2 changed files with 71 additions and 16 deletions
  1. +3
    -0
      WHATSNEW
  2. +68
    -16
      src/main/org/apache/tools/ant/taskdefs/Javac.java

+ 3
- 0
WHATSNEW View File

@@ -4,6 +4,9 @@ Changes from current Ant 1.6.5 version to current CVS version
Changes that could break older environments:
--------------------------------------------

* Use alternative names for the command line arguments in javac. Bugzilla
Report 37546.

* Use org.apache.log4j.Logger instead of org.apache.log4j.Category.
Category has been deprecated for ~2 years and has been removed from
the log4j code. Logger was introduced in log4j 1.2 so users of


+ 68
- 16
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

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

private static final String JAVAC15 = "javac1.5";
private static final String JAVAC14 = "javac1.4";
private static final String JAVAC13 = "javac1.3";
private static final String JAVAC12 = "javac1.2";
private static final String JAVAC11 = "javac1.1";
private static final String MODERN = "modern";
private static final String CLASSIC = "classic";
private static final String EXTJAVAC = "extJavac";

private Path src;
private File destDir;
private Path compileClasspath;
@@ -103,18 +112,22 @@ public class Javac extends MatchingTask {
* Javac task for compilation of Java files.
*/
public Javac() {
facade = new FacadeTaskHelper(assumedJavaVersion());
}

private String assumedJavaVersion() {
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
facade = new FacadeTaskHelper("javac1.1");
return JAVAC11;
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)) {
facade = new FacadeTaskHelper("javac1.2");
return JAVAC12;
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)) {
facade = new FacadeTaskHelper("javac1.3");
return JAVAC13;
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)) {
facade = new FacadeTaskHelper("javac1.4");
return JAVAC14;
} else if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) {
facade = new FacadeTaskHelper("javac1.5");
return JAVAC15;
} else {
facade = new FacadeTaskHelper("classic");
return CLASSIC;
}
}

@@ -700,15 +713,54 @@ public class Javac extends MatchingTask {
*/
public String[] getCurrentCompilerArgs() {
String chosen = facade.getExplicitChoice();
// make sure facade knows about magic properties and fork setting
facade.setImplementation(getCompiler());
try {
return facade.getArgs();
// make sure facade knows about magic properties and fork setting
String appliedCompiler = getCompiler();
facade.setImplementation(appliedCompiler);

String[] result = facade.getArgs();

String altCompilerName = getAltCompilerName(facade.getImplementation());

if (result.length == 0 && altCompilerName != null) {
facade.setImplementation(altCompilerName);
result = facade.getArgs();
}

return result;

} finally {
facade.setImplementation(chosen);
}
}

private String getAltCompilerName(String anImplementation) {
if (JAVAC15.equalsIgnoreCase(anImplementation)
|| JAVAC14.equalsIgnoreCase(anImplementation)
|| JAVAC13.equalsIgnoreCase(anImplementation)) {
return MODERN;
}
if (JAVAC12.equalsIgnoreCase(anImplementation)
|| JAVAC11.equalsIgnoreCase(anImplementation)) {
return CLASSIC;
}
if (MODERN.equalsIgnoreCase(anImplementation)) {
String nextSelected = assumedJavaVersion();
if (JAVAC15.equalsIgnoreCase(nextSelected)
|| JAVAC14.equalsIgnoreCase(nextSelected)
|| JAVAC13.equalsIgnoreCase(nextSelected)) {
return nextSelected;
}
}
if (CLASSIC.equals(anImplementation)) {
return assumedJavaVersion();
}
if (EXTJAVAC.equalsIgnoreCase(anImplementation)) {
return assumedJavaVersion();
}
return null;
}

/**
* Where Ant should place temporary files.
*
@@ -806,13 +858,13 @@ public class Javac extends MatchingTask {
* "javac1.2", "javac1.3", "javac1.4" or "javac1.5".
*/
protected boolean isJdkCompiler(String compilerImpl) {
return "modern".equals(compilerImpl)
|| "classic".equals(compilerImpl)
|| "javac1.1".equals(compilerImpl)
|| "javac1.2".equals(compilerImpl)
|| "javac1.3".equals(compilerImpl)
|| "javac1.4".equals(compilerImpl)
|| "javac1.5".equals(compilerImpl);
return MODERN.equals(compilerImpl)
|| CLASSIC.equals(compilerImpl)
|| JAVAC15.equals(compilerImpl)
|| JAVAC14.equals(compilerImpl)
|| JAVAC13.equals(compilerImpl)
|| JAVAC12.equals(compilerImpl)
|| JAVAC11.equals(compilerImpl);
}

/**


Loading…
Cancel
Save