git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@558058 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -194,6 +194,9 @@ Other changes: | |||||
| * <jar> has a new strict attribute that checks if the jar complies with | * <jar> has a new strict attribute that checks if the jar complies with | ||||
| the jar packaging version specification. | the jar packaging version specification. | ||||
| * <javac> has a new attribute - includeDestClasses. | |||||
| Bugzilla 40776. | |||||
| Changes from Ant 1.6.5 to Ant 1.7.0 | Changes from Ant 1.6.5 to Ant 1.7.0 | ||||
| =================================== | =================================== | ||||
| @@ -403,6 +403,29 @@ invoking the compiler.</p> | |||||
| </td> | </td> | ||||
| <td align="center" valign="top">No</td> | <td align="center" valign="top">No</td> | ||||
| </tr> | </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> | </table> | ||||
| <h3>Parameters specified as nested elements</h3> | <h3>Parameters specified as nested elements</h3> | ||||
| @@ -116,6 +116,7 @@ public class Javac extends MatchingTask { | |||||
| private String updatedProperty; | private String updatedProperty; | ||||
| private String errorProperty; | private String errorProperty; | ||||
| private boolean taskSuccess = true; // assume the best | private boolean taskSuccess = true; // assume the best | ||||
| private boolean includeDestClasses = true; | |||||
| /** | /** | ||||
| * Javac task for compilation of Java files. | * Javac task for compilation of Java files. | ||||
| @@ -817,6 +818,25 @@ public class Javac extends MatchingTask { | |||||
| this.errorProperty = errorProperty; | 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). | * Get the result of the javac task (success or failure). | ||||
| * @return true if compilation succeeded, or | * @return true if compilation succeeded, or | ||||
| @@ -137,7 +137,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter { | |||||
| // add dest dir to classpath so that previously compiled and | // add dest dir to classpath so that previously compiled and | ||||
| // untouched classes are on classpath | // untouched classes are on classpath | ||||
| if (destDir != null) { | |||||
| if (destDir != null && getJavac().isIncludeDestClasses()) { | |||||
| classpath.setLocation(destDir); | classpath.setLocation(destDir); | ||||
| } | } | ||||
| @@ -2,8 +2,43 @@ | |||||
| <import file="../antunit-base.xml" /> | <import file="../antunit-base.xml" /> | ||||
| <property name="ant-build" location="../../../../build"/> | <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"> | <target name="test-updated-property"> | ||||
| <delete quiet="yes" dir="${build-dir}"/> | <delete quiet="yes" dir="${build-dir}"/> | ||||
| <mkdir dir="${build-dir}"/> | <mkdir dir="${build-dir}"/> | ||||