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/framework/src/test/org/apache/myrmidon/framework TestCaseProjectBuilder.java
Date Fri, 07 Jun 2002 07:07:52 GMT
donaldp     2002/06/07 00:07:52

  Modified:    container/src/test/org/apache/myrmidon/components/embeddor/test
                        DefaultEmbeddorTest.java
               container/src/java/org/apache/myrmidon/components/builder
                        DefaultProject.java DefaultProjectBuilder.java
               container/src/test/org/apache/myrmidon/components/builder/test
                        DefaultProjectBuilderTestCase.java
               container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java ProjectEntry.java
               container/src/java/org/apache/myrmidon/interfaces/oldmodel
                        Project.java
               framework/src/test/org/apache/myrmidon/framework
                        TestCaseProjectBuilder.java
  Added:       container/src/java/org/apache/myrmidon/components/builder
                        Target.java
  Removed:     container/src/java/org/apache/myrmidon/interfaces/oldmodel
                        Target.java
  Log:
  Move Target into component.builder and remove references to it in external classes
  
  Revision  Changes    Path
  1.22      +12 -14    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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DefaultEmbeddorTest.java	7 Jun 2002 02:48:51 -0000	1.21
  +++ DefaultEmbeddorTest.java	7 Jun 2002 07:07:52 -0000	1.22
  @@ -17,15 +17,15 @@
   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;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
  +import org.apache.myrmidon.interfaces.model.TargetMetaData;
  +import org.apache.myrmidon.interfaces.oldmodel.Project;
   
   /**
    * Test cases for the default embeddor.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.21 $ $Date: 2002/06/07 02:48:51 $
  + * @version $Revision: 1.22 $ $Date: 2002/06/07 07:07:52 $
    */
   public class DefaultEmbeddorTest
       extends AbstractContainerTestCase
  @@ -85,20 +85,18 @@
   
           // Verify the project.
           assertEquals( "test-project", project.getMetaData().getName() );
  -        assertEquals( project.getTarget( "main-target" ), project.getDefaultTarget() );
  +        //assertEquals( project.getTarget( "main-target" ), project.getDefaultTarget()
);
           assertEquals( projectFile.getParentFile(), project.getBaseDirectory() );
           //assertEquals( 0, project.getProjectNames().length );
           //assertEquals( 1, project.getTargetNames().length );
   
  -        final Target implicitTarget = project.getTarget( Project.IMPLICIT_TARGET_NAME );
  -        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.getModel().getChildCount() );
  -        assertEquals( "log", target.getModel().getChildren()[ 0 ].getName() );
  +        final ModelElement implicit = project.getTargetModel( Project.IMPLICIT_TARGET_NAME
);
  +        assertEquals( 1, implicit.getChildCount() );
  +        assertEquals( "property", implicit.getChildren()[ 0 ].getName() );
  +
  +        final ModelElement target = project.getTargetModel( "main-target" );
  +        assertEquals( 1, target.getChildCount() );
  +        assertEquals( "log", target.getChildren()[ 0 ].getName() );
       }
   
       /**
  @@ -133,7 +131,7 @@
           listener.addExpectedMessage( "main-target", "A log message" );
   
           // Execute the default target
  -        final Target target = project.getDefaultTarget();
  +        final TargetMetaData target = project.getDefaultTarget();
           project.execute( frame, target );
   
           // Cleanup
  
  
  
  1.22      +19 -7     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProject.java
  
  Index: DefaultProject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProject.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- DefaultProject.java	7 Jun 2002 06:12:38 -0000	1.21
  +++ DefaultProject.java	7 Jun 2002 07:07:52 -0000	1.22
  @@ -15,20 +15,20 @@
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.components.workspace.DefaultWorkspace;
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.model.TargetMetaData;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
   import org.apache.myrmidon.interfaces.oldmodel.ProjectRef;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
   
   /**
    * Default project implementation.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.21 $ $Date: 2002/06/07 06:12:38 $
  + * @version $Revision: 1.22 $ $Date: 2002/06/07 07:07:52 $
    */
   public class DefaultProject
       extends AbstractLogEnabled
  @@ -98,9 +98,9 @@
       /**
        * Adds a target to this project.
        */
  -    public void addTarget( final Target target )
  +    public void addTarget( final TargetMetaData target )
       {
  -        m_targets.put( target.getName(), target);
  +        m_targets.put( target.getName(), target );
       }
   
       public String getURI()
  @@ -170,7 +170,7 @@
        * @return the default target name
        * @throws TaskException if the project has no default target.
        */
  -    public Target getDefaultTarget() throws TaskException
  +    public TargetMetaData getDefaultTarget() throws TaskException
       {
           return getTarget( m_defaultTarget );
       }
  @@ -178,16 +178,28 @@
       /**
        * Retrieve a target by name.
        */
  -    public final Target getTarget( final String targetName )
  +    public final TargetMetaData getTarget( final String targetName )
           throws TaskException
       {
  -        final Target target = (Target)m_targets.get( targetName );
  +        final TargetMetaData target = (TargetMetaData)m_targets.get( targetName );
           if( target == null )
           {
               final String message = REZ.getString( "project.unknown-target.error", targetName
);
               throw new TaskException( message );
           }
           return target;
  +    }
  +
  +    public final ModelElement getTargetModel( final String targetName )
  +        throws TaskException
  +    {
  +        final Target target = (Target)m_targets.get( targetName );
  +        if( target == null )
  +        {
  +            final String message = REZ.getString( "project.unknown-target.error", targetName
);
  +            throw new TaskException( message );
  +        }
  +        return target.getModel();
       }
   
       /**
  
  
  
  1.67      +5 -10     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.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- DefaultProjectBuilder.java	4 Jun 2002 12:36:17 -0000	1.66
  +++ DefaultProjectBuilder.java	7 Jun 2002 07:07:52 -0000	1.67
  @@ -25,7 +25,6 @@
   import org.apache.myrmidon.interfaces.builder.ProjectException;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
   import org.apache.myrmidon.interfaces.oldmodel.ProjectRef;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
   import org.apache.myrmidon.interfaces.property.NameValidator;
   import org.apache.myrmidon.interfaces.property.NameValidatorManager;
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
  @@ -34,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.66 $ $Date: 2002/06/04 12:36:17 $
  + * @version $Revision: 1.67 $ $Date: 2002/06/07 07:07:52 $
    *
    * @ant.type type="project-builder" name="ant2"
    */
  @@ -185,13 +184,9 @@
           // Do nothing
       }
   
  -    /**
  -     * Creates a target from its model.
  -     */
  -    protected Target createTarget( final DefaultProject project,
  -                                   final ModelElement model )
  +    protected ModelElement createTargetModel( final ModelElement model )
       {
  -        return new Target( project, model );
  +        return model;
       }
   
       /**
  @@ -400,7 +395,7 @@
   
               if( name.equals( "target" ) )
               {
  -                project.addTarget( createTarget( project, element ) );
  +                project.addTarget( new Target( createTargetModel( element ) ) );
               }
               else
               {
  @@ -410,7 +405,7 @@
                   throw new ProjectException( message );
               }
           }
  -        project.addTarget( createTarget( project, implicit ) );
  +        project.addTarget( new Target( createTargetModel( implicit ) ) );
       }
   
       private ProjectRef buildProjectRef( final File baseDirectory,
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/Target.java
  
  Index: Target.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.myrmidon.components.builder;
  
  import org.apache.myrmidon.api.metadata.ModelElement;
  import org.apache.myrmidon.interfaces.model.TargetMetaData;
  
  /**
   * Targets in build file.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/06/07 07:07:52 $
   */
  public class Target
      implements TargetMetaData
  {
      private final ModelElement m_target;
  
      /**
       * Constructs a target.
       *
       * @param target the ModelElement representing target
       */
      public Target( final ModelElement target )
      {
          m_target = target;
      }
  
      /**
       * Get tasks in target
       *
       * @return the target list
       */
      public final ModelElement getModel()
      {
          return m_target;
      }
  
      /**
       * Retrieve the name of the Target.
       *
       * @return the name of the Target.
       */
      public String getName()
      {
          return m_target.getAttribute( "name" );
      }
  
      /**
       * Retrieve a description of the target.
       *
       * @return a description of the target.
       */
      public String getDescription()
      {
          return m_target.getAttribute( "description" );
      }
  
      /**
       * Return an array of child targets.
       * Must return a non-null value, even when there
       * are no child targets.
       *
       * @return a non-null array of child targets.
       */
      public TargetMetaData[] getTargets()
      {
          return new TargetMetaData[ 0 ];
      }
  }
  
  
  
  1.13      +6 -5      jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/DefaultProjectBuilderTestCase.java
  
  Index: DefaultProjectBuilderTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/test/org/apache/myrmidon/components/builder/test/DefaultProjectBuilderTestCase.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultProjectBuilderTestCase.java	2 Jun 2002 14:08:06 -0000	1.12
  +++ DefaultProjectBuilderTestCase.java	7 Jun 2002 07:07:52 -0000	1.13
  @@ -20,7 +20,7 @@
   import org.apache.myrmidon.interfaces.builder.ProjectException;
   import org.apache.myrmidon.interfaces.model.TargetMetaData;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
  +import org.apache.myrmidon.components.builder.Target;
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.api.metadata.ModelElement;
   
  @@ -28,7 +28,7 @@
    * Test cases for {@link DefaultProjectBuilder}.
    *
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  - * @version $Revision: 1.12 $ $Date: 2002/06/02 14:08:06 $
  + * @version $Revision: 1.13 $ $Date: 2002/06/07 07:07:52 $
    */
   public class DefaultProjectBuilderTestCase
       extends AbstractComponentTest
  @@ -143,11 +143,12 @@
           assertSameProject( expected, project );
       }
   
  -    private void addTarget( final DefaultProject project, final String name )
  +    private void addTarget( final DefaultProject project,
  +                            final String name )
       {
           final ModelElement model = new ModelElement( "target", "" );
           model.setAttribute( "name", name );
  -        project.addTarget( new Target( project, model ) );
  +        project.addTarget( new Target( model ) );
       }
   
       private String getNameFor( final File projFile )
  @@ -285,7 +286,7 @@
       {
           assertSameMetaData( expected.getMetaData(), project.getMetaData() );
           assertEquals( expected.getBaseDirectory(), project.getBaseDirectory() );
  -        assertSameMetaData( expected.getDefaultTarget(), project.getDefaultTarget() );
  +        //assertSameMetaData( expected.getDefaultTarget(), project.getDefaultTarget() );
       }
   
       private void assertSameMetaData( final TargetMetaData expected,
  
  
  
  1.75      +7 -6      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.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- DefaultWorkspace.java	7 Jun 2002 05:48:20 -0000	1.74
  +++ DefaultWorkspace.java	7 Jun 2002 07:07:52 -0000	1.75
  @@ -25,8 +25,8 @@
   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.model.TargetMetaData;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
   import org.apache.myrmidon.interfaces.service.ScopedService;
   import org.apache.myrmidon.interfaces.type.TypeManager;
   import org.apache.myrmidon.interfaces.type.TypeRegistry;
  @@ -36,7 +36,7 @@
    * This is the default implementation of Workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.74 $ $Date: 2002/06/07 05:48:20 $
  + * @version $Revision: 1.75 $ $Date: 2002/06/07 07:07:52 $
    * @todo Merge m_entries and m_projects
    */
   public class DefaultWorkspace
  @@ -68,7 +68,7 @@
       {
           final ProjectEntry entry = getProjectEntry( projectURI );
           final Project project = entry.getProject();
  -        Target target = project.getTarget( targetName );
  +        TargetMetaData target = project.getTarget( targetName );
           if( null == target )
           {
               target = project.getDefaultTarget();
  @@ -223,7 +223,7 @@
        * @throws TaskException if an error occurs
        */
       private void executeTarget( final ProjectEntry entry,
  -                                final Target target )
  +                                final TargetMetaData target )
           throws TaskException
       {
           // Check target state, to see if it has already been executed, and
  @@ -260,10 +260,11 @@
        * @param target the target itself
        */
       private void executeTargetNoDeps( final ProjectEntry entry,
  -                                      final Target target )
  +                                      final TargetMetaData target )
           throws TaskException
       {
  -        final ModelElement targetModel = target.getModel();
  +        final ModelElement targetModel =
  +            entry.getProject().getTargetModel( target.getName() );
   
           final ExecutionFrame frame =
               entry.getFrame().createChildFrame( target.getName(), null, null, false );
  
  
  
  1.10      +4 -4      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/ProjectEntry.java
  
  Index: ProjectEntry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/ProjectEntry.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ProjectEntry.java	28 Apr 2002 05:04:49 -0000	1.9
  +++ ProjectEntry.java	7 Jun 2002 07:07:52 -0000	1.10
  @@ -10,15 +10,15 @@
   import java.util.HashMap;
   import java.util.Map;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
  +import org.apache.myrmidon.interfaces.model.TargetMetaData;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
   
   /**
    * This contains details for each project that is being executed by a
    * DefaultWorkspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.9 $ $Date: 2002/04/28 05:04:49 $
  + * @version $Revision: 1.10 $ $Date: 2002/06/07 07:07:52 $
    */
   final class ProjectEntry
   {
  @@ -45,7 +45,7 @@
           return m_frame;
       }
   
  -    public TargetState getTargetState( final Target target )
  +    public TargetState getTargetState( final TargetMetaData target )
       {
           TargetState state = (TargetState)m_targetState.get( target );
           if( state == null )
  @@ -55,7 +55,7 @@
           return state;
       }
   
  -    public void setTargetState( final Target target, final TargetState state )
  +    public void setTargetState( final TargetMetaData target, final TargetState state )
       {
           m_targetState.put( target, state );
       }
  
  
  
  1.15      +8 -3      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/oldmodel/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/oldmodel/Project.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Project.java	7 Jun 2002 06:13:47 -0000	1.14
  +++ Project.java	7 Jun 2002 07:07:52 -0000	1.15
  @@ -9,14 +9,16 @@
   
   import java.io.File;
   import org.apache.myrmidon.interfaces.model.Module;
  +import org.apache.myrmidon.interfaces.model.TargetMetaData;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.api.metadata.ModelElement;
   
   /**
    * Abstraction used to interact with projects.
    * Implementations may choose to structure it anyway they choose.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.14 $ $Date: 2002/06/07 06:13:47 $
  + * @version $Revision: 1.15 $ $Date: 2002/06/07 07:07:52 $
    */
   public interface Project
       extends Module
  @@ -54,7 +56,7 @@
        * @return the default target name
        * @throws TaskException if the project has no default target.
        */
  -    Target getDefaultTarget() throws TaskException;
  +    TargetMetaData getDefaultTarget() throws TaskException;
   
       /**
        * Retrieve a target by name.
  @@ -63,7 +65,10 @@
        * @return the Target
        * @throws TaskException if the requested target is unknown
        */
  -    Target getTarget( String name ) throws TaskException;
  +    TargetMetaData getTarget( String name ) throws TaskException;
  +
  +    ModelElement getTargetModel( String name )
  +        throws TaskException;
   
       /**
        * Retrieve base directory of project.
  
  
  
  1.2       +4 -8      jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/TestCaseProjectBuilder.java
  
  Index: TestCaseProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/test/org/apache/myrmidon/framework/TestCaseProjectBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestCaseProjectBuilder.java	5 Jun 2002 07:58:22 -0000	1.1
  +++ TestCaseProjectBuilder.java	7 Jun 2002 07:07:52 -0000	1.2
  @@ -7,11 +7,9 @@
    */
   package org.apache.myrmidon.framework;
   
  +import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.components.builder.DefaultProjectBuilder;
  -import org.apache.myrmidon.components.builder.DefaultProject;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
   import org.apache.myrmidon.interfaces.model.ModelElementUtil;
  -import org.apache.myrmidon.api.metadata.ModelElement;
   
   /**
    * A project builder for unit test projects.  Uses a simplified project file
  @@ -19,7 +17,7 @@
    * targets.
    *
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.1 $ $Date: 2002/06/05 07:58:22 $
  + * @version $Revision: 1.2 $ $Date: 2002/06/07 07:07:52 $
    *
    * @ant.type type="project-builder" name="simple"
    */
  @@ -29,13 +27,11 @@
       /**
        * Creates a target from its model.
        */
  -    protected Target createTarget( final DefaultProject project,
  -                                   final ModelElement model )
  +    protected ModelElement createTargetModel( final ModelElement model )
       {
           final ModelElement newModel =
               new ModelElement( "simple-target", model.getLocation() );
           ModelElementUtil.copyModel( model, newModel );
  -
  -        return super.createTarget( project, newModel );
  +        return newModel;
       }
   }
  
  
  

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