ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1037667 - in /ant/core/trunk: ./ docs/manual/Tasks/ src/main/org/apache/tools/ant/taskdefs/ src/main/org/apache/tools/ant/taskdefs/compilers/
Date Mon, 22 Nov 2010 10:43:32 GMT
Author: bodewig
Date: Mon Nov 22 10:43:32 2010
New Revision: 1037667

URL: http://svn.apache.org/viewvc?rev=1037667&view=rev
Log:
fixup -source for OpenJDK7's javac

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/Tasks/javac.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1037667&r1=1037666&r2=1037667&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Nov 22 10:43:32 2010
@@ -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 
 ===================================
 

Modified: ant/core/trunk/docs/manual/Tasks/javac.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/Tasks/javac.html?rev=1037667&r1=1037666&r2=1037667&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/Tasks/javac.html (original)
+++ ant/core/trunk/docs/manual/Tasks/javac.html Mon Nov 22 10:43:32 2010
@@ -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>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?rev=1037667&r1=1037666&r2=1037667&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 Mon Nov 22 10:43:32 2010
@@ -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)

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java?rev=1037667&r1=1037666&r2=1037667&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java
Mon Nov 22 10:43:32 2010
@@ -119,7 +119,8 @@ public final class CompilerAdapterFactor
                 || 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();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java?rev=1037667&r1=1037666&r2=1037667&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
Mon Nov 22 10:43:32 2010
@@ -332,13 +332,12 @@ public abstract class DefaultCompilerAda
             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 DefaultCompilerAda
                     // 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;
@@ -620,6 +612,21 @@ public abstract class DefaultCompilerAda
     }
 
     /**
+     * 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 DefaultCompilerAda
     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);
+    }
+
 }
 



Mime
View raw message