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/ant1compat/src/java/org/apache/tools/ant/taskdefs CallTarget.java
Date Tue, 25 Jun 2002 14:45:55 GMT
adammurdoch    2002/06/25 07:45:55

  Modified:    antlib/src/test/org/apache/antlib/project/test ant-call.ant
               container/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java
               container/src/java/org/apache/myrmidon/interfaces/model
                        Project.java
               container/src/java/org/apache/myrmidon/interfaces/workspace
                        ProjectDescriptor.java
               framework/src/java/org/apache/myrmidon/framework/project
                        AbstractWorkspaceTask.java
               antlib/src/java/org/apache/antlib/project
                        AbstractAntTask.java AntCallTask.java
               ant1compat/src/java/org/apache/tools/ant/taskdefs
                        CallTarget.java
  Log:
  - Set the Project object as a single property, rather than setting a property for
    each reference.
  - Changed various tasks to look up references by using the Project object.
  - A bunch of changes to Project, to fit the XPath stuff better.  Use a shorter key.
  
  Revision  Changes    Path
  1.2       +4 -4      jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/project/test/ant-call.ant
  
  Index: ant-call.ant
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/test/org/apache/antlib/project/test/ant-call.ant,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ant-call.ant	25 Jun 2002 11:23:29 -0000	1.1
  +++ ant-call.ant	25 Jun 2002 14:45:54 -0000	1.2
  @@ -37,8 +37,8 @@
       <!-- Call unknown target -->
       <target name="unknown-target">
           <expect-error>
  -            <exc>Execution of target "no-such-target" in project "${project.uri}"
failed.</exc>
  -            <exc>No target named "no-such-target" in project "${project.uri}".</exc>
  +            <exc>Execution of target "no-such-target" in project "${myrmidon.project/projectDescriptor/uri}"
failed.</exc>
  +            <exc>No target named "no-such-target" in project "${myrmidon.project/projectDescriptor/uri}".</exc>
               <tasks>
                   <ant-call target="no-such-target"/>
               </tasks>
  @@ -80,8 +80,8 @@
       <!-- Call an unknown target in a referenced project -->
       <target name="ref-unknown-target">
           <expect-error>
  -            <exc>Execution of target "no-such-target" in project "${projectref.common.uri}"
failed.</exc>
  -            <exc>No target named "no-such-target" in project "${projectref.common.uri}".</exc>
  +            <exc>Execution of target "no-such-target" in project "${myrmidon.project/projectRefs/common/project/uri}"
failed.</exc>
  +            <exc>No target named "no-such-target" in project "${myrmidon.project/projectRefs/common/project/uri}".</exc>
               <tasks>
                   <ant-call project="common" target="no-such-target"/>
               </tasks>
  
  
  
  1.106     +1 -2      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.105
  retrieving revision 1.106
  diff -u -r1.105 -r1.106
  --- DefaultEmbeddor.java	24 Jun 2002 01:50:01 -0000	1.105
  +++ DefaultEmbeddor.java	25 Jun 2002 14:45:54 -0000	1.106
  @@ -31,7 +31,6 @@
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.api.event.TaskListener;
   import org.apache.myrmidon.api.metadata.ModelElement;
  -import org.apache.myrmidon.components.deployer.DefaultDeployer;
   import org.apache.myrmidon.components.executor.DefaultExecutionFrame;
   import org.apache.myrmidon.components.property.DefaultPropertyStore;
   import org.apache.myrmidon.components.role.DefaultRoleManager;
  
  
  
  1.101     +3 -21     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.100
  retrieving revision 1.101
  diff -u -r1.100 -r1.101
  --- DefaultWorkspace.java	25 Jun 2002 11:22:42 -0000	1.100
  +++ DefaultWorkspace.java	25 Jun 2002 14:45:55 -0000	1.101
  @@ -9,6 +9,7 @@
   
   import java.util.HashMap;
   import java.util.Map;
  +import java.util.Iterator;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  @@ -140,26 +141,7 @@
   
               final PropertyStore propertyStore =
                   (PropertyStore)childFrame.lookup( PropertyStore.ROLE );
  -            propertyStore.setProperty( ProjectDescriptor.KEY,
  -                                       project.getProjectDescriptor() );
  -            final ProjectRef[] refs = project.getProjectRefs();
  -            for( int i = 0; i < refs.length; i++ )
  -            {
  -                final ProjectRef ref = refs[ i ];
  -                final String key = ProjectDescriptor.KEY + "-" + ref.getName();
  -                propertyStore.setProperty( key, ref.getProject() );
  -            }
  -
  -            // Set some standard properties
  -            // TODO - use an expression language to introspect the Project object directly.
  -            propertyStore.setProperty( "project.name", project.getName() );
  -            propertyStore.setProperty( "project.basedir", project.getBaseDirectory() );
  -            propertyStore.setProperty( "project.uri", project.getProjectDescriptor().getUri()
);
  -            for( int i = 0; i < refs.length; i++ )
  -            {
  -                final ProjectRef ref = refs[ i ];
  -                propertyStore.setProperty( "projectref." + ref.getName() + ".uri", ref.getProject().getUri()
);
  -            }
  +            propertyStore.setProperty( Project.KEY, project );
   
               return childFrame;
           }
  
  
  
  1.13      +45 -20    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/model/Project.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Project.java	13 Jun 2002 05:53:11 -0000	1.12
  +++ Project.java	25 Jun 2002 14:45:55 -0000	1.13
  @@ -8,6 +8,8 @@
   package org.apache.myrmidon.interfaces.model;
   
   import java.io.File;
  +import java.util.Map;
  +import java.util.HashMap;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   
   /**
  @@ -19,7 +21,7 @@
   public class Project
       extends AbstractUnit
   {
  -    public final static String KEY = Project.class.getName();
  +    public final static String KEY = "myrmidon.project";
   
       public static final String IMPLICIT_TARGET_NAME = "<init>";
   
  @@ -41,12 +43,12 @@
       /**
        * The set of projectRefs that this Project uses.
        */
  -    private final ProjectRef[] m_projectRefs;
  +    private final Map m_projectRefs;
   
       /**
        * The set of targets for this project.
        */
  -    private final Target[] m_targets;
  +    private final Map m_targets;
   
       /**
        * Create a project object specifying all parameters.
  @@ -90,8 +92,22 @@
           m_descriptor = descriptor;
           m_baseDirectory = baseDirectory;
           m_defaultTarget = defaultTarget;
  -        m_projectRefs = projectRefs;
  -        m_targets = targets;
  +
  +        final HashMap refMap = new HashMap();
  +        for( int i = 0; i < projectRefs.length; i++ )
  +        {
  +            final ProjectRef projectRef = projectRefs[ i ];
  +            refMap.put( projectRef.getName(), projectRef );
  +        }
  +        m_projectRefs = refMap;
  +
  +        final HashMap targetMap = new HashMap();
  +        for( int i = 0; i < targets.length; i++ )
  +        {
  +            final Target target = targets[ i ];
  +            targetMap.put( target.getName(), target );
  +        }
  +        m_targets = targetMap;
       }
   
       /**
  @@ -135,29 +151,38 @@
       }
   
       /**
  -     * Return the array of all the {@link ProjectRef} objects in project.
  +     * Returns a read-only map of all the {@link ProjectRef} objects in project.
        *
  -     * @return the array of all the {@link ProjectRef} objects in project.
  +     * @return A map from project reference name to {@link ProjectRef}.
        */
  -    public ProjectRef[] getProjectRefs()
  +    public Map getProjectRefs()
       {
           return m_projectRefs;
       }
   
       /**
  -     * Retrieve a target by name.
  +     * Retrieve a project ref by name.
        */
  -    public final Target getTarget( final String targetName )
  +    public ProjectRef getProjectRef( final String name )
       {
  -        for( int i = 0; i < m_targets.length; i++ )
  -        {
  -            final Target target = m_targets[ i ];
  -            if( target.getName().equals( targetName ) )
  -            {
  -                return target;
  -            }
  -        }
  +        return (ProjectRef)m_projectRefs.get( name );
  +    }
   
  -        return null;
  +    /**
  +     * Returns a read-only map of all the {@link Target} objects in project.
  +     *
  +     * @return A map from target name to {@link Target}.
  +     */
  +    public Map getTargets()
  +    {
  +        return m_targets;
  +    }
  +
  +    /**
  +     * Retrieve a target by name.
  +     */
  +    public Target getTarget( final String targetName )
  +    {
  +        return (Target)m_targets.get( targetName );
       }
   }
  
  
  
  1.6       +1 -3      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/ProjectDescriptor.java
  
  Index: ProjectDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/ProjectDescriptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ProjectDescriptor.java	13 Jun 2002 06:17:53 -0000	1.5
  +++ ProjectDescriptor.java	25 Jun 2002 14:45:55 -0000	1.6
  @@ -16,8 +16,6 @@
    */
   public class ProjectDescriptor
   {
  -    public final static String KEY = ProjectDescriptor.class.getName();
  -
       private final String m_uri;
       private final String m_type;
   
  
  
  
  1.2       +11 -12    jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/project/AbstractWorkspaceTask.java
  
  Index: AbstractWorkspaceTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/framework/src/java/org/apache/myrmidon/framework/project/AbstractWorkspaceTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractWorkspaceTask.java	11 Jun 2002 13:20:15 -0000	1.1
  +++ AbstractWorkspaceTask.java	25 Jun 2002 14:45:55 -0000	1.2
  @@ -14,6 +14,8 @@
   import org.apache.myrmidon.framework.project.Dependency;
   import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
   import org.apache.myrmidon.interfaces.workspace.Workspace;
  +import org.apache.myrmidon.interfaces.model.Project;
  +import org.apache.myrmidon.interfaces.model.ProjectRef;
   
   /**
    * An abstract class used to execute Ant files within same workspace.
  @@ -75,22 +77,19 @@
       protected ProjectDescriptor getProjectDescriptor( final String projectName )
           throws TaskException
       {
  -        String key = ProjectDescriptor.KEY;
  -        if( null != projectName )
  +        final Project project = (Project)getContext().getProperty( Project.KEY );
  +        if( projectName == null )
           {
  -            key += "-" + projectName;
  +            return project.getProjectDescriptor();
           }
  -        final ProjectDescriptor project = (ProjectDescriptor)getContext().getProperty(
key );
  -        if( null == project )
  +
  +        final ProjectRef projectRef = project.getProjectRef( projectName );
  +        if( null == projectRef )
           {
               final String message =
  -                REZ.getString( "workspace.missing-ref.error",
  -                               projectName );
  +                REZ.getString( "workspace.missing-ref.error", projectName );
               throw new TaskException( message );
           }
  -        else
  -        {
  -            return project;
  -        }
  +        return projectRef.getProject();
       }
   }
  
  
  
  1.4       +3 -3      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractAntTask.java
  
  Index: AbstractAntTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AbstractAntTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractAntTask.java	4 Jun 2002 12:32:21 -0000	1.3
  +++ AbstractAntTask.java	25 Jun 2002 14:45:55 -0000	1.4
  @@ -7,9 +7,9 @@
    */
   package org.apache.antlib.project;
   
  -import org.apache.myrmidon.api.AbstractTask;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.framework.ExecuteTarget;
  +import org.apache.myrmidon.framework.project.AbstractWorkspaceTask;
   
   /**
    * Abstract base class for Tasks which execute targets.
  @@ -19,7 +19,7 @@
    * @version $Revision$ $Date$
    */
   public abstract class AbstractAntTask
  -    extends AbstractTask
  +    extends AbstractWorkspaceTask
   {
       private final ExecuteTarget m_exe = new ExecuteTarget();
   
  
  
  
  1.9       +1 -31     jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AntCallTask.java
  
  Index: AntCallTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/AntCallTask.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AntCallTask.java	25 Jun 2002 11:15:56 -0000	1.8
  +++ AntCallTask.java	25 Jun 2002 14:45:55 -0000	1.9
  @@ -48,34 +48,4 @@
           final ProjectDescriptor project = getProjectDescriptor( m_projectName );
           exe.setProject( project );
       }
  -
  -    /**
  -     * Get project descriptor for projecName.
  -     * If projecName is null then return descriptor for current project else
  -     * return descriptor for project referenced by current project.
  -     *
  -     * @param projectName the project to get descriptor for
  -     * @return the descriptor
  -     * @throws TaskException if unable to locate descriptor
  -     */
  -    protected ProjectDescriptor getProjectDescriptor( final String projectName )
  -        throws TaskException
  -    {
  -        String key = ProjectDescriptor.KEY;
  -        if( null != projectName )
  -        {
  -            key += "-" + projectName;
  -        }
  -        final ProjectDescriptor project = (ProjectDescriptor)getContext().getProperty(
key );
  -        if( null == project )
  -        {
  -            final String message =
  -                REZ.getString( "antcall.missing-ref.error", projectName );
  -            throw new TaskException( message );
  -        }
  -        else
  -        {
  -            return project;
  -        }
  -    }
   }
  
  
  
  1.7       +4 -5      jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs/CallTarget.java
  
  Index: CallTarget.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/src/java/org/apache/tools/ant/taskdefs/CallTarget.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CallTarget.java	11 Jun 2002 03:59:48 -0000	1.6
  +++ CallTarget.java	25 Jun 2002 14:45:55 -0000	1.7
  @@ -9,7 +9,7 @@
   
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.framework.ExecuteTarget;
  -import org.apache.myrmidon.interfaces.workspace.ProjectDescriptor;
  +import org.apache.myrmidon.interfaces.model.Project;
   
   /**
    * The Ant1Compat version of the &lt;antcall&gt; task, which delegates to the
  @@ -35,8 +35,7 @@
        */
       protected void prepare( final ExecuteTarget exe ) throws TaskException
       {
  -        final ProjectDescriptor project =
  -            (ProjectDescriptor)m_context.getProperty( ProjectDescriptor.KEY );
  -        exe.setProject( project );
  +        final Project project = (Project)m_context.getProperty( Project.KEY );
  +        exe.setProject( project.getProjectDescriptor() );
       }
   }
  
  
  

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