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/workspace ProjectDescriptor.java
Date Thu, 13 Jun 2002 06:17:54 GMT
donaldp     2002/06/12 23:17:53

  Modified:    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
                        EmbeddedAnt.java
               container/src/java/org/apache/myrmidon/interfaces/workspace
                        ProjectDescriptor.java
  Log:
  Store the Project objects in the PropertyStore so thta frontends can supply them. If frontend
does not supply them then they will be loaded via standard mechanisms.
  
  Revision  Changes    Path
  1.95      +13 -3     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.94
  retrieving revision 1.95
  diff -u -r1.94 -r1.95
  --- DefaultEmbeddor.java	13 Jun 2002 05:18:59 -0000	1.94
  +++ DefaultEmbeddor.java	13 Jun 2002 06:17:53 -0000	1.95
  @@ -121,8 +121,6 @@
                                                   final Project[] projects )
           throws Exception
       {
  -        //TODO: Handle projects parameters
  -
           // setup a service manager that creates the project services
           final ServiceManager projServiceManager =
               (ServiceManager)createService( ServiceManager.class,
  @@ -142,6 +140,18 @@
           final PropertyStore propStore = m_rootProps.createChildStore();
           manager.put( PropertyStore.ROLE, propStore );
           addToStore( propStore, properties );
  +
  +        if( null != projects )
  +        {
  +            for( int i = 0; i < projects.length; i++ )
  +            {
  +                final Project project = projects[ i ];
  +                final ProjectDescriptor descriptor = project.getProjectDescriptor();
  +                final String key =
  +                    Project.KEY + '-' + descriptor.toKey();
  +                propStore.setProperty( key, projects[ i ] );
  +            }
  +        }
   
           return new DefaultExecutionFrame( "",
                                             new File( "." ),
  
  
  
  1.89      +30 -6     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.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- DefaultWorkspace.java	13 Jun 2002 02:59:26 -0000	1.88
  +++ DefaultWorkspace.java	13 Jun 2002 06:17:53 -0000	1.89
  @@ -251,7 +251,7 @@
           ProjectEntry entry = (ProjectEntry)m_entries.get( descriptor );
           if( null == entry )
           {
  -            final Project project = createProject( descriptor );
  +            final Project project = getProject( descriptor );
               entry = createProjectEntry( project, m_frame );
               m_entries.put( descriptor, entry );
           }
  @@ -259,20 +259,44 @@
           return entry;
       }
   
  -    private Project createProject( final ProjectDescriptor project )
  +    private Project getProject( final ProjectDescriptor descriptor )
  +        throws TaskException
  +    {
  +        final ServiceManager serviceManager = m_frame.getServiceManager();
  +        final String key = Project.KEY + '-' + descriptor.toKey();
  +        try
  +        {
  +            final PropertyStore propertyStore =
  +                (PropertyStore)serviceManager.lookup( PropertyStore.ROLE );
  +            if( propertyStore.isPropertySet( key ) )
  +            {
  +                return (Project)propertyStore.getProperty( key );
  +            }
  +            else
  +            {
  +                return createProject( descriptor );
  +            }
  +        }
  +        catch( final ServiceException se )
  +        {
  +            throw new TaskException( se.getMessage(), se );
  +        }
  +    }
  +
  +    private Project createProject( final ProjectDescriptor descriptor )
           throws TaskException
       {
           try
           {
               final ServiceManager serviceManager = m_frame.getServiceManager();
               final Embeddor embeddor = (Embeddor)serviceManager.lookup( Embeddor.ROLE );
  -            return embeddor.createProject( project );
  +            return embeddor.createProject( descriptor );
           }
           catch( final Exception e )
           {
               final String message =
  -                REZ.getString( "nobuild-project.error",
  -                               project.getUri() );
  +                REZ.getString( "nobuild-descriptor.error",
  +                               descriptor.getUri() );
               throw new TaskException( message, e );
           }
       }
  
  
  
  1.29      +7 -8      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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- EmbeddedAnt.java	13 Jun 2002 05:18:59 -0000	1.28
  +++ EmbeddedAnt.java	13 Jun 2002 06:17:53 -0000	1.29
  @@ -149,14 +149,14 @@
   
           // Prepare the embeddor, and project model
           final Embeddor embeddor = prepareEmbeddor( embeddorParameters );
  -        final ProjectDescriptor project = prepareProjectDescriptor();
  +        final ProjectDescriptor descriptor = prepareProjectDescriptor();
   
           final ExecutionFrame frame =
               embeddor.createExecutionFrame( m_workspaceProperties, null );
           prepareListeners( embeddor, frame );
   
           //execute the project
  -        executeTargets( frame, project, targets );
  +        executeTargets( frame, descriptor, targets );
       }
   
       /**
  @@ -183,22 +183,21 @@
        * Actually do the build.
        */
       private void executeTargets( final ExecutionFrame frame,
  -                                 final ProjectDescriptor project,
  +                                 final ProjectDescriptor descriptor,
                                    final String[] targets )
           throws TaskException
       {
  -        //if we didn't specify a target, then choose default
           if( targets == null || targets.length == 0 )
           {
  -            //final String targetName = project.getDefaultTargetName();
  +            //final String targetName = descriptor.getDefaultTargetName();
               //Next line an utter hack - need to rejif it completely
  -            m_embeddor.execute( frame, project, null );
  +            m_embeddor.execute( frame, descriptor, null );
           }
           else
           {
               for( int i = 0; i < targets.length; i++ )
               {
  -                m_embeddor.execute( frame, project, targets[ i ] );
  +                m_embeddor.execute( frame, descriptor, targets[ i ] );
               }
           }
       }
  
  
  
  1.5       +14 -1     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProjectDescriptor.java	13 Jun 2002 05:51:55 -0000	1.4
  +++ ProjectDescriptor.java	13 Jun 2002 06:17:53 -0000	1.5
  @@ -167,4 +167,17 @@
               return m_uri.hashCode() + m_type.hashCode();
           }
       }
  +
  +    public String toKey()
  +    {
  +        final StringBuffer sb = new StringBuffer();
  +        if( null != m_type )
  +        {
  +            sb.append( m_type );
  +            sb.append( '.' );
  +        }
  +        sb.append( m_uri.hashCode() );
  +
  +        return sb.toString();
  +    }
   }
  
  
  

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