ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/types/optional/depend ClassfileSet.java DependScanner.java
Date Thu, 04 Apr 2002 13:59:19 GMT
conor       02/04/04 05:59:19

  Modified:    src/main/org/apache/tools/ant/types/optional/depend
                        ClassfileSet.java DependScanner.java
  Log:
  Fix up operation of classfileset to behave more like a normal fileset in
  terms of what it returns. Also, do not ignore the <include> elements, etc
  but allow it to control the basic set of classes which are examined.
  
  Revision  Changes    Path
  1.7       +6 -1      jakarta-ant/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java
  
  Index: ClassfileSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/optional/depend/ClassfileSet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -u -r1.6 -r1.7
  --- ClassfileSet.java	15 Mar 2002 16:21:19 -0000	1.6
  +++ ClassfileSet.java	4 Apr 2002 13:59:19 -0000	1.7
  @@ -138,7 +138,12 @@
        * @return a dependency scanner.
        */
       public DirectoryScanner getDirectoryScanner(Project p) {
  -        DependScanner scanner = new DependScanner();
  +        if (isReference()) {
  +            return getRef(p).getDirectoryScanner(p);
  +        }
  +
  +        DirectoryScanner parentScanner = super.getDirectoryScanner(p);
  +        DependScanner scanner = new DependScanner(parentScanner);
           scanner.setBasedir(getDir(p));
           scanner.setRootClasses(rootClasses);
           scanner.scan();
  
  
  
  1.9       +30 -9     jakarta-ant/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java
  
  Index: DependScanner.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/optional/depend/DependScanner.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -w -u -r1.8 -r1.9
  --- DependScanner.java	18 Mar 2002 02:44:30 -0000	1.8
  +++ DependScanner.java	4 Apr 2002 13:59:19 -0000	1.9
  @@ -56,6 +56,7 @@
   import java.io.File;
   import java.util.Vector;
   import java.util.Enumeration;
  +import java.util.Hashtable;
   import org.apache.tools.ant.util.depend.DependencyAnalyzer;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.BuildException;
  @@ -92,6 +93,17 @@
       private Vector included;
       
       /**
  +     * The parent scanner which gives the basic set of files. Only files which 
  +     * are in this set and which can be reached from a root class will end
  +     * up being included in the result set
  +     */
  +    private DirectoryScanner parentScanner;
  +    
  +    public DependScanner(DirectoryScanner parentScanner) {
  +        this.parentScanner = parentScanner;
  +    }
  +    
  +    /**
        * Sets the basedir for scanning. This is the directory that is scanned
        * recursively.
        *
  @@ -126,12 +138,7 @@
           int count = included.size();
           String[] files = new String[count];
           for (int i = 0; i < count; i++) {
  -            String classname = (String)included.elementAt(i); 
  -            String filename = classname.replace('.', File.separatorChar);
  -            filename = filename + ".class";
  -            File file = new File(basedir, filename); 
  -            files[i] =  file.getPath();
  -            //System.err.println("  " + files[i]);
  +            files[i] = (String)included.elementAt(i); 
           }
           return files;
       }
  @@ -142,6 +149,7 @@
        * @exception IllegalStateException when basedir was set incorrecly
        */
       public void scan() throws IllegalStateException {
  +        included = new Vector();
           String analyzerClassName = DEFAULT_ANALYZER_CLASS;
           DependencyAnalyzer analyzer = null;
           try {
  @@ -154,14 +162,27 @@
           analyzer.addClassPath(new Path(null, basedir.getPath()));
           
           for (Enumeration e = rootClasses.elements(); e.hasMoreElements(); ) {
  -            analyzer.addRootClass((String)e.nextElement());
  +            String rootClass = (String)e.nextElement();
  +            analyzer.addRootClass(rootClass);
           }
   
           Enumeration e = analyzer.getClassDependencies();
   
  -        included.removeAllElements();
  +        String[] parentFiles = parentScanner.getIncludedFiles();
  +        Hashtable parentSet = new Hashtable();
  +        for (int i = 0; i < parentFiles.length; ++i) {
  +            parentSet.put(parentFiles[i], parentFiles[i]);
  +        }
  +
           while (e.hasMoreElements()) {
  -            included.addElement(e.nextElement());
  +            String classname = (String)e.nextElement();
  +            String filename = classname.replace('.', File.separatorChar);
  +            filename = filename + ".class";
  +            File depFile = new File(basedir, filename);
  +            if (depFile.exists() && parentSet.containsKey(filename)) {
  +                // This is included
  +                included.addElement(filename);
  +            }
           }
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message