diff --git a/WHATSNEW b/WHATSNEW index f1077d5bb..512c8114a 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -287,6 +287,9 @@ Other changes: * now supports a timeout attribute analog to - it is highly recommended to only use it together with fork="true". +* now supports a source attribute to enable javadoc to + handle assertions present in JDK 1.4 source code. + Changes from Ant 1.4 to Ant 1.4.1 =========================================== diff --git a/docs/manual/CoreTasks/javadoc.html b/docs/manual/CoreTasks/javadoc.html index db6f03e92..1f3753a13 100644 --- a/docs/manual/CoreTasks/javadoc.html +++ b/docs/manual/CoreTasks/javadoc.html @@ -386,6 +386,16 @@ instead.

all No + + source + Necessary to enable javadoc to handle assertions + present in J2SE v 1.4 source code. Set this to "1.4" to + documents code that compiles using "javac -source + 1.4". Will be ignored if you use a custom + doclet. + 1.4 + No +

Format of the group attribute

diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 9bd6c8ff9..bb6d69352 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -281,6 +281,7 @@ public class Javadoc extends Task { private boolean useExternalFile = false; private File tmpList = null; private FileUtils fileUtils = FileUtils.newFileUtils(); + private String source = null; /** * Work around command line length limit by using an external file @@ -431,7 +432,17 @@ public class Javadoc extends Task { } public void setOld(boolean b) { - add12ArgIf(b, "-1.1"); + if (b) { + if (javadoc1) { + log("Javadoc 1.1 doesn't support the -1.1 switch", + Project.MSG_WARN); + } else if (javadoc4) { + log("Javadoc 1.4 doesn't support the -1.1 switch anymore", + Project.MSG_WARN); + } else { + cmd.createArgument().setValue("-1.1"); + } + } } public void setClasspath(Path src) { if (classpath == null) { @@ -896,6 +907,17 @@ public class Javadoc extends Task { failOnError = b; } + /** + * Enables the -source switch, will be ignored if javadoc is not + * the 1.4 version or a different doclet than the standard doclet + * is used. + * + * @since 1.86, Ant 1.5 + */ + public void setSource(String source) { + this.source = source; + } + public void execute() throws BuildException { if ("javadoc2".equals(taskType)) { log("!! javadoc2 is deprecated. Use javadoc instead. !!"); @@ -1096,6 +1118,16 @@ public class Javadoc extends Task { } } } + + if (source != null) { + if (doclet != null) { + log("ignoring source option for custom doclet", + Project.MSG_WARN); + } else { + toExecute.createArgument().setValue("-source"); + toExecute.createArgument().setValue(source); + } + } } }