ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r558060 - in /ant/core/branches/ANT_17_BRANCH: ./ docs/manual/CoreTasks/ src/main/org/apache/tools/ant/taskdefs/ src/main/org/apache/tools/ant/taskdefs/compilers/ src/tests/antunit/taskdefs/
Date Fri, 20 Jul 2007 17:13:19 GMT
Author: peterreilly
Date: Fri Jul 20 10:13:16 2007
New Revision: 558060

URL: http://svn.apache.org/viewvc?view=rev&rev=558060
Log:
Merge - Bugzilla: 40776 work-around for javac generics bug

Modified:
    ant/core/branches/ANT_17_BRANCH/WHATSNEW
    ant/core/branches/ANT_17_BRANCH/docs/manual/CoreTasks/javac.html
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Javac.java
    ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
    ant/core/branches/ANT_17_BRANCH/src/tests/antunit/taskdefs/javac-test.xml

Modified: ant/core/branches/ANT_17_BRANCH/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/WHATSNEW?view=diff&rev=558060&r1=558059&r2=558060
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/WHATSNEW (original)
+++ ant/core/branches/ANT_17_BRANCH/WHATSNEW Fri Jul 20 10:13:16 2007
@@ -175,6 +175,9 @@
 * <jar> has a new strict attribute that checks if the jar complies with
   the jar packaging version specification.
 
+* <javac> has a new attribute - includeDestClasses.
+  Bugzilla 40776.
+
 Changes from Ant 1.6.5 to Ant 1.7.0
 ===================================
 

Modified: ant/core/branches/ANT_17_BRANCH/docs/manual/CoreTasks/javac.html
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/docs/manual/CoreTasks/javac.html?view=diff&rev=558060&r1=558059&r2=558060
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/docs/manual/CoreTasks/javac.html (original)
+++ ant/core/branches/ANT_17_BRANCH/docs/manual/CoreTasks/javac.html Fri Jul 20 10:13:16 2007
@@ -403,6 +403,29 @@
     </td>
     <td align="center" valign="top">No</td>
   </tr>
+  <tr>
+    <td valign="top">includeDestClasses</td>
+    <td valign="top">
+      This attribute controls whether to include the
+      destination classes directory in the classpath
+      given to the compiler.
+      The default value of this is "true" and this
+      means that previously compiled classes are on
+      the classpath for the compiler. This means that "greedy" compilers
+      will not recompile dependant classes that are already compiled.
+      In general this is a good thing as it stops the compiler
+      for doing unnecessary work. However, for some edge cases,
+      involving generics, the javac compiler
+      needs to compile the dependant classes to get the generics
+      information. One example is documented in the bug report:
+      <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=40776">
+        Bug 40776 - a problem compiling a Java 5 project with generics</a>.
+      Setting the attribute to "false" will cause the compiler
+      to recompile dependent classes.
+      <em>Since Ant 1.7.1</em>.
+    </td>
+    <td align="center" valign="top">No - default is "true"</td>
+  </tr>
 </table>
 
 <h3>Parameters specified as nested elements</h3>

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Javac.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Javac.java?view=diff&rev=558060&r1=558059&r2=558060
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Javac.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/Javac.java Fri
Jul 20 10:13:16 2007
@@ -116,6 +116,7 @@
     private String updatedProperty;
     private String errorProperty;
     private boolean taskSuccess = true; // assume the best
+    private boolean includeDestClasses = true;
 
     /**
      * Javac task for compilation of Java files.
@@ -817,6 +818,25 @@
         this.errorProperty = errorProperty;
     }
 
+    /**
+     * This property controls whether to include the
+     * destination classes directory in the classpath
+     * given to the compiler.
+     * The default value is "true".
+     * @param includeDestClasses the value to use.
+     */
+    public void setIncludeDestClasses(boolean includeDestClasses) {
+        this.includeDestClasses = includeDestClasses;
+    }
+
+    /**
+     * Get the value of the includeDestClasses property.
+     * @return the value.
+     */
+    public boolean isIncludeDestClasses() {
+        return includeDestClasses;
+    }
+        
     /**
      * Get the result of the javac task (success or failure).
      * @return true if compilation succeeded, or

Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java?view=diff&rev=558060&r1=558059&r2=558060
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
(original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
Fri Jul 20 10:13:16 2007
@@ -137,7 +137,7 @@
         // add dest dir to classpath so that previously compiled and
         // untouched classes are on classpath
 
-        if (destDir != null) {
+        if (destDir != null && getJavac().isIncludeDestClasses()) {
             classpath.setLocation(destDir);
         }
 

Modified: ant/core/branches/ANT_17_BRANCH/src/tests/antunit/taskdefs/javac-test.xml
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/tests/antunit/taskdefs/javac-test.xml?view=diff&rev=558060&r1=558059&r2=558060
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/tests/antunit/taskdefs/javac-test.xml (original)
+++ ant/core/branches/ANT_17_BRANCH/src/tests/antunit/taskdefs/javac-test.xml Fri Jul 20 10:13:16
2007
@@ -2,8 +2,43 @@
   <import file="../antunit-base.xml" />
 
   <property name="ant-build" location="../../../../build"/>
-  <property name="build-dir" location="${ant-build}/ant-unit/javac-dir/build"/>
+  <property name="javac-dir" location="${ant-build}/ant-unit/javac-dir"/>
+  <property name="build-dir" location="${javac-dir}/build"/>
   
+  <target name="test-includeDestClasses">
+    <property name="DATE" value="09/10/1999 4:30 pm"/>
+    <delete dir="${javac-dir}/src"/>
+    <mkdir dir="${javac-dir}/src"/>
+    <echo file="${javac-dir}/src/A.java">
+      public class A { B b;}
+    </echo>
+    <echo file="${javac-dir}/src/B.java">
+      public class B { }
+    </echo>
+    <delete dir="${javac-dir}/classes" quiet="yes"/>
+    <mkdir dir="${javac-dir}/classes"/>
+    <javac srcdir="${javac-dir}/src" destdir="${javac-dir}/classes"/>
+    <touch file="${javac-dir}/src/B.java" datetime="${DATE}"/>
+    <touch file="${javac-dir}/classes/B.class" datetime="${DATE}"/>
+    <!-- following should not update B.class -->
+    <delete quiet="yes" file="${javac-dir}/classes/A.class"/>
+    <javac srcdir="${javac-dir}/src" destdir="${javac-dir}/classes"/>
+    <au:assertTrue>
+      <isfileselected file="${javac-dir}/classes/B.class">
+        <date datetime="${DATE}" when="equal"/>
+      </isfileselected>
+    </au:assertTrue>
+    <!-- following should update B.class -->
+    <delete quiet="yes" file="${javac-dir}/classes/A.class"/>
+    <javac srcdir="${javac-dir}/src"
+           destdir="${javac-dir}/classes" includeDestClasses="no"/>
+    <au:assertFalse>
+      <isfileselected file="${javac-dir}/classes/B.class">
+        <date datetime="${DATE}" when="equal"/>
+      </isfileselected>
+    </au:assertFalse>
+  </target>
+
   <target name="test-updated-property">
     <delete quiet="yes" dir="${build-dir}"/>
     <mkdir dir="${build-dir}"/>



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


Mime
View raw message