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/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer Configurer.java DefaultConfigurer.java
Date Mon, 28 May 2001 09:06:52 GMT
donaldp     01/05/28 02:06:52

  Modified:    proposal/myrmidon/src/java/org/apache/ant Main.java
               proposal/myrmidon/src/java/org/apache/ant/modules/basic
                        AntCall.java Property.java
               proposal/myrmidon/src/java/org/apache/ant/project
                        DefaultProject.java DefaultProjectBuilder.java
                        DefaultProjectEngine.java Project.java
                        ProjectEngine.java
               proposal/myrmidon/src/java/org/apache/ant/runtime
                        DefaultAntEngine.java
               proposal/myrmidon/src/java/org/apache/ant/tasklet/engine
                        DefaultTaskletEngine.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer
                        DefaultConfigurer.java
  Added:       proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer
                        Configurer.java
  Removed:     proposal/myrmidon/src/java/org/apache/myrmidon/components
                        Configurer.java
  Log:
  Removed instance data from Project object. This allows reuse of Project objects ... is this
required ???
  
  Revision  Changes    Path
  1.13      +14 -6     jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/Main.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Main.java	2001/05/28 08:16:02	1.12
  +++ Main.java	2001/05/28 09:06:45	1.13
  @@ -32,6 +32,7 @@
   import org.apache.ant.runtime.DefaultAntEngine;
   import org.apache.myrmidon.api.JavaVersion;
   import org.apache.myrmidon.api.TaskContext;
  +import org.apache.myrmidon.api.DefaultTaskContext;
   import org.apache.ant.tasklet.engine.TaskletEngine;
   import org.apache.avalon.excalibur.cli.CLArgsParser;
   import org.apache.avalon.excalibur.cli.CLOption;
  @@ -317,7 +318,6 @@
   
           //create the project
           final Project project = builder.build( buildFile );
  -        setupProjectContext( project, defines );
   
           final ProjectEngine engine = antEngine.getProjectEngine();
           engine.addProjectListener( listener );
  @@ -328,8 +328,15 @@
           while( true )
           {
               //actually do the build ...
  -            doBuild( engine, project, targets );
  +            final TaskContext context = new DefaultTaskContext();
  +            setupContext( context, defines );
   
  +            context.setProperty( TaskContext.BASE_DIRECTORY, project.getBaseDirectory()
);
  +            context.setProperty( Project.PROJECT_FILE, buildFile );
  +            //context.setProperty( Project.PROJECT, projectName );
  +
  +            doBuild( engine, project, context, targets );
  +
               if( !incremental ) break;
   
               System.out.println( "Continue ? (Enter no to stop)" );
  @@ -357,6 +364,7 @@
        */
       protected void doBuild( final ProjectEngine engine,
                               final Project project,
  +                            final TaskContext context,
                               final ArrayList targets )
       {
           try
  @@ -366,13 +374,13 @@
               //if we didn't specify a target on CLI then choose default
               if( 0 == targetCount )
               {
  -                engine.execute( project, project.getDefaultTargetName() );
  +                engine.executeTarget( project, project.getDefaultTargetName(), context
);
               }
               else
               {
                   for( int i = 0; i < targetCount; i++ )
                   {
  -                    engine.execute( project, (String)targets.get( i ) );
  +                    engine.executeTarget( project, (String)targets.get( i ), context );
                   }
               }
           }
  @@ -483,7 +491,7 @@
        * @param defines the defines
        * @exception AntException if an error occurs
        */
  -    protected void setupProjectContext( final Project project, final HashMap defines )
  +    protected void setupContext( final TaskContext context, final HashMap defines )
           throws AntException
       {
           //put these values into defines so that they overide
  @@ -494,7 +502,7 @@
           //defines.put( AntContextResources.TASKLIB_DIR, m_taskLibDir );
           //defines.put( TaskletContext.JAVA_VERSION, getJavaVersion() );
   
  -        final TaskContext context = project.getContext();
  +        //final TaskContext context = project.getContext();
           addToContext( context, defines );
   
           //Add system properties second so that they overide user-defined properties
  
  
  
  1.4       +2 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/basic/AntCall.java
  
  Index: AntCall.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/basic/AntCall.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AntCall.java	2001/05/28 07:36:41	1.3
  +++ AntCall.java	2001/05/28 09:06:46	1.4
  @@ -82,6 +82,7 @@
           }
   
           getLogger().info( "Calling target " + m_target );
  -        m_projectEngine.execute( m_project, m_target, m_childContext );
  +        //This calls startProject() which is probably not wanted???
  +        m_projectEngine.executeTarget( m_project, m_target, m_childContext );
       }
   }
  
  
  
  1.5       +18 -18    jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/basic/Property.java
  
  Index: Property.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/modules/basic/Property.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Property.java	2001/05/28 08:16:06	1.4
  +++ Property.java	2001/05/28 09:06:46	1.5
  @@ -9,27 +9,27 @@
   
   import java.util.Iterator;
   import org.apache.ant.AntException;
  -import org.apache.myrmidon.components.Configurer;
   import org.apache.ant.convert.Converter;
   import org.apache.ant.tasklet.DataType;
   import org.apache.ant.tasklet.engine.DataTypeEngine;
  -import org.apache.myrmidon.api.AbstractTask;
  -import org.apache.myrmidon.api.TaskContext;
   import org.apache.ant.tasklet.engine.TaskletEngine;
  -import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.ComponentException;
  +import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.context.Resolvable;
  +import org.apache.myrmidon.api.AbstractTask;
  +import org.apache.myrmidon.api.TaskContext;
  +import org.apache.myrmidon.components.configurer.Configurer;
   
   /**
    * This is the property "task" to declare a binding of a datatype to a name.
  - * 
  + *
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
    */
  -public class Property 
  +public class Property
       extends AbstractTask
       implements Configurable, Composable
   {
  @@ -39,12 +39,12 @@
       protected DataTypeEngine      m_engine;
       protected Converter           m_converter;
       protected Configurer          m_configurer;
  -    
  +
       public void compose( final ComponentManager componentManager )
           throws ComponentException
       {
           m_configurer = (Configurer)componentManager.
  -            lookup( "org.apache.myrmidon.components.Configurer" );
  +            lookup( "org.apache.myrmidon.components.configurer.Configurer" );
   
           m_engine = (DataTypeEngine)componentManager.
               lookup( "org.apache.ant.tasklet.engine.DataTypeEngine" );
  @@ -71,9 +71,9 @@
   
               if( name.equals( "name" ) )
               {
  -                try 
  +                try
                   {
  -                    final String convertedValue = 
  +                    final String convertedValue =
                           (String)m_converter.convert( String.class, object, getContext()
);
                       setName( convertedValue );
                   }
  @@ -86,13 +86,13 @@
               {
                   setValue( object );
               }
  -            else if( name.equals( "local-scope" ) ) 
  +            else if( name.equals( "local-scope" ) )
               {
  -                try 
  +                try
                   {
  -                    final Boolean localScope = 
  +                    final Boolean localScope =
                           (Boolean)m_converter.convert( Boolean.class, object, getContext()
);
  -                    setLocalScope( Boolean.TRUE == localScope ); 
  +                    setLocalScope( Boolean.TRUE == localScope );
                   }
                   catch( final Exception e )
                   {
  @@ -128,7 +128,7 @@
       {
           m_name = name;
       }
  -    
  +
       public void setValue( final Object value )
           throws AntException
       {
  @@ -139,7 +139,7 @@
   
           m_value = value;
       }
  -    
  +
       public void setLocalScope( final boolean localScope )
       {
           m_localScope = localScope;
  
  
  
  1.4       +40 -24    jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProject.java
  
  Index: DefaultProject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProject.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultProject.java	2001/05/28 07:36:47	1.3
  +++ DefaultProject.java	2001/05/28 09:06:47	1.4
  @@ -24,19 +24,35 @@
   public class DefaultProject
       implements Project
   {
  -    protected final TaskContext          m_baseContext     = new DefaultTaskContext();
  -    protected final HashMap              m_targets         = new HashMap();
  -    protected Target                     m_implicitTarget;
  -    protected String                     m_defaultTarget;
  +    ///The targets contained by this project
  +    private final HashMap   m_targets         = new HashMap();
  +
  +    ///The implicit target (not present in m_targets)
  +    private Target          m_implicitTarget;
  +
  +    ///The name of the default target
  +    private String          m_defaultTarget;
  +
  +    ///The base directory of project
  +    private File            m_baseDirectory;
  +
  +    /**
  +     * Retrieve base directory of project.
  +     *
  +     * @return the projects base directory
  +     */
  +    public final File getBaseDirectory()
  +    {
  +        return m_baseDirectory;
  +    }
       
       /**
        * Retrieve implicit target. 
  -     * The implicit target is top level tasks. 
  -     * Currently restricted to property tasks.
  +     * The implicit target contains all the top level tasks. 
        *
        * @return the Target
        */
  -    public Target getImplicitTarget()
  +    public final Target getImplicitTarget()
       {
           return m_implicitTarget;
       }
  @@ -46,7 +62,7 @@
        *
        * @param target the implicit target
        */
  -    public void setImplicitTarget( final Target target )
  +    public final void setImplicitTarget( final Target target )
       {
           m_implicitTarget = target;
       }
  @@ -57,7 +73,7 @@
        * @param name the name of target
        * @return the Target or null if no target exists with name
        */
  -    public Target getTarget( final String targetName )
  +    public final Target getTarget( final String targetName )
       {
           return (Target)m_targets.get( targetName );
       }
  @@ -67,7 +83,7 @@
        *
        * @return the default target name
        */
  -    public String getDefaultTargetName()
  +    public final String getDefaultTargetName()
       {
           return m_defaultTarget;
       }
  @@ -75,31 +91,31 @@
       /**
        * Retrieve names of all targets in project.
        *
  -     * @return the iterator of project names
  +     * @return an array target names
        */
  -    public Iterator getTargetNames()
  +    public final String[] getTargetNames()
       {
  -        return m_targets.keySet().iterator();
  +        return (String[])m_targets.keySet().toArray( new String[ 0 ] );
       }
  -    
  +
       /**
  -     * Get project (top-level) context.
  +     * Set DefaultTargetName.
        *
  -     * @return the context
  -     */    
  -    public TaskContext getContext()
  +     * @param defaultTarget the default target name
  +     */
  +    public final void setDefaultTargetName( final String defaultTarget )
       {
  -        return m_baseContext;
  +        m_defaultTarget = defaultTarget;
       }
   
       /**
  -     * Set DefaultTargetName.
  +     * Retrieve base directory of project.
        *
  -     * @param defaultTarget the default target name
  +     * @return the projects base directory
        */
  -    public void setDefaultTargetName( final String defaultTarget )
  +    public final void setBaseDirectory( final File baseDirectory )
       {
  -        m_defaultTarget = defaultTarget;
  +        m_baseDirectory = baseDirectory;
       }
   
       /**
  @@ -109,7 +125,7 @@
        * @param target the Target
        * @exception AntException if an error occurs
        */
  -    public void addTarget( final String name, final Target target )
  +    public final void addTarget( final String name, final Target target )
           throws AntException
       {
           if( null != m_targets.get( name ) )
  
  
  
  1.6       +5 -8      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectBuilder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultProjectBuilder.java	2001/05/28 07:36:47	1.5
  +++ DefaultProjectBuilder.java	2001/05/28 09:06:47	1.6
  @@ -105,23 +105,20 @@
           //get project-level attributes
           final String baseDirectoryName = configuration.getAttribute( "basedir" );
           final String defaultTarget = configuration.getAttribute( "default" );
  -        final String projectName = configuration.getAttribute( "name" );
   
  +        //Ignore Project name in the future ok??
  +        //final String projectName = configuration.getAttribute( "name" );
  +
           //determine base directory for project
           final File baseDirectory =
               (new File( file.getParentFile(), baseDirectoryName )).getAbsoluteFile();
   
  -        getLogger().debug( "Project " + projectName + " base directory: " + baseDirectory
);
  +        getLogger().debug( "Project " + file + " base directory: " + baseDirectory );
   
           //create project and ...
           final DefaultProject project = new DefaultProject();
           project.setDefaultTargetName( defaultTarget );
  -
  -        //setup basic context of project
  -        final TaskContext context = project.getContext();
  -        context.setProperty( TaskContext.BASE_DIRECTORY, baseDirectory );
  -        context.setProperty( Project.PROJECT_FILE, file );
  -        context.setProperty( Project.PROJECT, projectName );
  +        project.setBaseDirectory( baseDirectory );
   
           //build using all top-level attributes
           buildTopLevelProject( project, configuration );
  
  
  
  1.9       +2 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectEngine.java
  
  Index: DefaultProjectEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectEngine.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultProjectEngine.java	2001/05/28 07:36:47	1.8
  +++ DefaultProjectEngine.java	2001/05/28 09:06:47	1.9
  @@ -81,13 +81,13 @@
        * @param target the name of the target
        * @exception AntException if an error occurs
        */
  -    public void execute( final Project project, final String target )
  +    public void executeTarget( final Project project, final String target, final TaskContext
context )
           throws AntException
       {
           //HACK: should do this a better way !!!!!!
           m_componentManager.put( "org.apache.ant.project.Project", project );
   
  -        final TaskContext context = project.getContext();
  +        //final TaskContext context = project.getContext();
   
           final String projectName = (String)context.getProperty( Project.PROJECT );
   
  
  
  
  1.6       +7 -8      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/Project.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Project.java	2001/05/28 07:36:47	1.5
  +++ Project.java	2001/05/28 09:06:47	1.6
  @@ -7,13 +7,12 @@
    */
   package org.apache.ant.project;
   
  -import java.util.Iterator;
  -import org.apache.ant.AntException;
  -import org.apache.myrmidon.api.TaskContext;
  +import java.io.File;
   import org.apache.avalon.framework.component.Component;
   
   /**
  - * Interface through which to interact with projects.
  + * Abstraction used to interact with projects.
  + * Implementations may choose to structure it anyway they choose. 
    *
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
    */
  @@ -58,12 +57,12 @@
        *
        * @return the iterator of project names
        */
  -    Iterator getTargetNames();
  +    String[] getTargetNames();
   
       /**
  -     * Get project (top-level) context.
  +     * Retrieve base directory of project.
        *
  -     * @return the context
  +     * @return the projects base directory
        */
  -    TaskContext getContext();
  +    File getBaseDirectory();
   }
  
  
  
  1.7       +1 -12     jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/ProjectEngine.java
  
  Index: ProjectEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/ProjectEngine.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ProjectEngine.java	2001/05/28 07:36:48	1.6
  +++ ProjectEngine.java	2001/05/28 09:06:47	1.7
  @@ -37,17 +37,6 @@
       void removeProjectListener( ProjectListener listener );
   
       /**
  -     * Execute a target in a particular project.
  -     * Execute in the project context.
  -     *
  -     * @param project the Project
  -     * @param target the name of the target
  -     * @exception AntException if an error occurs
  -     */
  -    void execute( Project project, String target )
  -        throws AntException;
  -
  -    /**
        * Execute a target in a particular project, in a particular context.
        *
        * @param project the Project
  @@ -55,6 +44,6 @@
        * @param context the context
        * @exception AntException if an error occurs
        */
  -    void execute( Project project, String target, TaskContext context )
  +    void executeTarget( Project project, String target, TaskContext context )
           throws AntException;
   }
  
  
  
  1.6       +2 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/runtime/DefaultAntEngine.java
  
  Index: DefaultAntEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/runtime/DefaultAntEngine.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultAntEngine.java	2001/05/28 08:16:07	1.5
  +++ DefaultAntEngine.java	2001/05/28 09:06:49	1.6
  @@ -10,7 +10,7 @@
   import java.io.File;
   import java.util.Properties;
   import org.apache.ant.AntException;
  -import org.apache.myrmidon.components.Configurer;
  +import org.apache.myrmidon.components.configurer.Configurer;
   import org.apache.ant.convert.engine.ConverterEngine;
   import org.apache.ant.project.ProjectBuilder;
   import org.apache.ant.project.ProjectEngine;
  @@ -193,7 +193,7 @@
           componentManager.put( "org.apache.ant.project.ProjectBuilder", m_builder );
           componentManager.put( "org.apache.ant.tasklet.engine.TskDeployer", m_deployer );
           componentManager.put( "org.apache.avalon.framework.camelot.Factory", m_factory
);
  -        componentManager.put( "org.apache.myrmidon.components.Configurer", m_configurer
);
  +        componentManager.put( "org.apache.myrmidon.components.configurer.Configurer", m_configurer
);
   
           return componentManager;
       }
  
  
  
  1.14      +2 -3      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletEngine.java
  
  Index: DefaultTaskletEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/tasklet/engine/DefaultTaskletEngine.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DefaultTaskletEngine.java	2001/05/28 08:16:09	1.13
  +++ DefaultTaskletEngine.java	2001/05/28 09:06:49	1.14
  @@ -34,8 +34,7 @@
   import org.apache.log.Logger;
   import org.apache.myrmidon.api.Task;
   import org.apache.myrmidon.api.TaskContext;
  -import org.apache.myrmidon.components.Configurer;
  -import org.apache.myrmidon.components.configurer.DefaultConfigurer;
  +import org.apache.myrmidon.components.configurer.Configurer;
   
   public class DefaultTaskletEngine
       extends AbstractLoggable
  @@ -91,7 +90,7 @@
           m_tskDeployer = (TskDeployer)componentManager.
               lookup( "org.apache.ant.tasklet.engine.TskDeployer" );
           m_configurer = (Configurer)componentManager.
  -            lookup( "org.apache.myrmidon.components.Configurer" );
  +            lookup( "org.apache.myrmidon.components.configurer.Configurer" );
           m_dataTypeEngine = (DataTypeEngine)componentManager.
               lookup( "org.apache.ant.tasklet.engine.DataTypeEngine" );
           m_converterEngine = (ConverterEngine)componentManager.
  
  
  
  1.2       +0 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultConfigurer.java
  
  Index: DefaultConfigurer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/DefaultConfigurer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultConfigurer.java	2001/05/28 08:16:12	1.1
  +++ DefaultConfigurer.java	2001/05/28 09:06:51	1.2
  @@ -25,7 +25,6 @@
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.logger.Loggable;
   import org.apache.log.Logger;
  -import org.apache.myrmidon.components.Configurer;
   
   /**
    * Class used to configure tasks.
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/configurer/Configurer.java
  
  Index: Configurer.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.myrmidon.components.configurer;
  
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.context.Context;
  
  /**
   * Class used to configure tasks.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public interface Configurer
      extends Component
  {
      /**
       * Configure an object based on a configuration in a particular context.
       * This configuring can be done in different ways for different
       * configurers.
       *
       * @param object the object
       * @param configuration the configuration
       * @param context the Context
       * @exception ConfigurationException if an error occurs
       */
      void configure( Object object, Configuration configuration, Context context )
          throws ConfigurationException;
  }
  
  
  

Mime
View raw message