ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jose Alberto Fernandez <j_a_fernan...@yahoo.com>
Subject Re: cvs commit: jakarta-ant/src/main/org/apache/tools/ant Project.java RuntimeConfigurable.java Target.java Task.java UnknownElement.java
Date Fri, 14 Dec 2001 11:42:15 GMT
Don't forget <typedef>s. You have to do the same thing
there.

Jose Alberto

 --- bodewig@apache.org wrote: > bodewig     01/12/14
03:15:42
> 
>   Modified:    src/main/org/apache/tools/ant
> Project.java
>                         RuntimeConfigurable.java
> Target.java Task.java
>                         UnknownElement.java
>   Log:
>   Fix taskdef testcase in a rather hacky way.  This
> one doesn't address
>   child elements of user defined tasks that override
> built-in tasks.
>   
>   Revision  Changes    Path
>   1.89      +48 -3    
>
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.88
>   retrieving revision 1.89
>   diff -u -r1.88 -r1.89
>   --- Project.java	2001/12/13 11:53:43	1.88
>   +++ Project.java	2001/12/14 11:15:42	1.89
>   @@ -114,6 +114,7 @@
>        private String defaultTarget;
>        private Hashtable dataClassDefinitions = new
> Hashtable();
>        private Hashtable taskClassDefinitions = new
> Hashtable();
>   +    private Hashtable createdTasks = new
> Hashtable();
>        private Hashtable targets = new Hashtable();
>        private FilterSet globalFilterSet = new
> FilterSet();
>        private FilterSetCollection globalFilters =
> new FilterSetCollection(globalFilterSet);
>   @@ -589,9 +590,18 @@
>         * conditions, that will cause the task
> execution to fail.
>         */
>        public void addTaskDefinition(String
> taskName, Class taskClass) throws BuildException {
>   -        if (null !=
> taskClassDefinitions.get(taskName)) {
>   -            log("Trying to override old
> definition of task "+taskName, 
>   -                MSG_WARN);
>   +        Class old =
> (Class)taskClassDefinitions.get(taskName);
>   +        if (null != old) {
>   +            if (old.equals(taskClass)) {
>   +                log("Ignoring override for task "
> + taskName 
>   +                    + ", it is already defined by
> the same class.", 
>   +                    MSG_VERBOSE);
>   +                return;
>   +            } else {
>   +                log("Trying to override old
> definition of task "+taskName, 
>   +                    MSG_WARN);
>   +                invalidateCreatedTasks(taskName);
>   +            }
>            }
>    
>            String msg = " +User task: " + taskName +
> "     " + taskClass.getName();
>   @@ -751,11 +761,46 @@
>    
>                String msg = "   +Task: " + taskType;
>                log (msg, MSG_DEBUG);
>   +            addCreatedTask(taskType, task);
>                return task;
>            } catch (Throwable t) {
>                String msg = "Could not create task
> of type: "
>                     + taskType + " due to " + t;
>                throw new BuildException(msg, t);
>   +        }
>   +    }
>   +
>   +    /**
>   +     * Keep a record of all tasks that have been
> created so that they
>   +     * can be invalidated if a taskdef overrides
> the definition.
>   +     */
>   +    private void addCreatedTask(String type, Task
> task) {
>   +        synchronized (createdTasks) {
>   +            Vector v = (Vector)
> createdTasks.get(type);
>   +            if (v == null) {
>   +                v = new Vector();
>   +                createdTasks.put(type, v);
>   +            }
>   +            v.addElement(task);
>   +        }
>   +    }
>   +
>   +    /**
>   +     * Mark tasks as invalid which no longer are
> of the correct type
>   +     * for a given taskname.
>   +     */
>   +    private void invalidateCreatedTasks(String
> type) {
>   +        synchronized (createdTasks) {
>   +            Vector v = (Vector)
> createdTasks.get(type);
>   +            if (v != null) {
>   +                Enumeration enum = v.elements();
>   +                while (enum.hasMoreElements()) {
>   +                    Task t = (Task)
> enum.nextElement();
>   +                    t.markInvalid();
>   +                }
>   +                v.removeAllElements();
>   +                createdTasks.remove(type);
>   +            }
>            }
>        }
>    
>   
>   
>   
>   1.11      +8 -2     
>
jakarta-ant/src/main/org/apache/tools/ant/RuntimeConfigurable.java
>   
>   Index: RuntimeConfigurable.java
>  
>
===================================================================
>   RCS file:
>
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/RuntimeConfigurable.java,v
>   retrieving revision 1.10
>   retrieving revision 1.11
>   diff -u -r1.10 -r1.11
>   --- RuntimeConfigurable.java	2001/11/27 18:04:51
> 1.10
>   +++ RuntimeConfigurable.java	2001/12/14 11:15:42
> 1.11
>   @@ -138,7 +138,7 @@
>         * Configure the wrapped element and all
> children.
>         */
>        public void maybeConfigure(Project p) throws
> BuildException {
>   -    String id = null;
>   +        String id = null;
>    
>            if (attributes != null) {
>               
> ProjectHelper.configure(wrappedObject, attributes,
> p);
>   @@ -152,7 +152,13 @@
>            Enumeration enum = children.elements();
>            while (enum.hasMoreElements()) {
>                RuntimeConfigurable child =
> (RuntimeConfigurable) enum.nextElement();
>   -            child.maybeConfigure(p);
>   +            if (child.wrappedObject instanceof
> Task) {
>   +                Task childTask = (Task)
> child.wrappedObject;
>   +               
> childTask.setRuntimeConfigurableWrapper(child);
>   +                childTask.maybeConfigure();
>   +            } else {
>   +                child.maybeConfigure(p);
>   +            }
>                ProjectHelper.storeChild(p,
> wrappedObject, child.wrappedObject,
> child.getElementTag().toLowerCase(Locale.US));
>            }
>    
>   
>   
>   
>   1.30      +1 -1     
>
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.29
>   retrieving revision 1.30
>   diff -u -r1.29 -r1.30
>   --- Target.java	2001/12/12 09:17:36	1.29
>   +++ Target.java	2001/12/14 11:15:42	1.30
>   @@ -210,7 +210,7 @@
>            }
>        }
>        
>   -    void replaceChild(UnknownElement el, Object
> o) {
> 
=== message truncated === 

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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