ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adammurd...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder ConvertingProjectBuilder.java
Date Wed, 29 May 2002 06:20:23 GMT
adammurdoch    02/05/28 23:20:23

  Modified:    container/src/java/org/apache/myrmidon/components/builder
                        ConvertingProjectBuilder.java
  Log:
  Changed ant1 project builder, to transform the model so that
  all top-level task elements end up in front of the first
  <target> element.
  
  Revision  Changes    Path
  1.11      +21 -8     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/ConvertingProjectBuilder.java
  
  Index: ConvertingProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/ConvertingProjectBuilder.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ConvertingProjectBuilder.java	21 May 2002 07:30:23 -0000	1.10
  +++ ConvertingProjectBuilder.java	29 May 2002 06:20:23 -0000	1.11
  @@ -8,13 +8,15 @@
   package org.apache.myrmidon.components.builder;
   
   import org.apache.myrmidon.api.metadata.ModelElement;
  +import java.util.List;
  +import java.util.ArrayList;
   
   /**
    * A simple ProjectBuilder, which programmatically converts an Ant1 Project
    * configuration into a Myrmidon one.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.10 $ $Date: 2002/05/21 07:30:23 $
  + * @version $Revision: 1.11 $ $Date: 2002/05/29 06:20:23 $
    *
    * @ant.type type="project-builder" name="xml"
    * @ant.type type="project-builder" name="ant"
  @@ -39,14 +41,10 @@
           // Put a new version attribute.
           model.setAttribute( VERSION_ATTRIBUTE, "2.0" );
   
  -        // Add an "import" task for the ant1 tasks
  -        final ModelElement typelibDeclaration =
  -            new ModelElement( "import", model.getLocation() );
  -        typelibDeclaration.setAttribute( "library", "ant1" );
  -        model.addChild( 0, typelibDeclaration );
  -
  -        // Convert the child <target> elements
  +        // Convert the child <target> elements, and move all the non <target>
  +        // elements
           final ModelElement[] children = model.getChildren();
  +        int insertPos = 0;
           for( int i = 0; i < children.length; i++ )
           {
               final ModelElement child = children[ i ];
  @@ -55,7 +53,22 @@
               {
                   convertTarget( child );
               }
  +            else
  +            {
  +                if( i > insertPos )
  +                {
  +                    model.removeChild( child );
  +                    model.addChild( insertPos, child );
  +                }
  +                insertPos++;
  +            }
           }
  +
  +        // Add an "import" task for the ant1 tasks
  +        final ModelElement typelibDeclaration =
  +            new ModelElement( "import", model.getLocation() );
  +        typelibDeclaration.setAttribute( "library", "ant1" );
  +        model.addChild( 0, typelibDeclaration );
       }
   
       /**
  
  
  

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