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/container/src/java/org/apache/myrmidon/frontends CLIMain.java Resources.properties
Date Sun, 02 Jun 2002 05:03:47 GMT
adammurdoch    2002/06/01 22:03:47

  Modified:    container/src/java/org/apache/myrmidon/frontends
                        CLIMain.java Resources.properties
  Log:
  Added --listenerparam and --listenerconfig options.
  
  Revision  Changes    Path
  1.47      +91 -37    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/frontends/CLIMain.java
  
  Index: CLIMain.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/frontends/CLIMain.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- CLIMain.java	29 May 2002 13:03:32 -0000	1.46
  +++ CLIMain.java	2 Jun 2002 05:03:46 -0000	1.47
  @@ -14,6 +14,7 @@
   import java.util.HashMap;
   import java.util.List;
   import java.util.Map;
  +import java.util.Iterator;
   import org.apache.avalon.excalibur.cli.CLArgsParser;
   import org.apache.avalon.excalibur.cli.CLOption;
   import org.apache.avalon.excalibur.cli.CLOptionDescriptor;
  @@ -27,6 +28,7 @@
   import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.interfaces.BasicLogger;
   import org.apache.myrmidon.interfaces.EmbeddedAnt;
  +import org.apache.myrmidon.interfaces.model.ModelElementUtil;
   import org.apache.myrmidon.interfaces.executor.Executor;
   
   /**
  @@ -35,7 +37,7 @@
    * to run project.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.46 $ $Date: 2002/05/29 13:03:32 $
  + * @version $Revision: 1.47 $ $Date: 2002/06/02 05:03:46 $
    */
   public class CLIMain
   {
  @@ -53,10 +55,12 @@
       private static final int LOG_LEVEL_OPT = 'l';
       private static final int DEFINE_OPT = 'D';
       private static final int BUILDER_PARAM_OPT = 'B';
  +    private static final int LISTENER_PARAM_OPT = 'L';
       private static final int NO_PREFIX_OPT = 'p';
       private static final int GUI_OPT = 'g';
       private static final int VERSION_OPT = 1;
       private static final int LISTENER_OPT = 2;
  +    private static final int LISTENER_CONFIG_OPT = 3;
       private static final int EXTLIB_DIR_OPT = 6;
       private static final int INCREMENTAL_OPT = 7;
       private static final int HOME_DIR_OPT = 8;
  @@ -69,10 +73,10 @@
       private static final int[] INFO_OPT_INCOMPAT = new int[]
       {
           HELP_OPT, QUIET_OPT, VERBOSE_OPT, FILE_OPT,
  -        LOG_LEVEL_OPT, BUILDER_PARAM_OPT, NO_PREFIX_OPT,
  -        VERSION_OPT, LISTENER_OPT, EXTLIB_DIR_OPT,
  -        INCREMENTAL_OPT, HOME_DIR_OPT, DRY_RUN_OPT, TYPE_OPT,
  -        BANNER_OPT
  +        LOG_LEVEL_OPT, BUILDER_PARAM_OPT, LISTENER_PARAM_OPT,
  +        NO_PREFIX_OPT, VERSION_OPT, LISTENER_OPT, LISTENER_CONFIG_OPT,
  +        EXTLIB_DIR_OPT, INCREMENTAL_OPT, HOME_DIR_OPT, DRY_RUN_OPT,
  +        TYPE_OPT, BANNER_OPT
       };
   
       //incompatable options for other logging options
  @@ -81,7 +85,13 @@
           QUIET_OPT, VERBOSE_OPT, LOG_LEVEL_OPT, DEBUG_OPT
       };
   
  -    //incompatible options for listener options
  +    // incompatible options for listener
  +    private static final int[] LISTENER_OPT_INCOMPAT = new int[]
  +    {
  +        LISTENER_OPT, LISTENER_CONFIG_OPT
  +    };
  +
  +    //incompatible options for run options
       private static final int[] RUNSTYLE_OPT_INCOMPAT = new int[]
       {
           GUI_OPT, INCREMENTAL_OPT
  @@ -96,10 +106,12 @@
       ///Enables incremental mode
       private boolean m_incremental;
   
  -    ///The name of the listener to use
  -    private String m_listenerName = "default";
  +    ///Listener config
  +    private String m_listenerName;
       private boolean m_prefix = true;
       private boolean m_banner = false;
  +    private Map m_listenerParams = new HashMap();
  +    private String m_listenerConfig;
   
       ///The launcher
       private final EmbeddedAnt m_embedded = new EmbeddedAnt();
  @@ -172,10 +184,27 @@
                                       HELP_OPT,
                                       REZ.getString( "help.opt" ),
                                       INFO_OPT_INCOMPAT ),
  +            new CLOptionDescriptor( "version",
  +                                    CLOptionDescriptor.ARGUMENT_DISALLOWED,
  +                                    VERSION_OPT,
  +                                    REZ.getString( "version.opt" ),
  +                                    INFO_OPT_INCOMPAT ),
  +            new CLOptionDescriptor( "define",
  +                                    CLOptionDescriptor.ARGUMENTS_REQUIRED_2 | CLOptionDescriptor.DUPLICATES_ALLOWED,
  +                                    DEFINE_OPT,
  +                                    REZ.getString( "define.opt" ) ),
               new CLOptionDescriptor( "file",
                                       CLOptionDescriptor.ARGUMENT_REQUIRED,
                                       FILE_OPT,
                                       REZ.getString( "file.opt" ) ),
  +            new CLOptionDescriptor( "type",
  +                                    CLOptionDescriptor.ARGUMENT_REQUIRED,
  +                                    TYPE_OPT,
  +                                    REZ.getString( "type.opt" ) ),
  +            new CLOptionDescriptor( "builderparam",
  +                                    CLOptionDescriptor.ARGUMENTS_REQUIRED_2 | CLOptionDescriptor.DUPLICATES_ALLOWED,
  +                                    BUILDER_PARAM_OPT,
  +                                    REZ.getString( "build.opt" ) ),
               new CLOptionDescriptor( "loglevel",
                                       CLOptionDescriptor.ARGUMENT_REQUIRED,
                                       LOG_LEVEL_OPT,
  @@ -199,7 +228,17 @@
               new CLOptionDescriptor( "listener",
                                       CLOptionDescriptor.ARGUMENT_REQUIRED,
                                       LISTENER_OPT,
  -                                    REZ.getString( "listener.opt" ) ),
  +                                    REZ.getString( "listener.opt" ),
  +                                    LISTENER_OPT_INCOMPAT ),
  +            new CLOptionDescriptor( "listenerparam",
  +                                    CLOptionDescriptor.ARGUMENTS_REQUIRED_2 | CLOptionDescriptor.DUPLICATES_ALLOWED,
  +                                    LISTENER_PARAM_OPT,
  +                                    REZ.getString( "listenerparam.opt" ) ),
  +            new CLOptionDescriptor( "listenerconfig",
  +                                    CLOptionDescriptor.ARGUMENT_REQUIRED,
  +                                    LISTENER_CONFIG_OPT,
  +                                    REZ.getString( "listenerconfig.opt" ),
  +                                    LISTENER_OPT_INCOMPAT ),
               new CLOptionDescriptor( "noprefix",
                                       CLOptionDescriptor.ARGUMENT_DISALLOWED,
                                       NO_PREFIX_OPT,
  @@ -208,41 +247,23 @@
                                       CLOptionDescriptor.ARGUMENT_DISALLOWED,
                                       BANNER_OPT,
                                       REZ.getString( "banner.opt" ) ),
  -            new CLOptionDescriptor( "version",
  -                                    CLOptionDescriptor.ARGUMENT_DISALLOWED,
  -                                    VERSION_OPT,
  -                                    REZ.getString( "version.opt" ),
  -                                    INFO_OPT_INCOMPAT ),
               new CLOptionDescriptor( "extpath",
                                       CLOptionDescriptor.ARGUMENT_REQUIRED,
                                       EXTLIB_DIR_OPT,
                                       REZ.getString( "extlib.opt" ) ),
  -            new CLOptionDescriptor( "incremental",
  -                                    CLOptionDescriptor.ARGUMENT_DISALLOWED,
  -                                    INCREMENTAL_OPT,
  -                                    REZ.getString( "incremental.opt" ),
  -                                    CLIMain.RUNSTYLE_OPT_INCOMPAT ),
               new CLOptionDescriptor( "anthome",
                                       CLOptionDescriptor.ARGUMENT_REQUIRED,
                                       HOME_DIR_OPT,
                                       REZ.getString( "home.opt" ) ),
  -            new CLOptionDescriptor( "define",
  -                                    CLOptionDescriptor.ARGUMENTS_REQUIRED_2,
  -                                    DEFINE_OPT,
  -                                    REZ.getString( "define.opt" ),
  -                                    new int[ 0 ] ),
  -            new CLOptionDescriptor( "builderparam",
  -                                    CLOptionDescriptor.ARGUMENTS_REQUIRED_2,
  -                                    BUILDER_PARAM_OPT,
  -                                    REZ.getString( "build.opt" ) ),
               new CLOptionDescriptor( "dryrun",
                                       CLOptionDescriptor.ARGUMENT_DISALLOWED,
                                       DRY_RUN_OPT,
                                       REZ.getString( "dry-run.opt" ) ),
  -            new CLOptionDescriptor( "type",
  -                                    CLOptionDescriptor.ARGUMENT_REQUIRED,
  -                                    TYPE_OPT,
  -                                    REZ.getString( "type.opt" ) ),
  +            new CLOptionDescriptor( "incremental",
  +                                    CLOptionDescriptor.ARGUMENT_DISALLOWED,
  +                                    INCREMENTAL_OPT,
  +                                    REZ.getString( "incremental.opt" ),
  +                                    CLIMain.RUNSTYLE_OPT_INCOMPAT ),
               new CLOptionDescriptor( "gui",
                                       CLOptionDescriptor.ARGUMENT_DISALLOWED,
                                       GUI_OPT,
  @@ -312,6 +333,12 @@
                   case LISTENER_OPT:
                       m_listenerName = option.getArgument();
                       break;
  +                case LISTENER_PARAM_OPT:
  +                    m_listenerParams.put( option.getArgument( 0 ), option.getArgument(
1 ) );
  +                    break;
  +                case LISTENER_CONFIG_OPT:
  +                    m_listenerConfig = option.getArgument();
  +                    break;
                   case NO_PREFIX_OPT:
                       m_prefix = false;
                       break;
  @@ -373,11 +400,7 @@
               }
   
               // Setup the listener
  -            final ModelElement listenerModel = new ModelElement( m_listenerName, "command-line:?:?"
);
  -            listenerModel.setAttribute( "level", BasicLogger.mapLogLevel( m_priority )
);
  -            listenerModel.setAttribute( "prefix", String.valueOf( m_prefix ) );
  -            listenerModel.setAttribute( "banner", String.valueOf( m_banner ) );
  -            m_embedded.addTaskListener( listenerModel );
  +            prepareListeners();
   
               // Set the common and container classloaders
               final ClassLoader sharedClassLoader = (ClassLoader)properties.get( "myrmidon.shared.classloader"
);
  @@ -409,6 +432,37 @@
           {
               embeddedAnt.stop();
           }
  +    }
  +
  +    private void prepareListeners() throws Exception
  +    {
  +        // Build the listener model
  +        final ModelElement listenerModel;
  +        if( m_listenerConfig != null )
  +        {
  +            // Load model from file
  +            listenerModel = ModelElementUtil.loadModel( m_listenerConfig );
  +        }
  +        else if( m_listenerName != null )
  +        {
  +            listenerModel = new ModelElement( m_listenerName, "command-line:?:?" );
  +        }
  +        else
  +        {
  +            // Use the default listener
  +            listenerModel = new ModelElement( "default", "command-line:?:?" );
  +            listenerModel.setAttribute( "prefix", String.valueOf( m_prefix ) );
  +            listenerModel.setAttribute( "banner", String.valueOf( m_banner ) );
  +        }
  +
  +        listenerModel.setAttribute( "level", BasicLogger.mapLogLevel( m_priority ) );
  +        for( Iterator iterator = m_listenerParams.entrySet().iterator(); iterator.hasNext();
)
  +        {
  +            final Map.Entry entry = (Map.Entry)iterator.next();
  +            listenerModel.setAttribute( (String)entry.getKey(), (String)entry.getValue()
);
  +        }
  +
  +        m_embedded.addTaskListener( listenerModel );
       }
   
       private void executeIncrementalBuild()
  
  
  
  1.14      +9 -7      jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/frontends/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/frontends/Resources.properties,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Resources.properties	29 May 2002 13:03:32 -0000	1.13
  +++ Resources.properties	2 Jun 2002 05:03:46 -0000	1.14
  @@ -1,20 +1,22 @@
   error-message=Error: {0}.
   
   help.opt=Display this help message.
  -file.opt=Specify the build file.
  +file.opt=Specify the project file.
   log-level.opt=Specify the verbosity level at which to log messages. (DEBUG|VERBOSE|INFO|WARN|ERROR).
  -quiet.opt=Equivalent to --log-level=ERROR.
  -verbose.opt=Equivalent to --log-level=VERBOSE.
  -debug.opt=Equivalent to --log-level=DEBUG.
  +quiet.opt=Only output error messages.  Equivalent to --loglevel=ERROR.
  +verbose.opt=Enables verbose output.  Equivalent to --loglevel=VERBOSE.
  +debug.opt=Enable debug ouput.  Equivalent to --loglevel=DEBUG.
   listener.opt=Specify the listener for log events.
  -noprefix.opt=Do not prefix output with the task name.
  -banner.opt=Include a target banner in the output, for every target executed.
  +noprefix.opt=Do not prefix output with the task name (default listener only).
  +banner.opt=Include a target banner in the output, for every target executed (default listener
only).
  +listenerparam.opt=Define a listener parameter.
  +listenerconfig.opt=Specify the listener configuration file.
   version.opt=Display version.
   extlib.opt=Specify the path to use to search for optional packages.
   incremental.opt=Run in incremental mode.
   home.opt=Specify Ant home directory.
   define.opt=Define a property (ie -Dfoo=var).
  -build.opt=Define a builder parameter (ie -Bfoo=var).
  +build.opt=Define a project builder parameter.
   dry-run.opt=Do not execute tasks - just print them out.
   gui.opt=Run the GUI frontend.
   type.opt=Specify the project file type.
  
  
  

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