From 5ecf92bf58b97b706cc15d4fee480d1213dc4750 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Date: Fri, 28 Oct 2011 10:46:33 +0000
Subject: [PATCH] add an option to suppress the artifical package-info.class
files created by . PR 52096
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1190243 13f79535-47bb-0310-9956-ffa450edef68
---
WHATSNEW | 7 ++++++-
manual/Tasks/javac.html | 16 ++++++++++++++++
.../org/apache/tools/ant/taskdefs/Javac.java | 15 +++++++++++++++
src/tests/antunit/taskdefs/javac-test.xml | 12 ++++++++++++
4 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/WHATSNEW b/WHATSNEW
index 09c1a6df8..ba0a73f73 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -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.
+
+ * 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
===================================
diff --git a/manual/Tasks/javac.html b/manual/Tasks/javac.html
index 168f6b9cb..40c4199fe 100644
--- a/manual/Tasks/javac.html
+++ b/manual/Tasks/javac.html
@@ -441,6 +441,22 @@ invoking the compiler.
No - default is "true" |
+
+ createMissingPackageInfoClass |
+
+ Some package level annotations in package-info.java
+ files don't create any package-info.class files so
+ Ant would recompile the same file every time.
+ Starting with Ant 1.8 Ant will create an
+ empty package-info.class for
+ each package-info.java if there isn't one created
+ by the compiler.
+ In some setups this additional class causes problems and it can
+ be suppressed by setting this attribute to "false".
+ Since Ant 1.8.3.
+ |
+ No - default is "true" |
+
Parameters specified as nested elements
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java
index dd80b727f..a5502524c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javac.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java
@@ -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.
*/
@@ -884,6 +886,17 @@ public class Javac extends MatchingTask {
nestedAdapter = adapter;
}
+ /**
+ * 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;
diff --git a/src/tests/antunit/taskdefs/javac-test.xml b/src/tests/antunit/taskdefs/javac-test.xml
index 7201d2da1..3e5ceba04 100644
--- a/src/tests/antunit/taskdefs/javac-test.xml
+++ b/src/tests/antunit/taskdefs/javac-test.xml
@@ -139,6 +139,18 @@
+
+
+
+
+
+
+
+