ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant ProjectHelper.java
Date Fri, 27 Dec 2002 18:06:23 GMT
costin      2002/12/27 10:06:23

  Modified:    src/main/org/apache/tools/ant ProjectHelper.java
  Log:
  Add "importStack" that will allow import to keep track of loops.
  If importStack has more than one element, ProjectHelper implementations
  should know they are inside an import. This can also be used to
  display more informative error messages ( i.e. the include path to
  a file with errors ).
  
  Removed the SAX2 Attributes and deprecate the SAX1 Attributes methods.
  I made a small change to RuntimeConfigurable to make it less SAX-dependent,
  ProjectHelper2 will just use a simple Hashtable and RC/ProjectHelper will
  be SAX-independent ( except the deprecated methods ). This would allow
  better programmatic use of ant and maybe a DOM ProjectHelper.
  
  One interesting note: while SAX is faster, using DOM or caching the
  UE/RC tree will greatly optimize <antCall>, where the same file
  is parsed on each call.
  
  Revision  Changes    Path
  1.91      +35 -39    jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java
  
  Index: ProjectHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- ProjectHelper.java	13 Dec 2002 00:52:18 -0000	1.90
  +++ ProjectHelper.java	27 Dec 2002 18:06:23 -0000	1.91
  @@ -115,6 +115,7 @@
       public static void configureProject(Project project, File buildFile) 
           throws BuildException {
           ProjectHelper helper = ProjectHelper.getProjectHelper();
  +        project.addReference("ant.projectHelper", helper);
           helper.parse(project, buildFile);
       }
   
  @@ -122,6 +123,38 @@
       public ProjectHelper() {
       }
   
  +    // -------------------- Common properties  --------------------
  +    // The following properties are required by import ( and other tasks
  +    // that read build files using ProjectHelper ).
  +
  +    // A project helper may process multiple files. We'll keep track
  +    // of them - to avoid loops and to allow caching. The caching will
  +    // probably accelerate things like <antCall>.
  +    // The key is the absolute file, the value is a processed tree.
  +    // Since the tree is composed of UE and RC - it can be reused !
  +    // protected Hashtable processedFiles=new Hashtable();
  +
  +    protected Vector importStack=new Vector();
  +
  +    // Temporary - until we figure a better API
  +    /** EXPERIMENTAL WILL_CHANGE
  +     *
  +     */
  +//    public Hashtable getProcessedFiles() {
  +//        return processedFiles;
  +//    }
  +
  +    /** EXPERIMENTAL WILL_CHANGE
  +     *  Import stack.
  +     *  Used to keep track of imported files. Error reporting should
  +     *  display the import path.
  +     */
  +    public Vector getImportStack() {
  +        return importStack;
  +    }
  +
  +
  +    // --------------------  Parse method  --------------------
       /**
        * Parses the project file, configuring the project as it goes.
        *
  @@ -285,7 +318,8 @@
        *               Must not be <code>null</code>.
        * @param project The project containing the target. 
        *                Must not be <code>null</code>.
  -     * 
  +     *
  +     * @deprecated
        * @exception BuildException if any of the attributes can't be handled by
        *                           the target
        */
  @@ -311,44 +345,6 @@
               } catch (BuildException be) {
                   // id attribute must be set externally
                   if (!attrs.getName(i).equals("id")) {
  -                    throw be;
  -                }
  -            }
  -        }
  -    }
  -
  -    /** Configure a component using SAX2 attributes.
  -     */
  -    public static void configure( Object target, Attributes attrs, Project project )
  -        throws BuildException
  -    {
  -        if (target instanceof TaskAdapter) {
  -            target = ((TaskAdapter) target).getProxy();
  -        }
  -
  -        IntrospectionHelper ih =
  -            IntrospectionHelper.getHelper(target.getClass());
  -
  -        // Why ???
  -        project.addBuildListener(ih);
  -
  -        for (int i = 0; i < attrs.getLength(); i++) {
  -            // reflect these into the target
  -            String attValue=attrs.getValue(i);
  -
  -            // XXX ADD SPECIAL CASE FOR ${property} - don't convert to string
  -            // and support ARRAYS.
  -            // reflect these into the target
  -            //String value = replaceProperties(attValue);
  -            String value = replaceProperties(project, attValue,
  -                                           project.getProperties());
  -            try {
  -                ih.setAttribute(project, target,
  -                                attrs.getQName(i).toLowerCase(Locale.US), value);
  -
  -            } catch (BuildException be) {
  -                // id attribute must be set externally
  -                if (!attrs.getQName(i).equals("id")) {
                       throw be;
                   }
               }
  
  
  

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