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/framework/src/java/org/apache/myrmidon/framework ExecuteTarget.java
Date Tue, 02 Jul 2002 02:18:09 GMT
adammurdoch    2002/07/01 19:18:09

  Modified:    container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               container/src/java/org/apache/myrmidon/interfaces
                        EmbeddedAnt.java
               container/src/java/org/apache/myrmidon/interfaces/embeddor
                        Embeddor.java
               container/src/test/org/apache/myrmidon/components/embeddor/test
                        DefaultEmbeddorTest.java
               framework/src/java/org/apache/myrmidon/framework
                        ExecuteTarget.java
  Log:
  - Renamed Embeddor.setupListener() to createListener(), for better match with
    the other Embeddor methods.
  
  - Changed Embeddor.execute() to take a list of targets to execute.  Allows
    execution of more than one target in the same workspace.
  
  - Frontend now executes all targets given on the command-line in the same
    workspace, rather than creating a new workspace for each target.
  
  Revision  Changes    Path
  1.115     +17 -4     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java
  
  Index: DefaultEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java,v
  retrieving revision 1.114
  retrieving revision 1.115
  diff -u -r1.114 -r1.115
  --- DefaultEmbeddor.java	30 Jun 2002 11:09:11 -0000	1.114
  +++ DefaultEmbeddor.java	2 Jul 2002 02:18:09 -0000	1.115
  @@ -143,7 +143,7 @@
       /**
        * Creates a task listener.
        */
  -    public TaskListener setupListener( final ModelElement model,
  +    public TaskListener createListener( final ModelElement model,
                                          final TaskContext context )
           throws Exception
       {
  @@ -261,13 +261,26 @@
           m_context = null;
       }
   
  +    /**
  +     * Executes a set of targets in a new workspace.
  +     */
       public void execute( final ExecutionFrame frame,
                            final ProjectDescriptor project,
  -                         final String target )
  +                         final String[] targets )
           throws TaskException
       {
           final Workspace workspace = createWorkspace( frame );
  -        workspace.execute( project, target );
  +        if( targets == null || targets.length == 0 )
  +        {
  +            workspace.execute( project, null );
  +        }
  +        else
  +        {
  +            for( int i = 0; i < targets.length; i++ )
  +            {
  +                workspace.execute( project, targets[ i ] );
  +            }
  +        }
       }
   
       /**
  
  
  
  1.33      +3 -15     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/EmbeddedAnt.java
  
  Index: EmbeddedAnt.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/EmbeddedAnt.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- EmbeddedAnt.java	30 Jun 2002 10:49:40 -0000	1.32
  +++ EmbeddedAnt.java	2 Jul 2002 02:18:09 -0000	1.33
  @@ -187,19 +187,7 @@
                                    final String[] targets )
           throws TaskException
       {
  -        if( targets == null || targets.length == 0 )
  -        {
  -            //final String targetName = descriptor.getDefaultTargetName();
  -            //Next line an utter hack - need to rejif it completely
  -            m_embeddor.execute( frame, descriptor, null );
  -        }
  -        else
  -        {
  -            for( int i = 0; i < targets.length; i++ )
  -            {
  -                m_embeddor.execute( frame, descriptor, targets[ i ] );
  -            }
  -        }
  +        m_embeddor.execute( frame, descriptor, targets );
       }
   
       /**
  @@ -288,7 +276,7 @@
               else
               {
                   final ModelElement model = (ModelElement)obj;
  -                listener = embeddor.setupListener( model, null );
  +                listener = embeddor.createListener( model, null );
               }
               eventManager.addTaskListener( listener );
           }
  
  
  
  1.30      +11 -9     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/embeddor/Embeddor.java
  
  Index: Embeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/embeddor/Embeddor.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Embeddor.java	30 Jun 2002 10:49:40 -0000	1.29
  +++ Embeddor.java	2 Jul 2002 02:18:09 -0000	1.30
  @@ -48,7 +48,7 @@
        * @return the listener.
        * @throws Exception If the listener could not be created.
        */
  -    TaskListener setupListener( ModelElement model, TaskContext context )
  +    TaskListener createListener( ModelElement model, TaskContext context )
           throws Exception;
   
       /**
  @@ -69,16 +69,18 @@
           throws Exception;
   
       /**
  -     * Execute a target in a project in specified frame.
  -     * If target is null then the default target in project will be executed.
  +     * Execute a set of targets in a project in a new workspace.
  +     * If the list of targets is null or zero length, then the default targets
  +     * in project will be executed.  The targets are executed in the order
  +     * given, subject to dependency ordering, and each targets is executed once.
        *
  -     * @param frame the frame in which to execute project
  -     * @param project the descriptor point to project
  -     * @param target the target in project to execute (May be null).
  -     * @throws TaskException if error executing target
  +     * @param frame the frame to use to construct the workspace
  +     * @param project the descriptor pointing to project
  +     * @param targets the targets to execute (May be null).
  +     * @throws TaskException if error executing targets
        */
       void execute( ExecutionFrame frame,
                     ProjectDescriptor project,
  -                  String target )
  +                  String[] targets )
           throws TaskException;
   }
  
  
  
  1.40      +3 -3      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.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- DefaultEmbeddorTest.java	30 Jun 2002 10:49:41 -0000	1.39
  +++ DefaultEmbeddorTest.java	2 Jul 2002 02:18:09 -0000	1.40
  @@ -108,7 +108,7 @@
       public void testCreateListener() throws Exception
       {
           final ModelElement model = new ModelElement( "default", "?:?:?" );
  -        final TaskListener listener = getEmbeddor().setupListener( model, null );
  +        final TaskListener listener = getEmbeddor().createListener( model, null );
           assertNotNull( listener );
       }
   
  @@ -140,7 +140,7 @@
   
           // Execute the default target
           final String defaultTargetName = project.getDefaultTargetName();
  -        embeddor.execute( frame, project.getProjectDescriptor(), defaultTargetName );
  +        embeddor.execute( frame, project.getProjectDescriptor(), new String[] { defaultTargetName
} );
   
           // Cleanup
           listener.assertComplete();
  
  
  
  1.26      +32 -9     jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/ExecuteTarget.java
  
  Index: ExecuteTarget.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/ExecuteTarget.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ExecuteTarget.java	30 Jun 2002 10:49:41 -0000	1.25
  +++ ExecuteTarget.java	2 Jul 2002 02:18:09 -0000	1.26
  @@ -9,6 +9,7 @@
   
   import java.util.HashMap;
   import java.util.Map;
  +import java.util.Arrays;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.myrmidon.api.TaskContext;
  @@ -18,7 +19,7 @@
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   
   /**
  - * A utility class that simplifies executing a target in a project.
  + * A utility class that simplifies executing a target in a new workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
  @@ -31,9 +32,9 @@
           ResourceManager.getPackageResources( ExecuteTarget.class );
   
       private boolean m_inheritAll;
  -    private String m_target;
       private ProjectDescriptor m_project;
       private final Map m_parameters = new HashMap();
  +    private String[] m_targets;
   
       /**
        * Enables the inheritance of properties from the calling task.  Default
  @@ -45,12 +46,29 @@
       }
   
       /**
  -     * Sets the name of the target to execute. If not specified, the project's
  +     * Sets the target to execute.  If not specified, the project's
        * default target will be executed.
        */
       public void setTarget( final String target )
       {
  -        m_target = target;
  +        if( target != null )
  +        {
  +            m_targets = new String[] { target };
  +        }
  +        else
  +        {
  +            m_targets = null;
  +        }
  +    }
  +
  +    /**
  +     * Sets the targets to execute.  If not specified, the project's default
  +     * target will be executed.  The targets are executed in the order given,
  +     * subject to dependency ordering, and each target is executed once only.
  +     */
  +    public void setTargets( final String[] targets )
  +    {
  +        m_targets = targets;
       }
   
       /**
  @@ -81,18 +99,23 @@
   
           try
           {
  -            // TODO - need to be able to inherit services (TypeManager specifically)
               final ExecutionFrame frame = embeddor.createExecutionFrame( properties, null
);
  -            embeddor.execute( frame, m_project, m_target );
  +            embeddor.execute( frame, m_project, m_targets );
           }
           catch( final Exception e )
           {
               final String message;
  -            if( m_target != null )
  +            if( m_targets != null && m_targets.length ==1  )
  +            {
  +                message = REZ.getString( "execute-target.execute.error",
  +                                         m_project.getUri(),
  +                                         m_targets[0] );
  +            }
  +            else if( m_targets != null && m_targets.length > 1 )
               {
                   message = REZ.getString( "execute-target.execute.error",
                                            m_project.getUri(),
  -                                         m_target );
  +                                         Arrays.asList( m_targets ) );
               }
               else
               {
  
  
  

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