From 9fe0f5be4e42e49babd57ab69bd3fa6d5e64adf1 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 26 Apr 2002 16:06:52 +0000 Subject: [PATCH] Directory based . Two new nested elements, and . is a DirSet that points to directories which get translated into packages if they contain .java sources, points to sourcefiles. based on a patch by Daniel Ritchey . allows you to select files in the default package as well. PR: 6433 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272583 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 2 + build.xml | 7 +- docs/ant15_todo.html | 40 +- docs/manual/CoreTasks/javadoc.html | 176 ++++++--- .../apache/tools/ant/taskdefs/Javadoc.java | 370 ++++++++++-------- src/main/org/apache/tools/ant/types/Path.java | 2 +- xdocs/ant15_todo.xml | 12 +- 7 files changed, 359 insertions(+), 250 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 82fb20035..5c32d82b9 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -345,6 +345,8 @@ Other changes: * has a new attribute that selects the directory in which to run the command. +* now supports two new nested elements, and . + Changes from Ant 1.4 to Ant 1.4.1 =========================================== diff --git a/build.xml b/build.xml index efb1b5d19..f1043ae51 100644 --- a/build.xml +++ b/build.xml @@ -1042,15 +1042,16 @@ unless="javadoc.notrequired" description="--> creates the API documentation"> - + + + diff --git a/docs/ant15_todo.html b/docs/ant15_todo.html index 2e1bd4f8e..b21bf62a6 100644 --- a/docs/ant15_todo.html +++ b/docs/ant15_todo.html @@ -295,26 +295,6 @@ Steve + any other help he can get - - - - - - Make javadoc a real directory based task - - - - -   - - - - - Stefan, others welcome - @@ -492,6 +472,26 @@ Stefan + + + + + + Make javadoc a real directory based task + + + + +   + + + + + Stefan + diff --git a/docs/manual/CoreTasks/javadoc.html b/docs/manual/CoreTasks/javadoc.html index 1f3753a13..cf698f6d6 100644 --- a/docs/manual/CoreTasks/javadoc.html +++ b/docs/manual/CoreTasks/javadoc.html @@ -18,9 +18,9 @@ and management costs over time. This task, however, has no notion of "changed" files, unlike the javac task. This means all packages will be processed each time this task is run. In general, however, this task is used much less frequently.

-

This task works seamlessly between different javadoc versions (1.1 and 1.2), -with the obvious restriction that the 1.2 attributes will be ignored if run in a -1.1 VM.

+

This task works seamlessly between different javadoc versions (1.1, +1.2 and 1.4), with the obvious restriction that the 1.2 attributes +will be ignored if run in a 1.1 VM.

NOTE: since javadoc calls System.exit(), javadoc cannot be run inside the same VM as ant without breaking functionality. For this reason, this task always forks the VM. This overhead is not significant since javadoc is normally a heavy @@ -38,6 +38,11 @@ notation.

there for back compatibility reasons. Since this task will be removed in future versions, you are strongly encouraged to use javadoc instead.

+ +

In the table below, 1.1 means available if your current Java VM is +a 1.1 VM, 1.2 for either 1.2 or 1.3 and 1.4 for a 1.4 Java VM. 1.2+ +means any VM of at least version 1.2.

+

Parameters

@@ -50,8 +55,9 @@ instead.

- + @@ -59,6 +65,11 @@ instead.

href="../using.html#references">reference to a PATH defined elsewhere. + + + + + @@ -71,23 +82,17 @@ instead.

- - - - - - + - + @@ -100,7 +105,7 @@ instead.

- + @@ -115,19 +120,19 @@ instead.

- + - + - + @@ -170,13 +175,13 @@ instead.

- + - + @@ -194,7 +199,7 @@ instead.

- + @@ -206,57 +211,57 @@ instead.

- + - + - + - + - + - + - + - + - + @@ -268,7 +273,7 @@ instead.

- + @@ -286,56 +291,56 @@ instead.

- + - + - - + + - - + + - + - - + - + - + - + @@ -343,7 +348,7 @@ instead.

- + @@ -351,7 +356,7 @@ instead.

- + @@ -383,7 +388,7 @@ instead.

the package names specified via the packagenames attribute or nested package elements. (yes | no). Default is no. - + @@ -412,6 +417,36 @@ recommended.

Parameters specified as nested elements

+

packageset

+ +

A DirSet. All matched +directories that contain Java source files will be passed to javadoc +as package names. Package names are created from the directory names +by translating the directory separator into dots. Ant assumes the +base directory of the packageset points to the root of a package +hierarchy.

+ +

The packagenames, excludepackagenames and +defaultexcludes attributes of the task have no effect on +the nested <packageset> elements.

+ +

fileset

+ +

A FileSet. All matched +files will be passed to javadoc as source files. Ant will +automatically add the include pattern **/*.java 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 +documentation. If you want to document all source files and don't use +the default package, packagesets should be used instead as this +increases javadocs performance.

+ +

The packagenames, excludepackagenames and +defaultexcludes attributes of the task have no effect on +the nested <fileset> elements.

+

package

Same as one entry in the list given by packagenames.

@@ -554,8 +589,9 @@ of the doclet element is shown below:

tag

-

The tag nested element is used to specify custom tags. This option is only available -with Java 1.4.

+ +

The tag nested element is used to specify custom tags. This option +is only available with Java 1.4.

Parameters
sourcepath Specify where to find source files allAt least one of the two or nested - <sourcepath>At least one of the three or nested + <sourcepath>, <fileset> or + <packageset>
sourcepathref all
sourcefilesComma separated list of source filesall
destdir Destination directory for output files all No
sourcefilesComma separated list of source filesallat least one of the two - or nested <source> or <package>
packagenames Comma separated list of package files (with terminating wildcard) allNo
packageList The name of a file containing the packages to processall1.2+ No
Bootclasspath Override location of class files loaded by the bootstrap class loader1.21.2+ No
Override location of class files loaded by the bootstrap class loader by reference to a PATH defined elsewhere.1.21.2+ No
Extdirs Override location of installed extensions1.21.2+ No
Overview Read overview documentation from HTML file1.21.2+ No
Verbose Output messages about what Javadoc is doing1.21.2+ No
Locale Locale to be used, e.g. en_US or en_US_WIN1.21.2+ No
Use Create class and package usage pages1.21.2+ No
Splitindex Split index into one file per letter1.21.2+ No
Windowtitle Browser window title for the documentation (text)1.21.2+ No
Doctitle Include title for the package index(first) page (html-code)1.21.2+ No
Header Include header text for each page (html-code)1.21.2+ No
Footer Include footer text for each page (html-code)1.21.2+ No
bottom Include bottom text for each page (html-code)1.21.2+ No
link Create links to javadoc output at the given URL1.21.2+ No
linkoffline Link to docs at <url> using package list at <url2> - separate the URLs by using a space character.1.21.2+ No
group Group specified packages together in overview page. The format is as described below.1.21.2+ No
nodeprecatedlist Do not generate deprecated list1.21.2+ No
nohelp Do not generate help link1.21.2+ No
nonavbar Do not generate navigation bar1.21.2+ No
serialwarnFUTURE: Generate warning about @serial tag1.2Generate warning about @serial tag1.2+ No
helpfileFUTURE: Specifies the HTML help file to use1.2Specifies the HTML help file to use1.2+ No
stylesheetfile Specifies the CSS stylesheet to use1.21.2+ No
charsetFUTURE: Charset for cross-platform viewing of generated + Charset for cross-platform viewing of generated documentation1.21.2+ No
docencoding Output file encoding name1.1all No
doclet Specifies the class file that starts the doclet used in generating the documentation.1.21.2+ No
docletpath Specifies the path to the doclet class file that is specified with the -doclet option.1.21.2+ No
Specifies the path to the doclet class file that is specified with the -doclet option by reference to a PATH defined elsewhere.1.21.2+ No
Lets you add additional parameters to the javadoc command line. Useful for doclets. Parameters containing spaces need to be quoted using &quot;.1.2all No
all1.2+ No
@@ -641,6 +677,52 @@ respectively.

<link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/> </javadoc> +

is the same as

+ +
  <javadoc 
+           destdir="docs/api"
+           author="true"
+           version="true"
+           use="true"
+           windowtitle="Test API">
+
+    <packageset dir="src" defaultexcludes="yes">
+      <include name="com/dummy/test/**" />
+      <exclude name="com/dummy/test/doc-files/**" />
+    </packageset>
+
+    <doctitle><![CDATA[<h1>Test</h1>]]></doctitle>
+    <bottom><![CDATA[<i>Copyright &#169; 2000 Dummy Corp. All Rights Reserved.</i>]]></bottom>
+    <tag name="todo" scope="all" description="To do:" />
+    <group title="Group 1 Packages" packages="com.dummy.test.a*"/>
+    <group title="Group 2 Packages" packages="com.dummy.test.b*:com.dummy.test.c*"/>
+    <link offline="true" href="http://java.sun.com/products/jdk/1.2/docs/api/" packagelistLoc="C:\tmp"/>
+    <link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/>
+  </javadoc>
+ +

or

+ +
  <javadoc 
+           destdir="docs/api"
+           author="true"
+           version="true"
+           use="true"
+           windowtitle="Test API">
+
+    <fileset dir="src" defaultexcludes="yes">
+      <include name="com/dummy/test/**" />
+      <exclude name="com/dummy/test/doc-files/**" />
+    </fileset>
+
+    <doctitle><![CDATA[<h1>Test</h1>]]></doctitle>
+    <bottom><![CDATA[<i>Copyright &#169; 2000 Dummy Corp. All Rights Reserved.</i>]]></bottom>
+    <tag name="todo" scope="all" description="To do:" />
+    <group title="Group 1 Packages" packages="com.dummy.test.a*"/>
+    <group title="Group 2 Packages" packages="com.dummy.test.b*:com.dummy.test.c*"/>
+    <link offline="true" href="http://java.sun.com/products/jdk/1.2/docs/api/" packagelistLoc="C:\tmp"/>
+    <link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/>
+  </javadoc>
+

Copyright © 2001-2002 Apache Software Foundation. All rights Reserved.

diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 80315d877..0e9acd54a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -67,11 +67,13 @@ import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.DirSet; +import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.PatternSet; +import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.JavaEnvUtils; @@ -84,7 +86,6 @@ import org.apache.tools.ant.util.JavaEnvUtils; *

    *
  • patterns must be of the form "xxx.*", every other pattern doesn't * work. - *
  • the java comment-stripper reader is horribly slow *
  • there is no control on arguments sanity since they are left * to the javadoc implementation. *
  • argument J in javadoc1 is not supported (what is that for anyway?) @@ -281,7 +282,7 @@ public class Javadoc extends Task { * @param name the package name. */ public void setName(String name) { - this.name = name; + this.name = name.trim(); } /** @@ -308,6 +309,11 @@ public class Javadoc extends Task { /** The source file */ private File file; + public SourceFile() {} + public SourceFile(File file) { + this.file = file; + } + /** * Set the source file. * @@ -375,14 +381,14 @@ public class Javadoc extends Task { private Commandline cmd = new Commandline(); /** Flag which indicates if javadoc from JDK 1.1 is to be used. */ - private static boolean javadoc1 = - (JavaEnvUtils.getJavaVersion() == JavaEnvUtils.JAVA_1_1); + private static boolean javadoc1 = + JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1); /** Flag which indicates if javadoc from JDK 1.4 is available */ private static boolean javadoc4 = - (JavaEnvUtils.getJavaVersion() != JavaEnvUtils.JAVA_1_1 && - JavaEnvUtils.getJavaVersion() != JavaEnvUtils.JAVA_1_2 && - JavaEnvUtils.getJavaVersion() != JavaEnvUtils.JAVA_1_3); + (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1) && + !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2) && + !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)); /** * Utility method to add an argument to the command line conditionally @@ -429,7 +435,8 @@ public class Javadoc extends Task { } /** - * Flag which indicates if the task should fail if there is a javadoc error. + * Flag which indicates if the task should fail if there is a + * javadoc error. */ private boolean failOnError = false; private Path sourcePath = null; @@ -453,10 +460,12 @@ public class Javadoc extends Task { private Html footer = null; private Html bottom = null; private boolean useExternalFile = false; - private File tmpList = null; private FileUtils fileUtils = FileUtils.newFileUtils(); private String source = null; + private Vector fileSets = new Vector(); + private Vector packageSets = new Vector(); + /** * Work around command line length limit by using an external file * for the sourcefiles. @@ -1098,7 +1107,9 @@ public class Javadoc extends Task { cmd.createArgument().setValue(enc); } public void setPackageList(String src) { - packageList = src; + if (!javadoc1) { + packageList = src; + } } public LinkArgument createLink() { @@ -1389,22 +1400,62 @@ public class Javadoc extends Task { this.source = source; } + /** + * Adds a packageset. + * + *

    All included directories will be translated into package + * names be converting the directory separator into dots.

    + * + * @since 1.5 + */ + public void addPackageset(DirSet packageSet) { + packageSets.addElement(packageSet); + } + + /** + * Adds a fileset. + * + *

    All included files will be added as sourcefiles. The task + * will automatically add + * includes="**/*.java" to the + * fileset.

    + * + * @since 1.5 + */ + public void addFileset(FileSet fs) { + fs.createInclude().setName("**/*.java"); + fileSets.addElement(fs); + } + public void execute() throws BuildException { if ("javadoc2".equals(taskType)) { log("!! javadoc2 is deprecated. Use javadoc instead. !!"); } - if (sourcePath == null) { - String msg = "sourcePath attribute must be set!"; + Vector packagesToDoc = new Vector(); + Path sourceDirs = new Path(getProject()); + parsePackages(packagesToDoc, sourceDirs); + + if (packagesToDoc.size() != 0 && sourceDirs.size() == 0) { + String msg = "sourcePath attribute must be set when " + + "specifying package names."; throw new BuildException(msg); } + Vector sourceFilesToDoc = (Vector) sourceFiles.clone(); + addFileSets(sourceFilesToDoc); + + if (packagesToDoc.size() == 0 && sourceFilesToDoc.size() == 0) { + throw new BuildException("No source files and no packages have " + + "been specified."); + } + log("Generating Javadoc", Project.MSG_INFO); Commandline toExecute = (Commandline) cmd.clone(); toExecute.setExecutable(JavaEnvUtils.getJdkExecutable("javadoc")); -// ------------------------------------------------ general javadoc arguments + // ------------------------------------------ general javadoc arguments if (doctitle != null) { toExecute.createArgument().setValue("-doctitle"); toExecute.createArgument().setValue(expand(doctitle.getText())); @@ -1431,14 +1482,14 @@ public class Javadoc extends Task { if (!javadoc1) { toExecute.createArgument().setValue("-classpath"); toExecute.createArgument().setPath(classpath); - toExecute.createArgument().setValue("-sourcepath"); - toExecute.createArgument().setPath(sourcePath); + if (sourceDirs.size() > 0) { + toExecute.createArgument().setValue("-sourcepath"); + toExecute.createArgument().setPath(sourceDirs); + } } else { + sourceDirs.append(classpath); toExecute.createArgument().setValue("-classpath"); - toExecute.createArgument() - .setValue(sourcePath.toString() - + System.getProperty("path.separator") - + classpath.toString()); + toExecute.createArgument().setPath(sourceDirs); } if (version && doclet == null) { @@ -1455,7 +1506,7 @@ public class Javadoc extends Task { } } -// --------------------------------- javadoc2 arguments for default doclet + // ---------------------------- javadoc2 arguments for default doclet if (!javadoc1) { if (doclet != null) { @@ -1616,71 +1667,53 @@ public class Javadoc extends Task { } - tmpList = null; - if (packageNames.size() > 0) { - Vector packages = new Vector(); - Enumeration enum = packageNames.elements(); - while (enum.hasMoreElements()) { - PackageName pn = (PackageName) enum.nextElement(); - String name = pn.getName().trim(); - if (name.endsWith(".*")) { - packages.addElement(name); - } else { - toExecute.createArgument().setValue(name); - } - } + File tmpList = null; + PrintWriter srcListWriter = null; + try { - Vector excludePackages = new Vector(); - if (excludePackageNames.size() > 0) { - enum = excludePackageNames.elements(); - while (enum.hasMoreElements()) { - PackageName pn = (PackageName) enum.nextElement(); - excludePackages.addElement(pn.getName().trim()); + /** + * Write sourcefiles and package names to a temporary file + * if requested. + */ + if (useExternalFile) { + if (tmpList == null) { + tmpList = fileUtils.createTempFile("javadoc", "", null); + toExecute.createArgument() + .setValue("@" + tmpList.getAbsolutePath()); } + srcListWriter = new PrintWriter( + new FileWriter(tmpList.getAbsolutePath(), + true)); } - if (packages.size() > 0) { - evaluatePackages(toExecute, sourcePath, packages, - excludePackages); - } - } - if (sourceFiles.size() > 0) { - PrintWriter srcListWriter = null; - try { - - /** - * Write sourcefiles to a temporary file if requested. - */ + Enumeration enum = packagesToDoc.elements(); + while (enum.hasMoreElements()) { + String packageName = (String) enum.nextElement(); if (useExternalFile) { - if (tmpList == null) { - tmpList = fileUtils.createTempFile("javadoc", "", null); - toExecute.createArgument() - .setValue("@" + tmpList.getAbsolutePath()); - } - srcListWriter = new PrintWriter( - new FileWriter(tmpList - .getAbsolutePath(), - true)); + srcListWriter.println(packageName); + } else { + toExecute.createArgument().setValue(packageName); } - - Enumeration enum = sourceFiles.elements(); - while (enum.hasMoreElements()) { - SourceFile sf = (SourceFile) enum.nextElement(); - String sourceFileName = sf.getFile().getAbsolutePath(); - if (useExternalFile) { - srcListWriter.println(sourceFileName); - } else { - toExecute.createArgument().setValue(sourceFileName); - } + } + + enum = sourceFilesToDoc.elements(); + while (enum.hasMoreElements()) { + SourceFile sf = (SourceFile) enum.nextElement(); + String sourceFileName = sf.getFile().getAbsolutePath(); + if (useExternalFile) { + srcListWriter.println(sourceFileName); + } else { + toExecute.createArgument().setValue(sourceFileName); } + } - } catch (IOException e) { - throw new BuildException("Error creating temporary file", - e, location); - } finally { - if (srcListWriter != null) { - srcListWriter.close(); - } + } catch (IOException e) { + tmpList.delete(); + throw new BuildException("Error creating temporary file", + e, location); + } finally { + if (srcListWriter != null) { + srcListWriter.close(); } } @@ -1712,7 +1745,6 @@ public class Javadoc extends Task { } catch (IOException e) { throw new BuildException("Javadoc failed: " + e, e, location); } finally { - if (tmpList != null) { tmpList.delete(); tmpList = null; @@ -1728,111 +1760,105 @@ public class Javadoc extends Task { } /** - * Given a source path, a list of package patterns, fill the given list - * with the packages found in that path subdirs matching one of the given - * patterns. - */ - private void evaluatePackages(Commandline toExecute, Path sourcePath, - Vector packages, Vector excludePackages) { - log("Source path = " + sourcePath.toString(), Project.MSG_VERBOSE); - StringBuffer msg = new StringBuffer("Packages = "); - for (int i = 0; i < packages.size(); i++) { - if (i > 0) { - msg.append(","); - } - msg.append(packages.elementAt(i)); - } - log(msg.toString(), Project.MSG_VERBOSE); - - msg.setLength(0); - msg.append("Exclude Packages = "); - for (int i = 0; i < excludePackages.size(); i++) { - if (i > 0) { - msg.append(","); + * Add the files matched by the nested filesets to the Vector as + * SourceFile instances. + * + * @since 1.5 + */ + private void addFileSets(Vector sf) { + Enumeration enum = fileSets.elements(); + while (enum.hasMoreElements()) { + FileSet fs = (FileSet) enum.nextElement(); + File baseDir = fs.getDir(getProject()); + DirectoryScanner ds = fs.getDirectoryScanner(getProject()); + String[] files = ds.getIncludedFiles(); + for (int i = 0; i < files.length; i++) { + sf.addElement(new SourceFile(new File(baseDir, files[i]))); } - msg.append(excludePackages.elementAt(i)); } - log(msg.toString(), Project.MSG_VERBOSE); + } + /** + * Add the directories matched by the nested dirsets to the Vector + * and the base directories of the dirsets to the Path. It also + * handles the packages and excludepackages attributes and + * elements. + * + * @since 1.5 + */ + private void parsePackages(Vector pn, Path sp) { Vector addedPackages = new Vector(); - - String[] list = sourcePath.list(); - if (list == null) { - list = new String[0]; - } - - FileSet fs = new FileSet(); - fs.setDefaultexcludes(useDefaultExcludes); - - Enumeration e = packages.elements(); - while (e.hasMoreElements()) { - String pkg = (String) e.nextElement(); - pkg = pkg.replace('.', '/'); - if (pkg.endsWith("*")) { - pkg += "*"; + Vector dirSets = (Vector) packageSets.clone(); + + // for each sourcePath entry, add a directoryset with includes + // taken from packagenames attribute and nested package + // elements and excludes taken from excludepackages attribute + // and nested excludepackage elements + if (sourcePath != null) { + PatternSet ps = new PatternSet(); + Enumeration enum = packageNames.elements(); + while (enum.hasMoreElements()) { + PackageName p = (PackageName) enum.nextElement(); + String pkg = p.getName().replace('.', '/'); + if (pkg.endsWith("*")) { + pkg += "*"; + } + ps.createInclude().setName(pkg); } - - fs.createInclude().setName(pkg); - } // while - - e = excludePackages.elements(); - while (e.hasMoreElements()) { - String pkg = (String) e.nextElement(); - pkg = pkg.replace('.', '/'); - if (pkg.endsWith("*")) { - pkg += "*"; + + enum = excludePackageNames.elements(); + while (enum.hasMoreElements()) { + PackageName p = (PackageName) enum.nextElement(); + String pkg = p.getName().replace('.', '/'); + if (pkg.endsWith("*")) { + pkg += "*"; + } + ps.createExclude().setName(pkg); } + - fs.createExclude().setName(pkg); - } - - PrintWriter packageListWriter = null; - try { - if (useExternalFile) { - tmpList = fileUtils.createTempFile("javadoc", "", null); - toExecute.createArgument() - .setValue("@" + tmpList.getAbsolutePath()); - packageListWriter = new PrintWriter(new FileWriter(tmpList)); + String[] pathElements = sourcePath.list(); + for (int i = 0; i < pathElements.length; i++) { + DirSet ds = new DirSet(); + ds.setDefaultexcludes(useDefaultExcludes); + ds.setDir(new File(pathElements[i])); + ds.createPatternSet().addConfiguredPatternset(ps); + dirSets.addElement(ds); } + } - for (int j = 0; j < list.length; j++) { - File source = project.resolveFile(list[j]); - fs.setDir(source); - - DirectoryScanner ds = fs.getDirectoryScanner(project); - String[] packageDirs = ds.getIncludedDirectories(); - - for (int i = 0; i < packageDirs.length; i++) { - File pd = new File(source, packageDirs[i]); - String[] files = pd.list(new FilenameFilter () { - public boolean accept(File dir1, String name) { - if (name.endsWith(".java")) { - return true; - } - return false; // ignore dirs - } - }); - - if (files.length > 0) { - String pkgDir = - packageDirs[i].replace('/', '.').replace('\\', '.'); - if (!addedPackages.contains(pkgDir)) { - if (useExternalFile) { - packageListWriter.println(pkgDir); - } else { - toExecute.createArgument().setValue(pkgDir); + Enumeration enum = dirSets.elements(); + while (enum.hasMoreElements()) { + DirSet ds = (DirSet) enum.nextElement(); + File baseDir = ds.getDir(getProject()); + log("scanning " + baseDir + " for packages.", Project.MSG_DEBUG); + DirectoryScanner dsc = ds.getDirectoryScanner(getProject()); + String[] dirs = dsc.getIncludedDirectories(); + boolean containsPackages = false; + for (int i = 0; i < dirs.length; i++) { + // are there any java files in this directory? + 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; } - addedPackages.addElement(pkgDir); + return false; // ignore dirs } + }); + + if (files.length > 0) { + containsPackages = true; + String packageName = + dirs[i].replace(File.separatorChar, '.'); + if (!addedPackages.contains(packageName)) { + addedPackages.addElement(packageName); + pn.addElement(packageName); } } } - } catch (IOException ioex) { - throw new BuildException("Error creating temporary file", - ioex, location); - } finally { - if (packageListWriter != null) { - packageListWriter.close(); + if (containsPackages) { + sp.createPathElement().setLocation(baseDir); } } } diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java index f9e4de20a..97cc61e17 100644 --- a/src/main/org/apache/tools/ant/types/Path.java +++ b/src/main/org/apache/tools/ant/types/Path.java @@ -356,7 +356,7 @@ public class Path extends DataType implements Cloneable { // empty path return empty string if (list.length == 0) { - return ""; + return ""; } // path containing one or more elements diff --git a/xdocs/ant15_todo.xml b/xdocs/ant15_todo.xml index 0d98fd5ae..38ec69820 100644 --- a/xdocs/ant15_todo.xml +++ b/xdocs/ant15_todo.xml @@ -72,13 +72,6 @@
- - - - - - -
Steve + any other help he can get
Make javadoc a real directory based taskStefan, others welcome