ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model Target.java
Date Sun, 21 Apr 2002 01:47:38 GMT
donaldp     02/04/20 18:47:38

  Modified:    container/src/java/org/apache/myrmidon/components/builder
                        DefaultProjectBuilder.java
               container/src/java/org/apache/myrmidon/interfaces/model
                        Target.java
  Log:
  Update project building to use ModelElement rather than configuraiton objects.
  
  Revision  Changes    Path
  1.45      +42 -4     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- DefaultProjectBuilder.java	20 Apr 2002 12:53:37 -0000	1.44
  +++ DefaultProjectBuilder.java	21 Apr 2002 01:47:38 -0000	1.45
  @@ -21,6 +21,7 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectException;
   import org.apache.myrmidon.interfaces.model.DefaultNameValidator;
  @@ -34,7 +35,7 @@
    * Default implementation to construct project from a build file.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.44 $ $Date: 2002/04/20 12:53:37 $
  + * @version $Revision: 1.45 $ $Date: 2002/04/21 01:47:38 $
    *
    * @ant.type type="project-builder" name="ant2"
    */
  @@ -347,10 +348,45 @@
           final Configuration[] implicitTasks =
               (Configuration[])implicitTaskList.toArray( new Configuration[ 0 ] );
   
  -        final Target implicitTarget = new Target( implicitTasks, null );
  +        final Target implicitTarget = new Target( toModelElements( implicitTasks ), null
);
           project.setImplicitTarget( implicitTarget );
       }
   
  +    private ModelElement[] toModelElements( final Configuration[] implicitTasks )
  +    {
  +        final ModelElement[] elements = new ModelElement[ implicitTasks.length ];
  +        for( int i = 0; i < elements.length; i++ )
  +        {
  +            elements[ i ] = toModelElement( implicitTasks[ i ] );
  +
  +        }
  +        return elements;
  +    }
  +
  +    private ModelElement toModelElement( final Configuration task )
  +    {
  +        final ModelElement model =
  +            new ModelElement( task.getName(),
  +                              task.getLocation() );
  +
  +        final Configuration[] children = task.getChildren();
  +        for( int i = 0; i < children.length; i++ )
  +        {
  +            final ModelElement child = toModelElement( children[ i ] );
  +            model.addChild( child );
  +        }
  +
  +        final String[] names = task.getAttributeNames();
  +        for( int i = 0; i < names.length; i++ )
  +        {
  +            final String name = names[ i ];
  +            final String value = task.getAttribute( name, null );
  +            model.setAttribute( name, value );
  +        }
  +
  +        return model;
  +    }
  +
       private void buildProjectRef( final DefaultProject project,
                                     final Configuration element,
                                     final HashMap projects )
  @@ -469,10 +505,12 @@
           }
   
           final Dependency[] dependencies = buildDependsList( depends, target );
  -        final Target defaultTarget = new Target( target.getChildren(), dependencies );
  +        final Target targetModel =
  +            new Target( toModelElements( target.getChildren() ),
  +                        dependencies );
   
           //add target to project
  -        project.addTarget( name, defaultTarget );
  +        project.addTarget( name, targetModel );
       }
   
       private void verifyTargetName( final String name, final Configuration target )
  
  
  
  1.9       +5 -5      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/Target.java
  
  Index: Target.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/Target.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Target.java	1 Apr 2002 09:56:27 -0000	1.8
  +++ Target.java	21 Apr 2002 01:47:38 -0000	1.9
  @@ -8,13 +8,13 @@
   package org.apache.myrmidon.interfaces.model;
   
   import java.util.ArrayList;
  -import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   
   /**
    * Targets in build file.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.8 $ $Date: 2002/04/01 09:56:27 $
  + * @version $Revision: 1.9 $ $Date: 2002/04/21 01:47:38 $
    */
   public class Target
   {
  @@ -26,7 +26,7 @@
        * @param tasks The task models for all tasks in this target.
        * @param dependencies The dependencies for executing this target.
        */
  -    public Target( final Configuration[] tasks,
  +    public Target( final ModelElement[] tasks,
                      final Dependency[] dependencies )
       {
           for( int i = 0; i < tasks.length; i++ )
  @@ -58,8 +58,8 @@
        *
        * @return the target list
        */
  -    public final Configuration[] getTasks()
  +    public final ModelElement[] getTasks()
       {
  -        return (Configuration[])m_tasks.toArray( new Configuration[ 0 ] );
  +        return (ModelElement[])m_tasks.toArray( new ModelElement[ 0 ] );
       }
   }
  
  
  

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