ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1190243 - in /ant/core/trunk: WHATSNEW manual/Tasks/javac.html src/main/org/apache/tools/ant/taskdefs/Javac.java src/tests/antunit/taskdefs/javac-test.xml
Date Fri, 28 Oct 2011 10:46:34 GMT
Author: bodewig
Date: Fri Oct 28 10:46:33 2011
New Revision: 1190243

URL: http://svn.apache.org/viewvc?rev=1190243&view=rev
Log:
add an option to suppress the artifical package-info.class files created by <javac>.
 PR 52096

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/manual/Tasks/javac.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
    ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1190243&r1=1190242&r2=1190243&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Oct 28 10:46:33 2011
@@ -134,7 +134,12 @@ Other changes:
    property hasn't been set when the resource was empty even if the
    quiet attribute was set to true.  They will now use VERBOSE
    instead.
-   Bugzilla Report 52107.   
+   Bugzilla Report 52107.
+
+ * <javac> has a new attribute createMissingPackageInfoClass that can
+   be set to false to prevent Ant from creating empty dummy classes
+   used for up-to-date-ness checks.
+   Bugzilla Report 52096.
 
 Changes from Ant 1.8.1 TO Ant 1.8.2
 ===================================

Modified: ant/core/trunk/manual/Tasks/javac.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/manual/Tasks/javac.html?rev=1190243&r1=1190242&r2=1190243&view=diff
==============================================================================
--- ant/core/trunk/manual/Tasks/javac.html (original)
+++ ant/core/trunk/manual/Tasks/javac.html Fri Oct 28 10:46:33 2011
@@ -441,6 +441,22 @@ invoking the compiler.</p>
     </td>
     <td align="center" valign="top">No - default is "true"</td>
   </tr>
+  <tr>
+    <td valign="top">createMissingPackageInfoClass</td>
+    <td valign="top">
+      Some package level annotations in <code>package-info.java</code>
+      files don't create any <code>package-info.class</code> files so
+      Ant would recompile the same file every time.<br/>
+      Starting with Ant 1.8 Ant will create an
+      empty <code>package-info.class</code> for
+      each <code>package-info.java</code> if there isn't one created
+      by the compiler.<br/>
+      In some setups this additional class causes problems and it can
+      be suppressed by setting this attribute to "false".
+      <em>Since Ant 1.8.3</em>.
+    </td>
+    <td align="center" valign="top">No - default is "true"</td>
+  </tr>
 </table>
 
 <h3>Parameters specified as nested elements</h3>

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=1190243&r1=1190242&r2=1190243&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 Fri Oct 28 10:46:33 2011
@@ -131,6 +131,8 @@ public class Javac extends MatchingTask 
     private boolean includeDestClasses = true;
     private CompilerAdapter nestedAdapter = null;
 
+    private boolean createMissingPackageInfoClass = true;
+
     /**
      * Javac task for compilation of Java files.
      */
@@ -885,6 +887,17 @@ public class Javac extends MatchingTask 
     }
 
     /**
+     * Whether package-info.class files will be created by Ant
+     * matching package-info.java files that have been compiled but
+     * didn't create class files themselves.
+     *
+     * @since Ant 1.8.3
+     */
+    public void setCreateMissingPackageInfoClass(boolean b) {
+        createMissingPackageInfoClass = b;
+    }
+
+    /**
      * Executes the task.
      * @exception BuildException if an error occurs
      */
@@ -1133,6 +1146,7 @@ public class Javac extends MatchingTask 
             // finally, lets execute the compiler!!
             if (adapter.execute()) {
                 // Success
+                if (createMissingPackageInfoClass) {
                 try {
                     generateMissingPackageInfoClasses(destDir != null
                                                       ? destDir
@@ -1142,6 +1156,7 @@ public class Javac extends MatchingTask 
                     // Should this be made a nonfatal warning?
                     throw new BuildException(x, getLocation());
                 }
+                }
             } else {
                 // Fail path
                 this.taskSuccess = false;

Modified: ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml?rev=1190243&r1=1190242&r2=1190243&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/javac-test.xml Fri Oct 28 10:46:33 2011
@@ -139,6 +139,18 @@
     <au:assertPropertyEquals name="third-pass" value="true" />
   </target>
 
+  <target name="testSuppressPackageInfoClass"
+          depends="setUpForPackageInfoJava"
+          description="https://issues.apache.org/bugzilla/show_bug.cgi?id=52096">
+    <au:assertFileExists file="${build-dir}/a/package-info.class"/>
+    <delete file="${build-dir}/a/package-info.class"/>
+    <javac srcdir="${javac-dir}/src" destdir="${build-dir}"
+           createMissingPackageInfoClass="false"
+           updatedProperty="second-pass" />
+    <au:assertPropertyEquals name="second-pass" value="true" />
+    <au:assertFileDoesntExist file="${build-dir}/a/package-info.class"/>
+  </target>
+
   <target name="-create-javac-adapter">
     <property name="adapter.dir" location="${output}/adapter" />
     <mkdir dir="${input}/org/example" />



Mime
View raw message