ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant Project.java ProjectHelper.java Target.java
Date Fri, 08 Jun 2001 10:11:34 GMT
bodewig     01/06/08 03:11:34

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant Project.java
                        ProjectHelper.java Target.java
  Log:
  Allow data types to appear inside of targets.
  
  Revision  Changes    Path
  1.112     +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- WHATSNEW	2001/06/07 11:41:57	1.111
  +++ WHATSNEW	2001/06/08 10:11:20	1.112
  @@ -73,6 +73,8 @@
     temporary file for sourcefile and package names - helps to defeat
     command line length limitations.
   
  +* Data types like <path> can now be defined inside of <target>s
  +
   Fixed bugs:
   -----------
   
  
  
  
  1.58      +1 -0      jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- Project.java	2001/05/08 09:35:28	1.57
  +++ Project.java	2001/06/08 10:11:25	1.58
  @@ -1034,6 +1034,7 @@
       }
   
       public void addReference(String name, Object value) {
  +        log("Adding reference: " + name + " -> " + value, MSG_DEBUG);
           references.put(name,value);
       }
   
  
  
  
  1.51      +20 -3     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.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- ProjectHelper.java	2001/05/01 07:50:15	1.50
  +++ ProjectHelper.java	2001/06/08 10:11:27	1.51
  @@ -430,7 +430,11 @@
           }
   
           public void startElement(String name, AttributeList attrs) throws SAXParseException
{
  -            new TaskHandler(this, target).init(name, attrs);
  +            if (project.getDataTypeDefinitions().get(name) != null) {
  +                new DataTypeHandler(this, target).init(name, attrs);
  +            } else {
  +                new TaskHandler(this, target).init(name, attrs);
  +            }
           }
       }
   
  @@ -570,10 +574,17 @@
        * Handler for all data types at global level.
        */
       private class DataTypeHandler extends AbstractHandler {
  +        private Target target;
           private Object element;
  +        private RuntimeConfigurable wrapper = null;
   
           public DataTypeHandler(DocumentHandler parentHandler) {
  +            this(parentHandler, null);
  +        }
  +
  +        public DataTypeHandler(DocumentHandler parentHandler, Target target) {
               super(parentHandler);
  +            this.target = target;
           }
   
           public void init(String propType, AttributeList attrs) throws SAXParseException
{
  @@ -584,7 +595,13 @@
                   }
                   
                   configureId(element, attrs);
  -                configure(element, attrs, project);
  +                if (target != null) {
  +                    wrapper = new RuntimeConfigurable(element);
  +                    wrapper.setAttributes(attrs);
  +                    target.addDataType(wrapper);
  +                } else {
  +                    configure(element, attrs, project);
  +                }
               } catch (BuildException exc) {
                   throw new SAXParseException(exc.getMessage(), locator, exc);
               }
  @@ -599,7 +616,7 @@
           }
   
           public void startElement(String name, AttributeList attrs) throws SAXParseException
{
  -            new NestedElementHandler(this, element, null).init(name, attrs);
  +            new NestedElementHandler(this, element, wrapper).init(name, attrs);
           }
       }
   
  
  
  
  1.18      +43 -24    jakarta-ant/src/main/org/apache/tools/ant/Target.java
  
  Index: Target.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Target.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Target.java	2001/01/18 02:50:32	1.17
  +++ Target.java	2001/06/08 10:11:28	1.18
  @@ -68,7 +68,7 @@
       private String ifCondition = "";
       private String unlessCondition = "";
       private Vector dependencies = new Vector(2);
  -    private Vector tasks = new Vector(5);
  +    private Vector children = new Vector(5);
       private Project project;
       private String description = null;
   
  @@ -99,15 +99,28 @@
       }
   
       public void addTask(Task task) {
  -        tasks.addElement(task);
  +        children.addElement(task);
       }
   
  -	/** 
  -	 * Get the current set of tasks to be executed by this target.
  -	 * 
  +    public void addDataType(RuntimeConfigurable r) {
  +        children.addElement(r);
  +    }
  +
  +    /** 
  +     * Get the current set of tasks to be executed by this target.
  +     * 
        * @return The current set of tasks.
  -	 */
  +     */
       public Task[] getTasks() {
  +        Vector tasks = new Vector(children.size());
  +        Enumeration enum = children.elements();
  +        while (enum.hasMoreElements()) {
  +            Object o = enum.nextElement();
  +            if (o instanceof Task) {
  +                tasks.addElement(o);
  +            }
  +        }
  +        
           Task[] retval = new Task[tasks.size()];
           tasks.copyInto(retval);
           return retval;
  @@ -143,25 +156,31 @@
   
       public void execute() throws BuildException {
           if (testIfCondition() && testUnlessCondition()) {
  -            Enumeration enum = tasks.elements();
  +            Enumeration enum = children.elements();
               while (enum.hasMoreElements()) {
  -                Task task = (Task) enum.nextElement();
  -
  -                try {
  -                    project.fireTaskStarted(task);
  -                    task.maybeConfigure();
  -                    task.execute();
  -                    project.fireTaskFinished(task, null);
  -                }
  -                catch(RuntimeException exc) {
  -                    if (exc instanceof BuildException) {
  -                        BuildException be = (BuildException) exc;
  -                        if (be.getLocation() == Location.UNKNOWN_LOCATION) {
  -                            be.setLocation(task.getLocation());
  +                Object o = enum.nextElement();
  +                if (o instanceof Task) {
  +                    Task task = (Task) o;
  +                    
  +                    try {
  +                        project.fireTaskStarted(task);
  +                        task.maybeConfigure();
  +                        task.execute();
  +                        project.fireTaskFinished(task, null);
  +                    }
  +                    catch(RuntimeException exc) {
  +                        if (exc instanceof BuildException) {
  +                            BuildException be = (BuildException) exc;
  +                            if (be.getLocation() == Location.UNKNOWN_LOCATION) {
  +                                be.setLocation(task.getLocation());
  +                            }
                           }
  +                        project.fireTaskFinished(task, exc);
  +                        throw exc;
                       }
  -                    project.fireTaskFinished(task, exc);
  -                    throw exc;
  +                } else {
  +                    RuntimeConfigurable r = (RuntimeConfigurable) o;
  +                    r.maybeConfigure(project);
                   }
               }
           } else if (!testIfCondition()) {
  @@ -175,8 +194,8 @@
   
       void replaceTask(UnknownElement el, Task t) {
           int index = -1;
  -        while ((index = tasks.indexOf(el)) >= 0) {
  -            tasks.setElementAt(t, index);
  +        while ((index = children.indexOf(el)) >= 0) {
  +            children.setElementAt(t, index);
           }
       }
   
  
  
  

Mime
View raw message