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/frontends CLIMain.java
Date Wed, 27 Jun 2001 00:50:09 GMT
donaldp     01/06/26 17:50:09

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor
                        DefaultEmbeddor.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/executor
                        AspectAwareExecutor.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/manager
                        DefaultProjectManager.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/model
                        Target.java
               proposal/myrmidon/src/java/org/apache/myrmidon/framework
                        DataType.java Pattern.java
               proposal/myrmidon/src/java/org/apache/myrmidon/frontends
                        CLIMain.java
  Added:       proposal/myrmidon/src/java/org/apache/myrmidon/components/executor
                        PrintingExecutor.java
  Log:
  Integrate change of Condition package into rest of system.
  
  Add a new Executor and allow possibility of "dry runs". Ie runs that don't actually execute
commands.
  
  Revision  Changes    Path
  1.7       +2 -0      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java
  
  Index: DefaultEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/DefaultEmbeddor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultEmbeddor.java	2001/06/17 10:35:37	1.6
  +++ DefaultEmbeddor.java	2001/06/27 00:50:04	1.7
  @@ -132,6 +132,7 @@
   
           setupLogger( projectManager );
   
  +
           if( projectManager instanceof Composable )
           {
               final DefaultComponentManager componentManager =
  @@ -237,6 +238,7 @@
                                  "org.apache.myrmidon.components.type.DefaultTypeManager"
);
           defaults.setParameter( Executor.ROLE,
                                  //"org.apache.myrmidon.components.executor.DefaultExecutor"
);
  +                               //"org.apache.myrmidon.components.executor.PrintingExecutor"
);
                                  "org.apache.myrmidon.components.executor.AspectAwareExecutor"
);
           defaults.setParameter( ProjectManager.ROLE,
                                  "org.apache.myrmidon.components.manager.DefaultProjectManager"
);
  
  
  
  1.5       +7 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/AspectAwareExecutor.java
  
  Index: AspectAwareExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/AspectAwareExecutor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AspectAwareExecutor.java	2001/06/12 13:38:58	1.4
  +++ AspectAwareExecutor.java	2001/06/27 00:50:05	1.5
  @@ -95,11 +95,17 @@
   
           getLogger().debug( "Executing" );
           getAspectManager().preExecute();
  -        task.execute();
  +        doExecute( taskModel, task );
   
           getLogger().debug( "Disposing" );
           getAspectManager().preDestroy();
           doDispose( task, taskModel );
  +    }
  +
  +    protected void doExecute( final Configuration taskModel, final Task task )
  +        throws TaskException
  +    {
  +        task.execute();
       }
   
       //TODO: Extract and clean taskModel here.
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/executor/PrintingExecutor.java
  
  Index: PrintingExecutor.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.executor;
  
  import org.apache.myrmidon.api.Task;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.avalon.framework.configuration.Configuration;
  
  public class PrintingExecutor
      extends AspectAwareExecutor
  {
      protected void doExecute( final Configuration taskModel, final Task task )
          throws TaskException
      {
          final StringBuffer sb = new StringBuffer();
          printConfiguration( taskModel, 0, sb );
          
          System.out.println( sb.toString() );
      }
  
      private void printConfiguration( final Configuration taskModel, 
                                       final int level, 
                                       final StringBuffer sb )
      {
          for( int i = 0; i < level; i++ )
          {
              sb.append( ' ' );
          }
          
          sb.append( '<' );
          sb.append( taskModel.getName() );
  
  
          final String[] names = taskModel.getAttributeNames();
          for( int i = 0; i < names.length; i++ )
          {
              final String name = names[ i ];
              final String value = taskModel.getAttribute( name, null );
  
              sb.append( ' ' );
              sb.append( name );
              sb.append( "=\"" );
              sb.append( value );
              sb.append( '\"' );
          }
  
          final Configuration[] children = taskModel.getChildren();
          if( 0 == children.length )
          {
              sb.append( "/>\n" );
          }
          else
          {
              sb.append( ">\n" );
  
              for( int i = 0; i < children.length; i++ )
              {
                  printConfiguration( children[ i ], level + 1, sb );
              }
  
              for( int i = 0; i < level; i++ )
              {
                  sb.append( ' ' );
              }
  
              sb.append( "</" );
              sb.append( taskModel.getName() );
              sb.append( ">\n" );
          }
      }
  }
  
  
  
  1.10      +1 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/manager/DefaultProjectManager.java
  
  Index: DefaultProjectManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/manager/DefaultProjectManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultProjectManager.java	2001/06/17 10:35:39	1.9
  +++ DefaultProjectManager.java	2001/06/27 00:50:06	1.10
  @@ -29,7 +29,7 @@
   import org.apache.myrmidon.components.executor.DefaultExecutionFrame;
   import org.apache.myrmidon.components.executor.ExecutionFrame;
   import org.apache.myrmidon.components.executor.Executor;
  -import org.apache.myrmidon.components.model.Condition;
  +import org.apache.myrmidon.framework.Condition;
   import org.apache.myrmidon.components.model.Project;
   import org.apache.myrmidon.components.model.Target;
   import org.apache.myrmidon.components.type.TypeManager;
  
  
  
  1.5       +1 -0      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/model/Target.java
  
  Index: Target.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/model/Target.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Target.java	2001/06/12 13:39:31	1.4
  +++ Target.java	2001/06/27 00:50:07	1.5
  @@ -9,6 +9,7 @@
   
   import java.util.ArrayList;
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.myrmidon.framework.Condition;
   
   /**
    * Targets in build file.
  
  
  
  1.2       +1 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/DataType.java
  
  Index: DataType.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/DataType.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DataType.java	2001/06/17 10:35:41	1.1
  +++ DataType.java	2001/06/27 00:50:08	1.2
  @@ -15,5 +15,5 @@
    */
   public interface DataType
   {
  -    String ROLE = "org.apache.myrmidon.api.DataType";
  +    String ROLE = "org.apache.myrmidon.framework.DataType";
   }
  
  
  
  1.3       +1 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Pattern.java
  
  Index: Pattern.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Pattern.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Pattern.java	2001/06/17 10:35:41	1.2
  +++ Pattern.java	2001/06/27 00:50:08	1.3
  @@ -8,7 +8,7 @@
   package org.apache.myrmidon.framework;
   
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.myrmidon.components.model.Condition;
  +import org.apache.myrmidon.framework.Condition;
   
   /**
    * Basic data type for holding patterns.
  
  
  
  1.5       +20 -2     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/frontends/CLIMain.java
  
  Index: CLIMain.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/frontends/CLIMain.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CLIMain.java	2001/06/12 14:20:29	1.4
  +++ CLIMain.java	2001/06/27 00:50:09	1.5
  @@ -37,6 +37,7 @@
   import org.apache.myrmidon.api.TaskContext;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.components.builder.ProjectBuilder;
  +import org.apache.myrmidon.components.executor.Executor;
   import org.apache.myrmidon.components.embeddor.Embeddor;
   import org.apache.myrmidon.components.embeddor.DefaultEmbeddor;
   import org.apache.myrmidon.components.manager.LogTargetToListenerAdapter;
  @@ -67,13 +68,14 @@
       private static final int       TASKLIB_DIR_OPT           = 5;
       private static final int       INCREMENTAL_OPT           = 6;
       private static final int       HOME_DIR_OPT              = 7;
  +    private static final int       DRY_RUN_OPT               = 8;
   
       //incompatable options for info options
       private static final int[]     INFO_OPT_INCOMPAT         = new int[]
       {
           HELP_OPT, QUIET_OPT, VERBOSE_OPT, FILE_OPT,
           LOG_LEVEL_OPT, VERSION_OPT, LISTENER_OPT,
  -        DEFINE_OPT //TASKLIB_DIR_OPT, HOME_DIR_OPT
  +        DEFINE_OPT, DRY_RUN_OPT //TASKLIB_DIR_OPT, HOME_DIR_OPT
       };
   
       //incompatable options for other logging options
  @@ -96,6 +98,9 @@
       ///List of user supplied parameters for builder
       private Parameters           m_builderParameters = new Parameters();
   
  +    ///Determine whether tasks are actually executed
  +    private boolean              m_dryRun      = false;
  +
       /**
        * Main entry point called to run standard Myrmidon.
        *
  @@ -132,7 +137,7 @@
       private CLOptionDescriptor[] createCLOptions()
       {
           //TODO: localise
  -        final CLOptionDescriptor[] options = new CLOptionDescriptor[ 12 ];
  +        final CLOptionDescriptor[] options = new CLOptionDescriptor[ 13 ];
   
           options[0] =
               new CLOptionDescriptor( "help",
  @@ -210,6 +215,11 @@
                                       BUILDER_PARAM_OPT,
                                       "Define a builder parameter (ie -Bfoo=var)" );
   
  +        options[12] =
  +            new CLOptionDescriptor( "dry-run",
  +                                    CLOptionDescriptor.ARGUMENT_DISALLOWED,
  +                                    DRY_RUN_OPT,
  +                                    "Do not execute tasks - just print them out" );
   
           return options;
       }
  @@ -259,6 +269,8 @@
                   m_builderParameters.setParameter( option.getArgument( 0 ), option.getArgument(
1 ) );
                   break;
   
  +            case DRY_RUN_OPT: m_dryRun = true; break;
  +
               case 0: m_targets.add( option.getArgument() ); break;
               }
           }
  @@ -317,6 +329,12 @@
           //getLogger().info( "Ant Bin Directory: " + m_binDir );
           //getLogger().debug( "Ant Lib Directory: " + m_libDir );
           //getLogger().debug( "Ant Task Lib Directory: " + m_taskLibDir );
  +
  +        if( m_dryRun )
  +        {
  +            m_parameters.setParameter( Executor.ROLE, 
  +                                       "org.apache.myrmidon.components.executor.PrintingExecutor"
);
  +        }
   
           final Embeddor embeddor = new DefaultEmbeddor();
           setupLogger( embeddor );
  
  
  

Mime
View raw message