From 03c6952a50ba663cea05d8a3e4cc4ca4b956d879 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 17 Mar 2005 09:34:02 +0000 Subject: [PATCH] Optionally create javadocs for packages that only contain a package.html file. PR: 25339 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278005 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 ++++ docs/manual/CoreTasks/javadoc.html | 13 ++++++++++-- .../apache/tools/ant/taskdefs/Javadoc.java | 20 +++++++++++++++---- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index f1de02aa0..3af7e7797 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -281,6 +281,10 @@ Other changes: This was confusing so the definitions are now treated as similar. Bugzilla Report 31215. +* has a new attribute "includenosourcepackages" that can be + used to document packages that don't hold source files but a + package.html file. Bugzilla Report 25339. + Fixed bugs: ----------- diff --git a/docs/manual/CoreTasks/javadoc.html b/docs/manual/CoreTasks/javadoc.html index f4135edbc..466bb02b4 100644 --- a/docs/manual/CoreTasks/javadoc.html +++ b/docs/manual/CoreTasks/javadoc.html @@ -433,6 +433,14 @@ means any VM of at least version 1.2.

1.4+ No + + includenosourcepackages + If set to true, packages that don't contain Java + source but a package.html will get documented as well. + since Ant 1.6.3. + all + No (default is false) +

Format of the group attribute

@@ -465,8 +473,9 @@ the nested <packageset> elements.

A FileSet. All matched files will be passed to javadoc as source files. Ant will -automatically add the include pattern **/*.java to these -filesets.

+automatically add the include pattern **/*.java (and +**/package.html if inncludenosourcepackages is true) to +these filesets.

Nested filesets can be used to document sources that are in the default package or if you want to exclude certain files from diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index ae13f67b3..856e809b0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -434,6 +434,7 @@ public class Javadoc extends Task { private boolean linksource = false; private boolean breakiterator = false; private String noqualifier; + private boolean includeNoSourcePackages = false; private Vector fileSets = new Vector(); private Vector packageSets = new Vector(); @@ -1623,6 +1624,15 @@ public class Javadoc extends Task { this.noqualifier = noqualifier; } + /** + * If set to true, Ant will also accept packages that only hold + * package.html files but no Java sources. + * @since Ant 1.6.3 + */ + public void setIncludeNoSourcePackages(boolean b) { + this.includeNoSourcePackages = b; + } + /** * Execute the task. * @throws BuildException on error @@ -2080,6 +2090,9 @@ public class Javadoc extends Task { if (!fs.hasPatterns() && !fs.hasSelectors()) { fs = (FileSet) fs.clone(); fs.createInclude().setName("**/*.java"); + if (includeNoSourcePackages) { + fs.createInclude().setName("**/package.html"); + } } File baseDir = fs.getDir(getProject()); DirectoryScanner ds = fs.getDirectoryScanner(getProject()); @@ -2152,10 +2165,9 @@ public class Javadoc extends Task { File pd = new File(baseDir, dirs[i]); String[] files = pd.list(new FilenameFilter () { public boolean accept(File dir1, String name) { - if (name.endsWith(".java")) { - return true; - } - return false; // ignore dirs + return name.endsWith(".java") + || (includeNoSourcePackages + && name.equals("package.html")); } });