ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r345766 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/Javac.java
Date Sun, 20 Nov 2005 18:06:31 GMT
Author: jkf
Date: Sun Nov 20 10:06:25 2005
New Revision: 345766

URL: http://svn.apache.org/viewcvs?rev=345766&view=rev
Log:
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.)

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewcvs/ant/core/trunk/WHATSNEW?rev=345766&r1=345765&r2=345766&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sun Nov 20 10:06:25 2005
@@ -4,6 +4,9 @@
 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

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?rev=345766&r1=345765&r2=345766&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java Sun Nov 20 10:06:25 2005
@@ -69,6 +69,15 @@
     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 @@
      * 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 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 @@
      *                 "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);
     }
 
     /**



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


Mime
View raw message