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/java/org/apache/myrmidon/framework ExecuteTarget.java
Date Fri, 07 Jun 2002 06:06:05 GMT
donaldp     2002/06/06 23:06:05

  Modified:    antlib/src/java/org/apache/antlib/project
                        AbstractWorkspaceTask.java
               framework/src/java/org/apache/myrmidon/framework
                        ExecuteTarget.java
  Log:
  Start removing references to Target object
  
  Revision  Changes    Path
  1.5       +5 -7      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractWorkspaceTask.java
  
  Index: AbstractWorkspaceTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractWorkspaceTask.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractWorkspaceTask.java	7 Jun 2002 05:48:20 -0000	1.4
  +++ AbstractWorkspaceTask.java	7 Jun 2002 06:06:05 -0000	1.5
  @@ -12,14 +12,13 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.framework.AbstractContainerTask;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
   
   /**
    * An abstract class used to execute Ant files within same workspace.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.4 $ $Date: 2002/06/07 05:48:20 $
  + * @version $Revision: 1.5 $ $Date: 2002/06/07 06:06:05 $
    */
   abstract class AbstractWorkspaceTask
       extends AbstractContainerTask
  @@ -44,9 +43,8 @@
           // Locate the referenced target
           final Project project = getProject( dependency );
           final String targetName = dependency.getTargetName();
  -        final Target target = project.getTarget( targetName );
   
  -        executeTarget( target );
  +        executeTarget( project.getURI(), targetName );
       }
   
       /**
  @@ -56,13 +54,13 @@
        * @param target the name of target to execute
        * @throws TaskException if error occurs executing target
        */
  -    protected final void executeTarget( final Target target )
  +    protected final void executeTarget( final String projectURI,
  +                                        final String target )
           throws TaskException
       {
           final Workspace workspace =
               (Workspace)getContext().getService( Workspace.class );
  -        final String uri = target.getProject().getURI();
  -        workspace.execute( uri, target.getName() );
  +        workspace.execute( projectURI, target );
       }
   
       /**
  
  
  
  1.10      +24 -12    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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ExecuteTarget.java	7 Jun 2002 02:46:31 -0000	1.9
  +++ ExecuteTarget.java	7 Jun 2002 06:06:05 -0000	1.10
  @@ -17,7 +17,7 @@
   import org.apache.myrmidon.interfaces.embeddor.Embeddor;
   import org.apache.myrmidon.interfaces.executor.ExecutionFrame;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
  +import org.apache.myrmidon.interfaces.model.TargetMetaData;
   
   /**
    * A utility class that simplifies executing a target in a project.
  @@ -25,7 +25,7 @@
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:darrell@apache.org">Darrell DeBoer</a>
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
  - * @version $Revision: 1.9 $ $Date: 2002/06/07 02:46:31 $
  + * @version $Revision: 1.10 $ $Date: 2002/06/07 06:06:05 $
    */
   public class ExecuteTarget
   {
  @@ -96,15 +96,8 @@
           final Project project = buildProject( embeddor );
           final Map properties = buildParameters( context );
   
  -        final Target target;
  -        if( null == m_target )
  -        {
  -            target = project.getDefaultTarget();
  -        }
  -        else
  -        {
  -            target = project.getTarget( m_target );
  -        }
  +        final TargetMetaData projectMetaData = project.getMetaData();
  +        final TargetMetaData target = getTarget( projectMetaData );
   
           try
           {
  @@ -117,10 +110,29 @@
           {
               final String message =
                   REZ.getString( "execute-target.execute.error",
  -                               project.getMetaData().getName(),
  +                               projectMetaData.getName(),
                                  target.getName() );
               throw new TaskException( message, e );
           }
  +    }
  +
  +    private TargetMetaData getTarget( final TargetMetaData projectMetaData )
  +    {
  +        TargetMetaData target = projectMetaData;
  +        if( null != m_target )
  +        {
  +            final TargetMetaData[] targets = target.getTargets();
  +            for( int i = 0; i < targets.length; i++ )
  +            {
  +                final TargetMetaData candidate = targets[ i ];
  +                if( m_target.equals( candidate.getName() ) )
  +                {
  +                    target = candidate;
  +                    break;
  +                }
  +            }
  +        }
  +        return target;
       }
   
       /**
  
  
  

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