ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gle...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Javadoc.java
Date Wed, 24 Jan 2001 16:56:47 GMT
glennm      01/01/24 08:56:47

  Modified:    src/main/org/apache/tools/ant/taskdefs Javadoc.java
  Log:
  Resolving package names now occurs with the
  use of a private FileSet.  This provides
  the use of the default excludes patterns,
  which include **/CVS/**, preventing any
  .java files in a CVS/Base directory from
  being included.
  
  Just in case someone does ever have a
  package named blah.CVS, I added the
  "defaultexcludes" attribute.
  
  Revision  Changes    Path
  1.43      +46 -68    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  
  Index: Javadoc.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- Javadoc.java	2001/01/22 20:55:32	1.42
  +++ Javadoc.java	2001/01/24 16:56:46	1.43
  @@ -59,9 +59,7 @@
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
  -import org.apache.tools.ant.types.Commandline;
  -import org.apache.tools.ant.types.Path;
  -import org.apache.tools.ant.types.Reference;
  +import org.apache.tools.ant.types.*;
   
   /**
    * This task makes it easy to generate Javadoc documentation for a collection
  @@ -205,7 +203,19 @@
       private String packageList = null;
       private Vector links = new Vector(2);
       private Vector groups = new Vector(2);
  +	private boolean useDefaultExcludes = true;
   
  +    /**
  +     * Sets whether default exclusions should be used or not.
  +     *
  +     * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions 
  +     *                           should be used, "false"|"off"|"no" when they
  +     *                           shouldn't be used.
  +     */
  +    public void setDefaultexcludes(boolean useDefaultExcludes) {
  +       this.useDefaultExcludes = useDefaultExcludes;
  +    }
  +
       public void setMaxmemory(String max){
           if(javadoc1){
               cmd.createArgument().setValue("-J-mx" + max);
  @@ -769,36 +779,49 @@
           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 += "*";
  +            }
  +
  +            fs.createInclude().setName(pkg);
  +        } // while
  +
           for (int j=0; j<list.length; j++) {
               File source = project.resolveFile(list[j]);
  -            Vector foundPackages = findPackages(source);
  +            fs.setDir(source);
   
  -            Enumeration e = foundPackages.elements();
  -            while (e.hasMoreElements()) {
  -                String pack = (String) e.nextElement();
  -                for (int i = 0; i < packages.size(); i++) {
  -                    if (matches(pack, (String) packages.elementAt(i))) {
  -                        if (!addedPackages.contains(pack)) {
  -                            toExecute.createArgument().setValue(pack);
  -                            addedPackages.addElement(pack);
  +            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;
                           }
  -                        break;
  +                        return false;	// ignore dirs
  +                    }
  +                });
  +
  +                if (files.length > 0) {
  +                    String pkgDir = packageDirs[i].replace('/','.').replace('\\','.');
  +                    if (!addedPackages.contains(pkgDir)) {
  +                        toExecute.createArgument().setValue(pkgDir);
  +                        addedPackages.addElement(pkgDir);
                       }
                   }
               }
           }
       }
   
  -    /**
  -     * Implements the pattern matching. For now it's only able to
  -     * guarantee that "aaa.bbb.ccc" matches "aaa.*" and "aaa.bbb.*"
  -     * FIXME: this code needs much improvement.
  -     */
  -    private boolean matches(String string, String pattern) {
  -        return string.startsWith(pattern.substring(0, pattern.length() - 2));
  -    }
  -
  -
       private class JavadocOutputStream extends LogOutputStream {
           JavadocOutputStream(int level) {
               super(Javadoc.this, level);
  @@ -837,49 +860,4 @@
           }
       }
   
  -    protected Vector findPackages(File srcDir) {
  -        Vector foundPkgs = new Vector();
  -
  -        if ((srcDir != null) && (srcDir.isDirectory())) {
  -            scan(srcDir, "", foundPkgs);
  -        }
  -
  -        return foundPkgs;
  -    }
  -
  -    protected void scan(File srcDir, String vpath, Vector pkgs) {
  -        foundJavaFile = false;
  -        File dir = new File(srcDir, vpath);
  -
  -        if (!dir.isDirectory()) {
  -            return;
  -        }
  -    
  -        String[] files = dir.list(new FilenameFilter () {
  -            public boolean accept(File dir1, String name) {
  -                if (name.endsWith(".java")) {
  -                    foundJavaFile = true;
  -                    return false;
  -                }
  -                File d = new File(dir1, name);
  -                if (d.isDirectory() 
  -                    && d.getName().indexOf("-") == -1) {
  -                        return true;
  -                    }
  -                return false;
  -            }
  -        });
  -        
  -        if (foundJavaFile && vpath.length() > 0) {
  -            String newPkg = vpath.substring(1).replace(File.separatorChar, '.');
  -            if (!pkgs.contains(newPkg)) {
  -                pkgs.addElement(newPkg);
  -            }
  -        }
  -
  -        for (int i=0; i<files.length; i++) {
  -            scan(srcDir, vpath + File.separator + files[i], pkgs);
  -        }
  -        return;
  -    }
   }
  
  
  

Mime
View raw message