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/util/depend/bcel AncestorAnalyzer.java FullAnalyzer.java
Date Fri, 05 Apr 2002 15:57:33 GMT
conor       02/04/05 07:57:33

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/ejb
                        EjbJar.java GenericDeploymentTool.java
               src/main/org/apache/tools/ant/util/depend/bcel
                        AncestorAnalyzer.java FullAnalyzer.java
  Log:
  Allow ejbjar dependency including behaviour to be controlled
  
  Revision  Changes    Path
  1.32      +14 -0     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java
  
  Index: EjbJar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -w -u -r1.31 -r1.32
  --- EjbJar.java	5 Apr 2002 14:37:45 -0000	1.31
  +++ EjbJar.java	5 Apr 2002 15:57:32 -0000	1.32
  @@ -199,6 +199,11 @@
            * The Manifest file
            */
           public File manifest;
  +        
  +        /**
  +         * The dependency analyzer to use to add additional classes to the jar
  +         */
  +        public String analyzer;
       }
   
       /**
  @@ -442,6 +447,15 @@
           config.descriptorDir = inDir;
       }
   
  +    /**
  +     * Set the analyzer to use when adding in dependencies to the jar
  +     *
  +     * @param analyzer the name of the dependency analyzer or a class.
  +     */
  +    public void setDependency(String analyzer) {
  +        config.analyzer = analyzer;
  +    }
  +    
       /**
        * Set the base name of the EJB jar that is to be created if it is not
        * to be determined from the name of the deployment descriptor files.
  
  
  
  1.35      +58 -14    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
  
  Index: GenericDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -w -u -r1.34 -r1.35
  --- GenericDeploymentTool.java	20 Mar 2002 13:47:05 -0000	1.34
  +++ GenericDeploymentTool.java	5 Apr 2002 15:57:32 -0000	1.35
  @@ -103,7 +103,21 @@
       /** Name for EJB Deployment descriptor within EJB jars */
       protected static final String EJB_DD    = "ejb-jar.xml";
   
  -    public static final String DEFAULT_ANALYZER_CLASS
  +    /** A dependency analyzer name to find ancestor classes */
  +    public static final String ANALYZER_SUPER = "super";
  +    /** A dependency analyzer name to find all related classes */
  +    public static final String ANALYZER_FULL = "full";
  +    /** A dependency analyzer name for no analyzer */
  +    public static final String ANALYZER_NONE = "none";
  +
  +    /** The default analyzer */
  +    public static final String DEFAULT_ANALYZER = ANALYZER_SUPER;
  +
  +    /** The analyzer class for the super analyzer */    
  +    public static final String ANALYZER_CLASS_SUPER
  +        = "org.apache.tools.ant.util.depend.bcel.AncestorAnalyzer";
  +    /** The analyzer class for the super analyzer */    
  +    public static final String ANALYZER_CLASS_FULL
           = "org.apache.tools.ant.util.depend.bcel.FullAnalyzer";
   
       /**
  @@ -151,14 +165,6 @@
       private DependencyAnalyzer dependencyAnalyzer;
   
       public GenericDeploymentTool() {
  -        String analyzerClassName = DEFAULT_ANALYZER_CLASS;
  -        try {
  -            Class analyzerClass = Class.forName(analyzerClassName);
  -            dependencyAnalyzer = (DependencyAnalyzer)analyzerClass.newInstance();
  -        } catch (Exception e) {
  -            task.log("Unable to load dependency analyzer: " + analyzerClassName,
  -                Project.MSG_VERBOSE);
  -        }
       }
   
   
  @@ -172,7 +178,7 @@
       }
   
       /**
  -     * Get the desitination directory.
  +     * Get the destination directory.
        *
        * @return the destination directory into which EJB jars are to be written
        */
  @@ -285,6 +291,42 @@
           return getTask().getLocation();
       }
   
  +    private void createAnalyzer() {
  +        String analyzer = config.analyzer;
  +        if (analyzer == null) {
  +            analyzer = DEFAULT_ANALYZER;
  +        }
  +        
  +        if (analyzer.equals(ANALYZER_NONE)) {
  +            return;
  +        }
  +        
  +        String analyzerClassName = null;
  +        if (analyzer.equals(ANALYZER_SUPER)) {
  +            analyzerClassName = ANALYZER_CLASS_SUPER;
  +        } else if (analyzer.equals(ANALYZER_FULL)) {
  +            analyzerClassName = ANALYZER_CLASS_FULL;
  +        } else {
  +            analyzerClassName = analyzer;
  +        }
  +        
  +        try {
  +            Class analyzerClass = Class.forName(analyzerClassName);
  +            dependencyAnalyzer = (DependencyAnalyzer)analyzerClass.newInstance();
  +            dependencyAnalyzer.addClassPath(new Path(task.getProject(),
  +                config.srcDir.getPath()));
  +            dependencyAnalyzer.addClassPath(config.classpath);
  +        } catch (NoClassDefFoundError e) {
  +            dependencyAnalyzer = null;
  +            task.log("Unable to load dependency analyzer: " + analyzerClassName,
  +                Project.MSG_WARN);
  +        } catch (Exception e) {
  +            dependencyAnalyzer = null;
  +            task.log("Unable to load dependency analyzer: " + analyzerClassName,
  +                Project.MSG_WARN);
  +        }
  +    }
  +    
   
       /**
        * Configure this tool for use in the ejbjar task.
  @@ -293,10 +335,8 @@
        */
       public void configure(EjbJar.Config config) {
           this.config = config;
  -        dependencyAnalyzer.addClassPath(new Path(task.getProject(),
  -            config.srcDir.getPath()));
  -        dependencyAnalyzer.addClassPath(config.classpath);
   
  +        createAnalyzer();
           classpathLoader = null;
       }
   
  @@ -814,6 +854,10 @@
       protected void checkAndAddDependants(Hashtable checkEntries)
           throws BuildException {
   
  +        if (dependencyAnalyzer == null) {
  +            return;
  +        }
  +        
           dependencyAnalyzer.reset();
   
           Iterator i = checkEntries.keySet().iterator();
  
  
  
  1.4       +10 -0     jakarta-ant/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java
  
  Index: AncestorAnalyzer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -u -r1.3 -r1.4
  --- AncestorAnalyzer.java	27 Mar 2002 10:21:30 -0000	1.3
  +++ AncestorAnalyzer.java	5 Apr 2002 15:57:33 -0000	1.4
  @@ -68,6 +68,16 @@
    * @author Conor MacNeill
    */
   public class AncestorAnalyzer extends AbstractAnalyzer {
  +    
  +    public AncestorAnalyzer() {
  +        // force BCEL classes to load now
  +        try {
  +            ClassParser parser = new ClassParser("force");
  +        } catch (IOException e) {
  +            // ignore
  +        }
  +    }
  +    
       /**
        * Determine the dependencies of the configured root classes.
        *
  
  
  
  1.4       +9 -0      jakarta-ant/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java
  
  Index: FullAnalyzer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -w -u -r1.3 -r1.4
  --- FullAnalyzer.java	27 Mar 2002 10:21:30 -0000	1.3
  +++ FullAnalyzer.java	5 Apr 2002 15:57:33 -0000	1.4
  @@ -69,6 +69,15 @@
    * @author <a href="mailto:hengels@innovidata.com">Holger Engels</a>
    */
   public class FullAnalyzer extends AbstractAnalyzer {
  +    public FullAnalyzer() {
  +        // force BCEL classes to load now
  +        try {
  +            ClassParser parser = new ClassParser("force");
  +        } catch (IOException e) {
  +            // ignore
  +        }
  +    }
  +    
       /**
        * Determine the dependencies of the configured root classes.
        *
  
  
  

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