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/java/org/apache/myrmidon/interfaces/oldmodel Project.java
Date Tue, 11 Jun 2002 07:45:11 GMT
donaldp     2002/06/11 00:45:11

  Modified:    antlib/src/java/org/apache/antlib/project
                        AbstractWorkspaceTask.java
               container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               container/src/test/org/apache/myrmidon/components/embeddor/test
                        DefaultEmbeddorTest.java
               container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java Resources.properties
               container/src/java/org/apache/myrmidon/interfaces
                        EmbeddedAnt.java
               container/src/java/org/apache/myrmidon/interfaces/embeddor
                        Embeddor.java
               framework/src/java/org/apache/myrmidon/framework
                        ExecuteTarget.java
               container/src/java/org/apache/myrmidon/interfaces/oldmodel
                        Project.java
  Log:
  Project.getTarget(String) no longer throws an exception on missing target but instead returns
null.
  
  The workspace now checks to see if target is null before executing it and all the rest of
places where targets are executed will just pass through to Workspace.
  
  Revision  Changes    Path
  1.11      +2 -3      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AbstractWorkspaceTask.java	11 Jun 2002 06:46:56 -0000	1.10
  +++ AbstractWorkspaceTask.java	11 Jun 2002 07:45:10 -0000	1.11
  @@ -58,8 +58,7 @@
                                           final String target )
           throws TaskException
       {
  -        final Workspace workspace =
  -            (Workspace)getContext().getService( Workspace.class );
  +        final Workspace workspace = (Workspace)getContext().getService( Workspace.class
);
           workspace.execute( descriptor, target );
       }
   
  
  
  
  1.88      +5 -6      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.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- DefaultEmbeddor.java	11 Jun 2002 06:11:29 -0000	1.87
  +++ DefaultEmbeddor.java	11 Jun 2002 07:45:11 -0000	1.88
  @@ -50,7 +50,6 @@
   import org.apache.myrmidon.interfaces.library.Library;
   import org.apache.myrmidon.interfaces.library.LibraryManager;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
   import org.apache.myrmidon.interfaces.property.NameValidatorManager;
   import org.apache.myrmidon.interfaces.property.PropertyResolver;
   import org.apache.myrmidon.interfaces.property.PropertyStore;
  @@ -258,13 +257,13 @@
           m_context = null;
       }
   
  -    public void execute( ExecutionFrame frame,
  -                         Project project,
  -                         Target target )
  +    public void execute( final ExecutionFrame frame,
  +                         final Project project,
  +                         final String target )
           throws TaskException
       {
           final Workspace workspace = createWorkspace( frame );
  -        workspace.execute( project.getProjectDescriptor(), target.getName() );
  +        workspace.execute( project.getProjectDescriptor(), target );
       }
   
       /**
  
  
  
  1.31      +2 -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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- DefaultEmbeddorTest.java	11 Jun 2002 07:12:26 -0000	1.30
  +++ DefaultEmbeddorTest.java	11 Jun 2002 07:45:11 -0000	1.31
  @@ -139,8 +139,7 @@
   
           // Execute the default target
           final String defaultTargetName = project.getDefaultTargetName();
  -        final Target target = project.getTarget( defaultTargetName );
  -        embeddor.execute( frame, project, target );
  +        embeddor.execute( frame, project, defaultTargetName );
   
           // Cleanup
           listener.assertComplete();
  
  
  
  1.86      +63 -18    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.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- DefaultWorkspace.java	11 Jun 2002 07:12:26 -0000	1.85
  +++ DefaultWorkspace.java	11 Jun 2002 07:45:11 -0000	1.86
  @@ -34,7 +34,6 @@
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   import org.apache.myrmidon.interfaces.workspace.ProjectRef;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
  -import org.apache.myrmidon.interfaces.oldmodel.Project;
   
   /**
    * This is the default implementation of Workspace.
  @@ -65,13 +64,6 @@
           m_frame = frame;
       }
   
  -    public void execute( final String projectURI,
  -                         final String target )
  -        throws TaskException
  -    {
  -        execute( new ProjectDescriptor( projectURI, null ), target );
  -    }
  -
       public void execute( final ProjectDescriptor descriptor,
                            final String targetName )
           throws TaskException
  @@ -80,21 +72,68 @@
           final Project project = entry.getProject();
   
           // First execute the implicit target.
  -        Target implicitTarget =
  -            project.getTarget( Project.IMPLICIT_TARGET_NAME );
  -        executeTarget( entry, implicitTarget );
  +        executeTarget( entry, Project.IMPLICIT_TARGET_NAME );
   
           // Now execute the called target.
  -        Target target = project.getTarget( targetName );
  +        executeTarget( entry, getTargetName( project, targetName ) );
  +    }
  +
  +    /**
  +     * Retrieve target with specified name from project.
  +     * If no such target exists then throw a TaskException.
  +     *
  +     * @param project the project
  +     * @param targetName the name of Target to retrieve
  +     * @return the Target object
  +     * @throws TaskException if unable to locate target
  +     */
  +    private Target getTarget( final Project project, final String targetName )
  +        throws TaskException
  +    {
  +        final Target target = project.getTarget( targetName );
           if( null == target )
           {
  -            final String defaultTargetName = project.getDefaultTargetName();
  -            target = project.getTarget( defaultTargetName );
  +            final String message =
  +                REZ.getString( "workspace.missing.target",
  +                               project.getProjectDescriptor().getUri(),
  +                               targetName );
  +            throw new TaskException( message );
           }
  +        return target;
  +    }
  +
  +    /**
  +     * Executes a target.  Does not execute the target if it has already been
  +     * executed.  Executes the implicit target, before executing
  +     * the target itself.
  +     *
  +     * @param targetName the name of the target
  +     * @param entry the project in which to execute
  +     * @throws TaskException if an error occurs
  +     */
  +    private void executeTarget( final ProjectEntry entry,
  +                                final String targetName )
  +        throws TaskException
  +    {
  +        final Project project = entry.getProject();
  +        final Target target = getTarget( project, targetName );
           executeTarget( entry, target );
       }
   
       /**
  +     * Get the target name to execute.
  +     */
  +    private String getTargetName( final Project project, final String specifiedName )
  +    {
  +        String name = specifiedName;
  +        if( null == specifiedName )
  +        {
  +            name = project.getDefaultTargetName();
  +        }
  +        return name;
  +    }
  +
  +    /**
        * Creates an execution frame for a project.
        */
       private ExecutionFrame createExecutionFrame( final Project project,
  @@ -238,6 +277,14 @@
           }
       }
   
  +    /**
  +     * Create a ProjectEntry for Project in specified frame.
  +     *
  +     * @param project the project
  +     * @param frame the frame
  +     * @return the new ProjectEntry
  +     * @throws TaskException if unable to create entry
  +     */
       private ProjectEntry createProjectEntry( final Project project, final ExecutionFrame
frame )
           throws TaskException
       {
  @@ -296,9 +343,7 @@
                                         final Target target )
           throws TaskException
       {
  -        final ModelElement targetModel =
  -            entry.getProject().getTarget( target.getName() ).getModel();
  -
  +        final ModelElement targetModel = target.getModel();
           final ExecutionFrame frame =
               entry.getFrame().createChildFrame( target.getName(), null, null, false );
           Executor executor;
  
  
  
  1.16      +1 -0      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace/Resources.properties,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Resources.properties	7 Jun 2002 05:48:20 -0000	1.15
  +++ Resources.properties	11 Jun 2002 07:45:11 -0000	1.16
  @@ -6,6 +6,7 @@
   exec-target.notice=Executing project {0}, target {1}.
   exec-task.notice=Executing task {0}.
   target-dependency-cycle.error=Cycle in dependencies for target {0}.
  +workspace.missing-target.error=Unable to locate target named "{1}" in project at "{0}".
   
   #DefaultTaskContext
   unknown-prop.error=Unknown property {0}.
  
  
  
  1.23      +4 -7      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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- EmbeddedAnt.java	11 Jun 2002 06:11:30 -0000	1.22
  +++ EmbeddedAnt.java	11 Jun 2002 07:45:11 -0000	1.23
  @@ -25,7 +25,6 @@
   import org.apache.myrmidon.interfaces.event.TaskEventManager;
   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.workspace.ProjectDescriptor;
   
   /**
  @@ -217,17 +216,15 @@
           //if we didn't specify a target, then choose default
           if( targets == null || targets.length == 0 )
           {
  -            final String defaultTargetName = project.getDefaultTargetName();
  -            final Target target = project.getTarget( defaultTargetName );
  +            final String targetName = project.getDefaultTargetName();
               //Next line an utter hack - need to rejif it completely
  -            m_embeddor.execute( frame, project, target );
  +            m_embeddor.execute( frame, project, targetName );
           }
           else
           {
               for( int i = 0; i < targets.length; i++ )
               {
  -                final Target target = project.getTarget( targets[ i ] );
  -                m_embeddor.execute( frame, project, target );
  +                m_embeddor.execute( frame, project, targets[ i ] );
               }
           }
       }
  
  
  
  1.23      +2 -3      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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Embeddor.java	11 Jun 2002 06:11:30 -0000	1.22
  +++ Embeddor.java	11 Jun 2002 07:45:11 -0000	1.23
  @@ -13,7 +13,6 @@
   import org.apache.myrmidon.api.metadata.ModelElement;
   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.workspace.ProjectDescriptor;
   
   /**
  @@ -61,6 +60,6 @@
   
       void execute( ExecutionFrame frame,
                     Project project,
  -                  Target target )
  +                  String target )
           throws TaskException;
   }
  
  
  
  1.18      +3 -5      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ExecuteTarget.java	11 Jun 2002 06:11:30 -0000	1.17
  +++ ExecuteTarget.java	11 Jun 2002 07:45:11 -0000	1.18
  @@ -18,7 +18,6 @@
   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.workspace.ProjectDescriptor;
   
   /**
  @@ -109,20 +108,19 @@
               targetName = project.getDefaultTargetName();
           }
   
  -        final Target target = project.getTarget( targetName );
           try
           {
               // TODO - need to be able to inherit services (TypeManager specifically)
               final ExecutionFrame frame =
                   embeddor.createExecutionFrame( properties );
  -            embeddor.execute( frame, project, target );
  +            embeddor.execute( frame, project, targetName );
           }
           catch( final Exception e )
           {
               final String message =
                   REZ.getString( "execute-targetName.execute.error",
                                  project.getProjectName(),
  -                               target.getName() );
  +                               targetName );
               throw new TaskException( message, e );
           }
       }
  
  
  
  1.27      +8 -18     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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Project.java	11 Jun 2002 07:16:30 -0000	1.26
  +++ Project.java	11 Jun 2002 07:45:11 -0000	1.27
  @@ -8,11 +8,6 @@
   package org.apache.myrmidon.interfaces.oldmodel;
   
   import java.io.File;
  -import org.apache.avalon.excalibur.i18n.ResourceManager;
  -import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.myrmidon.api.TaskException;
  -import org.apache.myrmidon.interfaces.oldmodel.Target;
  -import org.apache.myrmidon.interfaces.oldmodel.AbstractUnit;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   import org.apache.myrmidon.interfaces.workspace.ProjectRef;
   
  @@ -25,9 +20,6 @@
   public class Project
       extends AbstractUnit
   {
  -    private static final Resources REZ =
  -        ResourceManager.getPackageResources( Project.class );
  -
       public static final String IMPLICIT_TARGET_NAME = "<init>";
   
       /**
  @@ -59,12 +51,12 @@
        * Create a project object specifying all parameters.
        */
       public Project( final String name,
  -                           final String description,
  -                           final ProjectDescriptor descriptor,
  -                           final File baseDirectory,
  -                           final String defaultTarget,
  -                           final ProjectRef[] projectRefs,
  -                           final Target[] targets )
  +                    final String description,
  +                    final ProjectDescriptor descriptor,
  +                    final File baseDirectory,
  +                    final String defaultTarget,
  +                    final ProjectRef[] projectRefs,
  +                    final Target[] targets )
       {
           super( name, description );
   
  @@ -155,7 +147,6 @@
        * Retrieve a target by name.
        */
       public final Target getTarget( final String targetName )
  -        throws TaskException
       {
           for( int i = 0; i < m_targets.length; i++ )
           {
  @@ -166,7 +157,6 @@
               }
           }
   
  -        final String message = REZ.getString( "project.unknown-target.error", targetName
);
  -        throw new TaskException( message );
  +        return null;
       }
   }
  
  
  

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