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/test/org/apache/myrmidon/components/embeddor/test DefaultEmbeddorTest.java
Date Thu, 23 May 2002 04:59:36 GMT
donaldp     02/05/22 21:59:36

  Modified:    container/src/java/org/apache/myrmidon/components/builder
                        DefaultProjectBuilder.java
               container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java
               container/src/test/org/apache/myrmidon/components/embeddor/test
                        DefaultEmbeddorTest.java
  Log:
  Target model object is just a shallow facade over ModelElement
  
  Revision  Changes    Path
  1.59      +6 -87     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.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- DefaultProjectBuilder.java	23 May 2002 04:32:10 -0000	1.58
  +++ DefaultProjectBuilder.java	23 May 2002 04:59:36 -0000	1.59
  @@ -12,7 +12,6 @@
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.util.ArrayList;
  -import java.util.StringTokenizer;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.excalibur.io.FileUtil;
  @@ -26,7 +25,6 @@
   import org.apache.myrmidon.interfaces.builder.ModelBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectException;
  -import org.apache.myrmidon.interfaces.oldmodel.Dependency;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
   import org.apache.myrmidon.interfaces.oldmodel.ProjectRef;
   import org.apache.myrmidon.interfaces.oldmodel.Target;
  @@ -35,7 +33,7 @@
    * Default implementation to construct project from a build file.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.58 $ $Date: 2002/05/23 04:32:10 $
  + * @version $Revision: 1.59 $ $Date: 2002/05/23 04:59:36 $
    *
    * @ant.type type="project-builder" name="ant2"
    */
  @@ -361,9 +359,11 @@
   
           final ModelElement[] implicitTasks =
               (ModelElement[])implicitTaskList.toArray( new ModelElement[ implicitTaskList.size()
] );
  +        final ModelElement target = new ModelElement( "target",  model.getLocation() );
  +        target.setAttribute( "name", "<init>" );
  +        target.addChildren( implicitTasks );
   
  -        final Target implicitTarget = new Target( "<init>", implicitTasks, null );
  -        project.setImplicitTarget( implicitTarget );
  +        project.setImplicitTarget( new Target( target ) );
       }
   
       private void buildProjectRef( final DefaultProject project,
  @@ -450,8 +450,6 @@
           throws Exception
       {
           final String name = target.getAttribute( "name" );
  -        final String depends = target.getAttribute( "depends" );
  -
           verifyTargetName( name, target );
   
           if( getLogger().isDebugEnabled() )
  @@ -460,12 +458,7 @@
               getLogger().debug( message );
           }
   
  -        final Dependency[] dependencies = buildDependsList( depends, target );
  -        final Target targetModel =
  -            new Target( name, target.getChildren(), dependencies );
  -
  -        //add target to project
  -        project.addTarget( name, targetModel );
  +        project.addTarget( name, new Target( target ) );
       }
   
       private void verifyTargetName( final String name, final ModelElement target )
  @@ -488,79 +481,5 @@
                   REZ.getString( "ant.target-bad-name.error", target.getLocation() );
               throw new ProjectException( message, e );
           }
  -    }
  -
  -    private Dependency[] buildDependsList( final String depends,
  -                                           final ModelElement target )
  -        throws ProjectException
  -    {
  -        //apply depends attribute
  -        if( null == depends )
  -        {
  -            return null;
  -        }
  -
  -        final String[] elements = split( depends, "," );
  -        final ArrayList dependsList = new ArrayList();
  -
  -        for( int i = 0; i < elements.length; i++ )
  -        {
  -            final String dependency = elements[ i ].trim();
  -
  -            if( getLogger().isDebugEnabled() )
  -            {
  -                final String message = REZ.getString( "ant.target-dependency.notice",
  -                                                      dependency );
  -                getLogger().debug( message );
  -            }
  -
  -            // Split project->target dependencies
  -            final int sep = dependency.indexOf( "->" );
  -            final String projectName;
  -            final String targetName;
  -            if( sep != -1 )
  -            {
  -                projectName = dependency.substring( 0, sep );
  -                targetName = dependency.substring( sep + 2 );
  -            }
  -            else
  -            {
  -                projectName = null;
  -                targetName = dependency;
  -            }
  -
  -            if( targetName.length() == 0 ||
  -                ( projectName != null && projectName.length() == 0 ) )
  -            {
  -                final String message = REZ.getString( "ant.target-bad-dependency.error",
  -                                                      target.getName(),
  -                                                      target.getLocation() );
  -                throw new ProjectException( message );
  -            }
  -
  -            dependsList.add( new Dependency( projectName, targetName ) );
  -        }
  -
  -        return (Dependency[])dependsList.toArray( new Dependency[ dependsList.size() ]
);
  -    }
  -
  -    /**
  -     * Splits the string on every token into an array of strings.
  -     *
  -     * @param string the string
  -     * @param onToken the token
  -     * @return the resultant array
  -     */
  -    private String[] split( final String string, final String onToken )
  -    {
  -        final StringTokenizer tokenizer = new StringTokenizer( string, onToken );
  -        final String[] result = new String[ tokenizer.countTokens() ];
  -
  -        for( int i = 0; i < result.length; i++ )
  -        {
  -            result[ i ] = tokenizer.nextToken();
  -        }
  -
  -        return result;
       }
   }
  
  
  
  1.70      +4 -45     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java
  
  Index: DefaultWorkspace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/DefaultWorkspace.java,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- DefaultWorkspace.java	23 May 2002 04:36:39 -0000	1.69
  +++ DefaultWorkspace.java	23 May 2002 04:59:36 -0000	1.70
  @@ -24,7 +24,6 @@
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.executor.Executor;
  -import org.apache.myrmidon.interfaces.oldmodel.Dependency;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
   import org.apache.myrmidon.interfaces.oldmodel.Target;
   import org.apache.myrmidon.interfaces.service.ScopedService;
  @@ -35,7 +34,7 @@
    * This is the default implementation of Workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.69 $ $Date: 2002/05/23 04:36:39 $
  + * @version $Revision: 1.70 $ $Date: 2002/05/23 04:59:36 $
    * @todo Merge m_entries and m_projects
    */
   public class DefaultWorkspace
  @@ -177,7 +176,8 @@
        */
       private void addChildService( final String role,
                                     final DefaultServiceManager serviceManager,
  -                                  final Map scopedServices ) throws Exception
  +                                  final Map scopedServices )
  +        throws Exception
       {
           // Lookup the service, and skip it if it is not a scoped service
           final Object service = serviceManager.lookup( role );
  @@ -349,18 +349,7 @@
                                         final Target target )
           throws TaskException
       {
  -        final ModelElement targetModel =
  -            new ModelElement( "target", "myFile:?:?" );
  -        targetModel.setAttribute( "name", name );
  -
  -        final String depends = buildDepends( target.getDependencies() );
  -        targetModel.setAttribute( "depends", depends );
  -
  -        final ModelElement[] tasks = target.getTasks();
  -        for( int i = 0; i < tasks.length; i++ )
  -        {
  -            targetModel.addChild( tasks[ i ] );
  -        }
  +        final ModelElement targetModel = target.getModel();
   
           final ExecutionFrame frame =
               entry.getFrame().createChildFrame( name, null, null, false );
  @@ -374,35 +363,5 @@
               throw new TaskException( se.getMessage(), se );
           }
           executor.execute( targetModel, frame );
  -    }
  -
  -    /**
  -     * Temporary method to build a depends string from an
  -     * already parsed set of dependencies.
  -     *
  -     * @param dependencies the dependencies
  -     * @return the depends string
  -     */
  -    private String buildDepends( final Dependency[] dependencies )
  -    {
  -        if( null == dependencies )
  -        {
  -            return null;
  -        }
  -        else
  -        {
  -            final StringBuffer sb = new StringBuffer();
  -            for( int i = 0; i < dependencies.length; i++ )
  -            {
  -                if( 0 != i )
  -                {
  -                    sb.append( ',' );
  -                }
  -
  -                sb.append( dependencies[ i ] );
  -            }
  -
  -            return sb.toString();
  -        }
       }
   }
  
  
  
  1.17      +8 -5      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/embeddor/test/DefaultEmbeddorTest.java
  
  Index: DefaultEmbeddorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/embeddor/test/DefaultEmbeddorTest.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DefaultEmbeddorTest.java	23 May 2002 04:31:15 -0000	1.16
  +++ DefaultEmbeddorTest.java	23 May 2002 04:59:36 -0000	1.17
  @@ -14,6 +14,7 @@
   import org.apache.myrmidon.AbstractContainerTestCase;
   import org.apache.myrmidon.LogMessageTracker;
   import org.apache.myrmidon.api.event.TaskListener;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.components.embeddor.DefaultEmbeddor;
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  @@ -25,7 +26,7 @@
    * Test cases for the default embeddor.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.16 $ $Date: 2002/05/23 04:31:15 $
  + * @version $Revision: 1.17 $ $Date: 2002/05/23 04:59:36 $
    */
   public class DefaultEmbeddorTest
       extends AbstractContainerTestCase
  @@ -91,12 +92,14 @@
           //assertEquals( 1, project.getTargetNames().length );
   
           final Target implicitTarget = project.getImplicitTarget();
  -        assertEquals( 1, implicitTarget.getTasks().length );
  -        assertEquals( "property", implicitTarget.getTasks()[ 0 ].getName() );
  +        final ModelElement model = implicitTarget.getModel();
  +
  +        assertEquals( 1, model.getChildCount() );
  +        assertEquals( "property", model.getChildren()[ 0 ].getName() );
   
           final Target target = project.getTarget( "main-target" );
  -        assertEquals( 1, target.getTasks().length );
  -        assertEquals( "log", target.getTasks()[ 0 ].getName() );
  +        assertEquals( 1, target.getModel().getChildCount() );
  +        assertEquals( "log", target.getModel().getChildren()[ 0 ].getName() );
       }
   
       /**
  
  
  

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