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, 29 Nov 2001 13:47:39 GMT
conor       01/11/29 05:47:38

  Modified:    src/main/org/apache/tools/ant/types/optional/depend
                        ClassfileSet.java DependScanner.java
  Log:
  Additional functionality for classfileset.
  
  Change baseclass paramater to rootclass and make it use dot notation for
  the classname rather than making it a file.
  
  Also allow multiple nested <root> elements to define more than one root
  class
  
  Example:
    <classfileset dir="build/classes" id="classes">
      <root classname="org.apache.tools.ant.Main"/>
      <root classname="org.apache.tools.ant.taskdefs.optional.ejb.EjbJar"/>
    </classfileset>
  
  Revision  Changes    Path
  1.2       +23 -9     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.1
  retrieving revision 1.2
  diff -u -w -u -r1.1 -r1.2
  --- ClassfileSet.java	2001/11/08 12:58:20	1.1
  +++ ClassfileSet.java	2001/11/29 13:47:38	1.2
  @@ -55,6 +55,8 @@
   
   import java.io.File;
   import java.util.Stack;
  +import java.util.List;
  +import java.util.ArrayList;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Project;
  @@ -72,16 +74,24 @@
    * @author <a href="mailto:hengels@innovidata.com">Holger Engels</a>
    */
   public class ClassfileSet extends FileSet {
  -    private File baseClass = null;
  +    private List rootClasses = new ArrayList();
   
  -    /**
  -     * Set the directory for the fileset.  Prevents both "dir" and "src"
  -     * from being specified.
  -     */
  -    public void setBaseClass(File baseClass)
  +    static public class ClassRoot {
  +        private String rootClass;
  +        
  +        public void setClassname(String name) {
  +            this.rootClass = name;
  +        }
  +        
  +        public String getClassname() {
  +            return rootClass;
  +        }
  +    }
  +    
  +    public void setRootClass(String rootClass)
           throws BuildException
       {
  -        this.baseClass = baseClass;
  +        rootClasses.add(rootClass);
       }
   
       public void setDir(File dir) throws BuildException {
  @@ -95,8 +105,12 @@
       public DirectoryScanner getDirectoryScanner(Project p) {
           DependScanner scanner = new DependScanner();
           scanner.setBasedir(getDir(p));
  -        scanner.setBaseClass(baseClass);
  +        scanner.setRootClasses(rootClasses);
           scanner.scan();
           return scanner;
       }    
  +    
  +    public void addConfiguredRoot(ClassRoot root) {
  +        rootClasses.add(root.getClassname());    
  +    }
   }
  
  
  
  1.3       +36 -32    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.2
  retrieving revision 1.3
  diff -u -w -u -r1.2 -r1.3
  --- DependScanner.java	2001/11/29 13:08:33	1.2
  +++ DependScanner.java	2001/11/29 13:47:38	1.3
  @@ -72,6 +72,8 @@
       File baseClass;
       List included = new LinkedList();
   
  +    private List rootClasses;
  +    
       /**
        * Sets the basedir for scanning. This is the directory that is scanned
        * recursively. 
  @@ -103,8 +105,8 @@
        *
        * @param domain the domain
        */
  -    public void setBaseClass(File baseClass) {
  -        this.baseClass = baseClass;
  +    public void setRootClasses(List rootClasses) {
  +        this.rootClasses = rootClasses;
       }
   
       /**
  @@ -129,20 +131,21 @@
        */
       public void scan() {
           Dependencies visitor = new Dependencies();
  +        
           Set set = new TreeSet();
  -        Set newSet = new HashSet();
  +
           final String base;
  -        String start;
           try {
               base = basedir.getCanonicalPath() + File.separator;
  -            start = baseClass.getCanonicalPath();
           }
           catch (Exception e) {
               throw new IllegalArgumentException(e.getMessage());
           }
   
  -        start = start.substring(base.length(), start.length() - ".class".length()).replace(File.separatorChar,
'/');
  -        System.err.println("start: " + start);
  +        for (Iterator rootClassIterator = rootClasses.iterator(); rootClassIterator.hasNext();)
{
  +            Set newSet = new HashSet();
  +            String start = (String)rootClassIterator.next();
  +            start = start.replace('.', '/');
   
           newSet.add(start);
           set.add(start);
  @@ -174,6 +177,7 @@
               set.addAll(newSet);
           }
           while (newSet.size() > 0);
  +        }
   
           included.clear();
           included.addAll(set);
  
  
  

--
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