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/antlib/src/java/org/apache/antlib/project ProjectRefTask.java Resources.properties
Date Thu, 04 Jul 2002 01:18:13 GMT
donaldp     2002/07/03 18:18:13

  Modified:    container/src/java/org/apache/myrmidon/components/workspace
                        DefaultWorkspace.java ProjectEntry.java
               container/src/java/org/apache/myrmidon/interfaces/workspace
                        ProjectRefSet.java
               antlib/src/java/org/apache/antlib/project
                        ProjectRefTask.java Resources.properties
  Log:
  Move ProjectRefSet outside of ProjectEntry and move all logic to tasks that build refset
  
  Revision  Changes    Path
  1.113     +4 -3      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.112
  retrieving revision 1.113
  diff -u -r1.112 -r1.113
  --- DefaultWorkspace.java	3 Jul 2002 23:53:33 -0000	1.112
  +++ DefaultWorkspace.java	4 Jul 2002 01:18:13 -0000	1.113
  @@ -89,7 +89,8 @@
           if( projectName != null )
           {
               // A target in a referenced project
  -            final ProjectRef otherProject = entry.getProjectRef( projectName );
  +            final ProjectRefSet projectRefSet = entry.getProjectRefSet();
  +            final ProjectRef otherProject = projectRefSet.getProjectRef( projectName );
               if( otherProject == null )
               {
                   final String message = REZ.getString( "no-project.error", projectName );
  @@ -268,7 +269,7 @@
           final PropertyStore propertyStore =
               (PropertyStore)projectContext.getService( PropertyStore.class );
           propertyStore.setProperty( Project.KEY, project );
  -        propertyStore.setProperty( ProjectRefSet.KEY, entry );
  +        propertyStore.setProperty( ProjectRefSet.KEY, entry.getProjectRefSet() );
           propertyStore.setProperty( TargetSet.KEY, entry );
   
           return entry;
  
  
  
  1.23      +11 -59    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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- ProjectEntry.java	4 Jul 2002 00:29:15 -0000	1.22
  +++ ProjectEntry.java	4 Jul 2002 01:18:13 -0000	1.23
  @@ -30,7 +30,7 @@
    * @version $Revision$ $Date$
    */
   public class ProjectEntry
  -    implements ProjectRefSet, TargetSet
  +    implements TargetSet
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( ProjectEntry.class );
  @@ -48,10 +48,8 @@
       private final Map m_targets = new HashMap();
   
       /** Map from project ref name -> ProjectRef. */
  -    private final Map m_projectRefs = new HashMap();
  +    private final ProjectRefSet m_projectRefSet;
   
  -    /** Self reference to the project. */
  -    private final ProjectRef m_selfRef;
       private TaskContext m_taskContext;
   
       public ProjectEntry( final Project project,
  @@ -93,8 +91,9 @@
           }
   
           // Add a reference to self
  -        m_selfRef = new ProjectRef( project.getName(), project.getProjectDescriptor() );
  -        addProjectRef( m_selfRef );
  +        final ProjectRef self = new ProjectRef( project.getName(), project.getProjectDescriptor()
);
  +        m_projectRefSet = new ProjectRefSet( self );
  +        m_projectRefSet.addProjectRef( self );
       }
   
       public Project getProject()
  @@ -103,58 +102,6 @@
       }
   
       /**
  -     * Returns a read-only map of all the {@link org.apache.myrmidon.interfaces.workspace.ProjectRef}
objects in project.
  -     *
  -     * @return A map from project reference name to {@link org.apache.myrmidon.interfaces.workspace.ProjectRef}.
  -     *
  -     * @todo Return an unmodifiable wrapper.  For some reason JXPath won't
  -     *       introspect the wrapper returned by Collections.unmodifiableMap().
  -     *       Need to investigate more.
  -     */
  -    public Map getProjectRefs()
  -    {
  -        return m_projectRefs;
  -    }
  -
  -    /**
  -     * Retrieve a project ref by name.
  -     */
  -    public ProjectRef getProjectRef( final String name )
  -    {
  -        if( null == name )
  -        {
  -            return m_selfRef;
  -        }
  -        return (ProjectRef)m_projectRefs.get( name );
  -    }
  -
  -    /**
  -     * Adds a project reference to this project.
  -     */
  -    public void addProjectRef( final ProjectRef ref )
  -        throws TaskException
  -    {
  -        // Validate reference
  -        final String name = ref.getName();
  -        try
  -        {
  -            m_projectValidator.validate( name );
  -        }
  -        catch( final Exception e )
  -        {
  -            final String message = REZ.getString( "bad-projectref-name.error", name );
  -            throw new TaskException( message, e );
  -        }
  -        if( m_projectRefs.containsKey( name ) )
  -        {
  -            final String message = REZ.getString( "duplicate-projectrefs.error", name );
  -            throw new TaskException( message );
  -        }
  -
  -        m_projectRefs.put( ref.getName(), ref );
  -    }
  -
  -    /**
        * Returns all the targets of the current project.
        *
        * @return A map from target name to {@link Target}.
  @@ -228,5 +175,10 @@
       public void setTargetState( final Target target, final TargetState state )
       {
           m_targetState.put( target, state );
  +    }
  +
  +    public ProjectRefSet getProjectRefSet()
  +    {
  +        return m_projectRefSet;
       }
   }
  
  
  
  1.2       +38 -6     jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/ProjectRefSet.java
  
  Index: ProjectRefSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/workspace/ProjectRefSet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProjectRefSet.java	2 Jul 2002 10:48:38 -0000	1.1
  +++ ProjectRefSet.java	4 Jul 2002 01:18:13 -0000	1.2
  @@ -8,6 +8,7 @@
   package org.apache.myrmidon.interfaces.workspace;
   
   import java.util.Map;
  +import java.util.HashMap;
   import org.apache.myrmidon.api.TaskException;
   
   /**
  @@ -17,16 +18,36 @@
    * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
    * @version $Revision$ $Date$
    */
  -public interface ProjectRefSet
  +public class ProjectRefSet
   {
  -    String KEY = "myrmidon.projectrefs";
  +    public final static String KEY = "myrmidon.projectrefs";
  +
  +    /**
  +     * Reference to the project that constructed set.
  +     */
  +    private final ProjectRef m_self;
  +
  +    /** Map from project ref name -> ProjectRef. */
  +    private final Map m_projectRefs = new HashMap();
  +
  +    public ProjectRefSet( final ProjectRef self )
  +    {
  +        m_self = self;
  +    }
   
       /**
        * Returns all the project references of the current project.
        *
        * @return A map from project reference name to {@link ProjectRef}.
  +     *
  +     * @todo Return an unmodifiable wrapper.  For some reason JXPath won't
  +     *       introspect the wrapper returned by Collections.unmodifiableMap().
  +     *       Need to investigate more.
        */
  -    Map getProjectRefs();
  +    public Map getProjectRefs()
  +    {
  +        return m_projectRefs;
  +    }
   
       /**
        * Retrieve a project reference by name.
  @@ -34,10 +55,21 @@
        * @param name The name of the project to get.  Use null for a reference to
        * the current project.
        */
  -    ProjectRef getProjectRef( final String name );
  +    public ProjectRef getProjectRef( final String name )
  +    {
  +        if( null == name )
  +        {
  +            return m_self;
  +        }
  +        return (ProjectRef)m_projectRefs.get( name );
  +    }
   
       /**
        * Adds a project reference to the current project.
        */
  -    void addProjectRef( final ProjectRef ref ) throws TaskException;
  +    public void addProjectRef( final ProjectRef ref )
  +        throws TaskException
  +    {
  +        m_projectRefs.put( ref.getName(), ref );
  +    }
   }
  
  
  
  1.4       +12 -4     jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/ProjectRefTask.java
  
  Index: ProjectRefTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/ProjectRefTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProjectRefTask.java	4 Jul 2002 00:36:37 -0000	1.3
  +++ ProjectRefTask.java	4 Jul 2002 01:18:13 -0000	1.4
  @@ -80,8 +80,17 @@
           {
               final String message =
                   REZ.getString( "projectref.bad-name.error",
  -                               m_name,
  -                               e );
  +                               m_name );
  +            throw new TaskException( message );
  +        }
  +
  +        final ProjectRefSet projectRefs = (ProjectRefSet)getContext().getProperty( ProjectRefSet.KEY
);
  +
  +        if( null != projectRefs.getProjectRef( m_name ) )
  +        {
  +            final String message =
  +                REZ.getString( "projectref.duplicate-name.error",
  +                               m_name );
               throw new TaskException( message );
           }
   
  @@ -89,7 +98,6 @@
           final ProjectDescriptor descriptor = new ProjectDescriptor( uri, m_type );
           final ProjectRef ref = new ProjectRef( m_name, descriptor );
   
  -        final ProjectRefSet projectRefs = (ProjectRefSet)getContext().getProperty( ProjectRefSet.KEY
);
           projectRefs.addProjectRef( ref );
       }
   
  
  
  
  1.16      +3 -1      jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/Resources.properties,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Resources.properties	27 Jun 2002 11:13:08 -0000	1.15
  +++ Resources.properties	4 Jul 2002 01:18:13 -0000	1.16
  @@ -9,4 +9,6 @@
   antcall.missing-ref.error=Unknown project reference "{0}".
   
   projectref.no-name.error=No project name specified.
  -projectref.no-location.error=No project location specified.
  \ No newline at end of file
  +projectref.no-location.error=No project location specified.
  +projectref.bad-name.error=Invalid project reference name "{0}".
  +projectref.duplicate-name.error=Multiple project references with name "{0}".
  \ No newline at end of file
  
  
  

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