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/proposal/mutant/src/java/common/org/apache/ant/common/antlib AntLibFactory.java StandardLibFactory.java
Date Tue, 05 Feb 2002 14:13:57 GMT
conor       02/02/05 06:13:57

  Modified:    proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution
                        ExecutionFrame.java
               proposal/mutant/src/java/antlibs/ant1compat antlib.xml
               proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant
                        Ant1Factory.java
               proposal/mutant/src/java/common/org/apache/ant/common/antlib
                        AntLibFactory.java StandardLibFactory.java
  Log:
  Mutant can now compile ant although it did require 3 minor changes to the
  Ant build file.
  
  Revision  Changes    Path
  1.7       +66 -32    jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionFrame.java
  
  Index: ExecutionFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionFrame.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -u -r1.6 -r1.7
  --- ExecutionFrame.java	5 Feb 2002 11:59:28 -0000	1.6
  +++ ExecutionFrame.java	5 Feb 2002 14:13:57 -0000	1.7
  @@ -240,14 +240,12 @@
        */
       protected void setInitialProperties(Map properties)
            throws ExecutionException {
  -        if (properties == null) {
  -            return;
  -        }
  -        for (Iterator i = properties.keySet().iterator(); i.hasNext(); ) {
  -            String name = (String)i.next();
  -            Object value = properties.get(name);
  -            setDataValue(name, value, false);
  +        if (properties != null) {
  +            addProperties(properties);
           }
  +
  +        // add in system properties
  +        addProperties(System.getProperties());
       }
   
       /**
  @@ -414,6 +412,21 @@
       }
   
       /**
  +     * Add a collection of properties to this frame
  +     *
  +     * @param properties the collection of property values, indexed by their
  +     *      names
  +     * @exception ExecutionException if the frame cannot be created.
  +     */
  +    protected void addProperties(Map properties) throws ExecutionException {
  +        for (Iterator i = properties.keySet().iterator(); i.hasNext(); ) {
  +            String name = (String)i.next();
  +            Object value = properties.get(name);
  +            setDataValue(name, value, false);
  +        }
  +    }
  +
  +    /**
        * Create a new frame for a given project
        *
        * @param project the project model the frame will deal with
  @@ -567,8 +580,11 @@
                   failureCause = e;
                   throw e;
               } catch (RuntimeException e) {
  -                failureCause = e;
  -                throw e;
  +                ExecutionException ee =
  +                    new ExecutionException(e.getClass().getName() + ": "
  +                     + e.getMessage(), e, model.getLocation());
  +                failureCause = ee;
  +                throw ee;
               } finally {
                   eventSupport.fireTaskFinished(model, failureCause);
               }
  @@ -597,8 +613,11 @@
               failureCause = e;
               throw e;
           } catch (RuntimeException e) {
  -            failureCause = e;
  -            throw e;
  +            ExecutionException ee =
  +                new ExecutionException(e.getClass().getName() + ": "
  +                 + e.getMessage(), e, target.getLocation());
  +            failureCause = ee;
  +            throw ee;
           } finally {
               eventSupport.fireTargetFinished(target, failureCause);
           }
  @@ -722,9 +741,12 @@
        *
        * @param element the object to be configured
        * @param model the BuildElement describing the object in the build file
  +     * @param factory Ant Library factory associated with the element being
  +     *      configured
        * @exception ExecutionException if the element cannot be configured
        */
  -    private void configureElement(Object element, BuildElement model)
  +    private void configureElement(AntLibFactory factory, Object element,
  +                                  BuildElement model)
            throws ExecutionException {
   
           Reflector reflector = getReflector(element.getClass());
  @@ -770,9 +792,11 @@
                   container.addTask(nestedContext.getTask());
               } else {
                   if (reflector.supportsNestedAdder(nestedElementName)) {
  -                    addNestedElement(reflector, element, nestedElementModel);
  +                    addNestedElement(factory, reflector, element,
  +                        nestedElementModel);
                   } else if (reflector.supportsNestedCreator(nestedElementName)) {
  -                    createNestedElement(reflector, element, nestedElementModel);
  +                    createNestedElement(factory, reflector, element,
  +                        nestedElementModel);
                   } else {
                       throw new ExecutionException(model.getType()
                            + " does not support the \"" + nestedElementName
  @@ -791,34 +815,41 @@
        * @param element the container object for which a nested element is
        *      required.
        * @param model the build model for the nestd element
  +     * @param factory Ant Library factory associated with the element
  +     *      creating the nested element
        * @exception ExecutionException if the nested element cannot be
        *      created.
        */
  -    private void createNestedElement(Reflector reflector, Object element,
  -                                     BuildElement model)
  +    private void createNestedElement(AntLibFactory factory, Reflector reflector,
  +                                     Object element, BuildElement model)
            throws ExecutionException {
           log("The use of create methods is deprecated - class: "
                + element.getClass().getName(), MessageLevel.MSG_INFO);
   
           String nestedElementName = model.getType();
  +        try {
           Object nestedElement
                = reflector.createElement(element, nestedElementName);
  -        try {
  +            factory.registerCreatedElement(nestedElement);
               if (nestedElement instanceof ExecutionComponent) {
  +                System.out.println("element is an execution component");
                   ExecutionComponent component
                        = (ExecutionComponent)nestedElement;
                   ExecutionContext context
                        = new ExecutionContext(this);
                   context.setModelElement(model);
                   component.init(context);
  -                configureElement(nestedElement, model);
  +                configureElement(factory, nestedElement, model);
                   component.validateComponent();
               } else {
  -                configureElement(nestedElement, model);
  +                configureElement(factory, nestedElement, model);
               }
           } catch (ExecutionException e) {
               e.setLocation(model.getLocation(), false);
               throw e;
  +        } catch (RuntimeException e) {
  +            throw new ExecutionException(e.getClass().getName() + ": "
  +                 + e.getMessage(), e, model.getLocation());
           }
       }
   
  @@ -830,10 +861,12 @@
        * @param element the container element in which the nested element will
        *      be created
        * @param model the model of the nested element
  +     * @param factory Ant Library factory associated with the element to
  +     *      which the attribute is to be added.
        * @exception ExecutionException if the nested element cannot be created
        */
  -    private void addNestedElement(Reflector reflector, Object element,
  -                                  BuildElement model)
  +    private void addNestedElement(AntLibFactory factory, Reflector reflector,
  +                                  Object element, BuildElement model)
            throws ExecutionException {
   
           String nestedElementName = model.getType();
  @@ -880,7 +913,7 @@
                       model.getLocation());
               }
   
  -            typeInstance = createTypeInstance(nestedType, null, model);
  +            typeInstance = createTypeInstance(nestedType, factory, model);
           }
   
           // is the typeInstance compatible with the type expected
  @@ -944,7 +977,7 @@
               ClassLoader currentLoader = setContextLoader(taskClassLoader);
               TaskContext taskContext = new TaskContext(this);
               taskContext.init(taskClassLoader, task, model);
  -            configureElement(element, model);
  +            configureElement(libFactory, element, model);
               task.validateComponent();
               setContextLoader(currentLoader);
               return taskContext;
  @@ -967,6 +1000,9 @@
           } catch (ExecutionException e) {
               e.setLocation(model.getLocation(), false);
               throw e;
  +        } catch (RuntimeException e) {
  +            throw new ExecutionException(e.getClass().getName() + ": "
  +                 + e.getMessage(), e, model.getLocation());
           }
       }
   
  @@ -1031,12 +1067,7 @@
                                         BuildElement model)
            throws ExecutionException {
           try {
  -            Object typeInstance = null;
  -            if (libFactory == null) {
  -                typeInstance = typeClass.newInstance();
  -            } else {
  -                typeInstance = libFactory.createTypeInstance(typeClass);
  -            }
  +            Object typeInstance = libFactory.createTypeInstance(typeClass);
   
               if (typeInstance instanceof ExecutionComponent) {
                   ExecutionComponent component = (ExecutionComponent)typeInstance;
  @@ -1044,10 +1075,10 @@
                        = new ExecutionContext(this);
                   context.setModelElement(model);
                   component.init(context);
  -                configureElement(typeInstance, model);
  +                configureElement(libFactory, typeInstance, model);
                   component.validateComponent();
               } else {
  -                configureElement(typeInstance, model);
  +                configureElement(libFactory, typeInstance, model);
               }
               return typeInstance;
           } catch (InstantiationException e) {
  @@ -1061,6 +1092,9 @@
           } catch (ExecutionException e) {
               e.setLocation(model.getLocation(), false);
               throw e;
  +        } catch (RuntimeException e) {
  +            throw new ExecutionException(e.getClass().getName() + ": "
  +                 + e.getMessage(), e, model.getLocation());
           }
       }
   }
  
  
  
  1.3       +9 -3      jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/antlib.xml
  
  Index: antlib.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/antlib.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -u -r1.2 -r1.3
  --- antlib.xml	5 Feb 2002 11:49:05 -0000	1.2
  +++ antlib.xml	5 Feb 2002 14:13:57 -0000	1.3
  @@ -145,8 +145,14 @@
     <taskdef name="xmlvalidate" classname="org.apache.tools.ant.taskdefs.optional.XMLValidateTask"/>
     <taskdef name="zip" classname="org.apache.tools.ant.taskdefs.Zip"/>
   
  -  <typedef name="patternset" classname="org.apache.tools.ant.types.PatternSet"/>
  -  <typedef name="fileset" classname="org.apache.tools.ant.types.FileSet"/>
     <typedef name="path" classname="org.apache.tools.ant.types.Path"/>
  -
  +  <typedef name="fileset" classname="org.apache.tools.ant.types.FileSet"/>
  +  <typedef name="filelist" classname="org.apache.tools.ant.types.FileList"/>
  +  <typedef name="patternset" classname="org.apache.tools.ant.types.PatternSet"/>
  +  <typedef name="mapper" classname="org.apache.tools.ant.types.Mapper"/>
  +  <typedef name="filterset" classname="org.apache.tools.ant.types.FilterSet"/>
  +  <typedef name="description" classname="org.apache.tools.ant.types.Description"/>
  +  <typedef name="classfileset" classname="org.apache.tools.ant.types.optional.depend.ClassfileSet"/>
  +  <typedef name="substitution" classname="org.apache.tools.ant.types.Substitution"/>
  +  <typedef name="regularexpression" classname="org.apache.tools.ant.types.RegularExpression"/>
   </antlib>
  
  
  
  1.2       +16 -0     jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Factory.java
  
  Index: Ant1Factory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Ant1Factory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -u -r1.1 -r1.2
  --- Ant1Factory.java	2 Feb 2002 14:50:32 -0000	1.1
  +++ Ant1Factory.java	5 Feb 2002 14:13:57 -0000	1.2
  @@ -185,5 +185,21 @@
                    + "constructor for converter " + converterClass.getName(), e);
           }
       }
  +
  +    /**
  +     * Register an element which has been created as the result of calling a
  +     * create method.
  +     *
  +     * @param createdElement the element that the component created
  +     * @exception ExecutionException if there is a problem registering the
  +     *      element
  +     */
  +    public void registerCreatedElement(Object createdElement)
  +         throws ExecutionException {
  +        if (createdElement instanceof ProjectComponent) {
  +            ProjectComponent component = (ProjectComponent)createdElement;
  +            component.setProject(project);
  +        }
  +    }
   }
   
  
  
  
  1.2       +13 -0     jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/AntLibFactory.java
  
  Index: AntLibFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/AntLibFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -u -r1.1 -r1.2
  --- AntLibFactory.java	2 Feb 2002 14:50:33 -0000	1.1
  +++ AntLibFactory.java	5 Feb 2002 14:13:57 -0000	1.2
  @@ -112,5 +112,18 @@
       Converter createConverter(Class converterClass)
            throws InstantiationException, IllegalAccessException,
           ExecutionException;
  +
  +
  +    /**
  +     * Register an element which has been created as the result of calling a
  +     * create method.
  +     *
  +     * @param createdElement the element that the component created
  +     * @exception ExecutionException if there is a problem registering the
  +     *      element
  +     */
  +    void registerCreatedElement(Object createdElement)
  +         throws ExecutionException;
  +
   }
   
  
  
  
  1.2       +14 -0     jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/StandardLibFactory.java
  
  Index: StandardLibFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/StandardLibFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -u -r1.1 -r1.2
  --- StandardLibFactory.java	2 Feb 2002 14:50:33 -0000	1.1
  +++ StandardLibFactory.java	5 Feb 2002 14:13:57 -0000	1.2
  @@ -118,5 +118,19 @@
           ExecutionException {
           return (Converter)converterClass.newInstance();
       }
  +
  +    /**
  +     * Register an element which has been created as the result of calling a
  +     * create method.
  +     *
  +     * @param createdElement the element that the component created
  +     * @exception ExecutionException if there is a problem registering the
  +     *      element
  +     */
  +    public void registerCreatedElement(Object createdElement)
  +         throws ExecutionException {
  +        // do nothing
  +    }
  +
   }
   
  
  
  

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