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/launcher Main.java
Date Tue, 29 May 2001 15:24:20 GMT
donaldp     01/05/29 08:24:20

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon
                        Constants.java Main.java
               proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor
                        MyrmidonEmbeddor.java
               proposal/myrmidon/src/java/org/apache/myrmidon/launcher
                        Main.java
  Log:
  Update names of properties.
  
  Revision  Changes    Path
  1.2       +4 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/Constants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Constants.java	2001/05/29 10:47:25	1.1
  +++ Constants.java	2001/05/29 15:24:11	1.2
  @@ -15,6 +15,8 @@
   interface Constants
   {
       //Constants to indicate the build of Ant/Myrmidon
  -    String  BUILD_DATE     = "@@DATE@@";
  -    String  BUILD_VERSION  = "@@VERSION@@";
  +    String  BUILD_DATE         = "@@DATE@@";
  +    String  BUILD_VERSION      = "@@VERSION@@";
  +
  +    String  BUILD_DESCRIPTION  = "Myrmidon " + BUILD_VERSION + " compiled on " + BUILD_DATE;
   }
  
  
  
  1.3       +61 -103   jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/Main.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Main.java	2001/05/29 12:06:15	1.2
  +++ Main.java	2001/05/29 15:24:12	1.3
  @@ -46,7 +46,7 @@
   
   /**
    * The class to kick the tires and light the fires.
  - * Starts ant, loads ProjectBuilder, builds project then uses ProjectManager
  + * Starts myrmidon, loads ProjectBuilder, builds project then uses ProjectManager
    * to run project.
    *
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
  @@ -54,19 +54,6 @@
   public class Main
       extends AbstractLoggable
   {
  -    //Constants to indicate the build of Ant/Myrmidon
  -    public final static String     VERSION                   =
  -        "Ant " + Constants.BUILD_VERSION + " compiled on " + Constants.BUILD_DATE;
  -
  -    //default log level
  -    protected final static String  DEFAULT_LOGLEVEL          = "WARN";
  -
  -    //Some defaults for file locations/names
  -    protected final static String  DEFAULT_FILENAME          = "build.ant";
  -
  -    protected final static String  DEFAULT_LISTENER          =
  -        "org.apache.myrmidon.listeners.DefaultProjectListener";
  -
       //defines for the Command Line options
       private static final int       HELP_OPT                  = 'h';
       private static final int       QUIET_OPT                 = 'q';
  @@ -95,10 +82,10 @@
       };
   
       private ProjectListener      m_listener;
  -    private File                 m_homeDir;
  +    private Parameters           m_parameters  = new Parameters();
   
       /**
  -     * Main entry point called to run standard Ant.
  +     * Main entry point called to run standard Myrmidon.
        *
        * @param args the args
        */
  @@ -108,11 +95,6 @@
           main.setLogger( Hierarchy.getDefaultHierarchy().getLoggerFor( "default" ) );
   
           try { main.execute( args ); }
  -        catch( final TaskException ae )
  -        {
  -            main.getLogger().error( "Error: " + ae.getMessage() );
  -            main.getLogger().debug( "Exception..." + ExceptionUtil.printStackTrace( ae
) );
  -        }
           catch( final Throwable throwable )
           {
               main.getLogger().error( "Error: " + throwable );
  @@ -198,10 +180,10 @@
                                       INCREMENTAL_OPT,
                                       "Run in incremental mode" );
           options[9] =
  -            new CLOptionDescriptor( "ant-home",
  +            new CLOptionDescriptor( "myrmidon-home",
                                       CLOptionDescriptor.ARGUMENT_REQUIRED,
                                       HOME_DIR_OPT,
  -                                    "Specify ant home directory" );
  +                                    "Specify myrmidon home directory" );
           options[10] =
               new CLOptionDescriptor( "define",
                                       CLOptionDescriptor.ARGUMENTS_REQUIRED_2,
  @@ -226,13 +208,15 @@
           final List clOptions = parser.getArguments();
           final int size = clOptions.size();
           final ArrayList targets = new ArrayList();
  -        String filename = null;
  -        String listenerName = null;
  -        String logLevel = null;
  -        String homeDir = null;
  -        String taskLibDir = null;
  -        boolean incremental = false;
  -        HashMap defines = new HashMap();
  +        final HashMap defines = new HashMap();
  +
  +        m_parameters.setParameter( "filename", "build.ant" );
  +        m_parameters.setParameter( "log.level", "WARN" );
  +        m_parameters.setParameter( "listener", "org.apache.myrmidon.listeners.DefaultProjectListener"
);
  +        m_parameters.setParameter( "incremental", "false" );
  +
  +        //System property set up by launcher
  +        m_parameters.setParameter( "myrmidon.home", System.getProperty( "myrmidon.home"
) );
   
           for( int i = 0; i < size; i++ )
           {
  @@ -240,48 +224,45 @@
   
               switch( option.getId() )
               {
  -            case 0: targets.add( option.getArgument() ); break;
               case HELP_OPT: usage( options ); return;
  -            case VERSION_OPT: System.out.println( VERSION ); return;
  -            case FILE_OPT: filename = option.getArgument(); break;
  -            case HOME_DIR_OPT: homeDir = option.getArgument(); break;
  -            case TASKLIB_DIR_OPT: taskLibDir = option.getArgument(); break;
  -            case VERBOSE_OPT: logLevel = "INFO"; break;
  -            case QUIET_OPT: logLevel = "ERROR"; break;
  -            case LOG_LEVEL_OPT: logLevel = option.getArgument(); break;
  -            case LISTENER_OPT: listenerName = option.getArgument(); break;
  -            case INCREMENTAL_OPT: incremental = true; break;
  +            case VERSION_OPT: System.out.println( Constants.BUILD_DESCRIPTION ); return;
   
  +            case HOME_DIR_OPT: m_parameters.setParameter( "myrmidon.home", option.getArgument()
); break;
  +            case TASKLIB_DIR_OPT: 
  +                m_parameters.setParameter( "myrmidon.lib.path", option.getArgument() );

  +                break;
  +
  +            case LOG_LEVEL_OPT: m_parameters.setParameter( "log.level", option.getArgument()
); break;
  +            case VERBOSE_OPT: m_parameters.setParameter( "log.level", "INFO" ); break;
  +            case QUIET_OPT: m_parameters.setParameter( "log.level", "ERROR" ); break;
  +
  +            case INCREMENTAL_OPT: m_parameters.setParameter( "incremental", "true" ); break;
  +
  +            case FILE_OPT: m_parameters.setParameter( "filename", option.getArgument()
); break;
  +            case LISTENER_OPT: m_parameters.setParameter( "listener", option.getArgument()
); break;
  +
               case DEFINE_OPT:
                   defines.put( option.getArgument( 0 ), option.getArgument( 1 ) );
                   break;
  +
  +            case 0: targets.add( option.getArgument() ); break;
               }
           }
   
  -        if( null == logLevel ) logLevel = DEFAULT_LOGLEVEL;
  -        if( null == listenerName ) listenerName = DEFAULT_LISTENER;
  -        if( null == filename ) filename = DEFAULT_FILENAME;
  -
           //handle logging...
  +        final String logLevel = m_parameters.getParameter( "log.level", null );
           setLogger( createLogger( logLevel ) );
  -
  -        //if ant home not set then use system property ant.home
  -        //that was set up by launcher.
  -        if( null == homeDir ) homeDir = System.getProperty( "ant.home" );
  -
  -        final Parameters parameters = new Parameters();
  -        parameters.setParameter( "ant.home", homeDir );
  -
  -        if( null != taskLibDir ) parameters.setParameter( "ant.path.task-lib", taskLibDir
);
   
  -        m_homeDir = (new File( homeDir )).getAbsoluteFile();
  -        if( !m_homeDir.isDirectory() )
  +        final String home = m_parameters.getParameter( "myrmidon.home", null );
  +        final File homeDir = (new File( home )).getAbsoluteFile();
  +        if( !homeDir.isDirectory() )
           {
  -            throw new TaskException( "ant-home (" + m_homeDir + ") is not a directory"
);
  +            throw new TaskException( "myrmidon-home (" + homeDir + ") is not a directory"
);
           }
   
  -        final File libDir = new File( m_homeDir, "lib" );
  +        final File libDir = new File( homeDir, "lib" );
   
  +        final String filename = m_parameters.getParameter( "filename", null );
           final File buildFile = (new File( filename )).getCanonicalFile();
           if( !buildFile.isFile() )
           {
  @@ -295,17 +276,23 @@
           Thread.currentThread().setContextClassLoader( classLoader );
   
           //handle listener..
  +        final String listenerName = m_parameters.getParameter( "listener", null );
           final ProjectListener listener = createListener( listenerName );
   
  +        final LogTarget target = new LogTargetToListenerAdapter( listener );
  +        getLogger().setLogTargets( new LogTarget[] { target } );
  +
  +
  +
           getLogger().warn( "Ant Build File: " + buildFile );
  -        getLogger().info( "Ant Home Directory: " + m_homeDir );
  +        getLogger().info( "Ant Home Directory: " + homeDir );
           //getLogger().info( "Ant Bin Directory: " + m_binDir );
           //getLogger().debug( "Ant Lib Directory: " + m_libDir );
           //getLogger().debug( "Ant Task Lib Directory: " + m_taskLibDir );
   
           final Embeddor embeddor = new MyrmidonEmbeddor();
           setupLogger( embeddor );
  -        embeddor.parameterize( parameters );
  +        embeddor.parameterize( m_parameters );
           embeddor.initialize();
           embeddor.start();
   
  @@ -320,15 +307,21 @@
           BufferedReader reader = null;
   
           //loop over build if we are in incremental mode..
  +        final boolean incremental = m_parameters.getParameterAsBoolean( "incremental",
false );
           while( true )
           {
               //actually do the build ...
               final TaskContext context = new DefaultTaskContext();
  -            setupContext( context, defines );
  +            
  +            //Add CLI defines
  +            addToContext( context, defines );
  +
  +            //Add system properties second so that they overide user-defined properties
  +            addToContext( context, System.getProperties() );
   
               context.setProperty( TaskContext.BASE_DIRECTORY, project.getBaseDirectory()
);
               context.setProperty( Project.PROJECT_FILE, buildFile );
  -            //context.setProperty( Project.PROJECT, projectName );
  +            //context.setProperty( Project.PROJECT, project.getName() );
   
               doBuild( manager, project, context, targets );
   
  @@ -405,8 +398,7 @@
               throw new TaskException( "Unknown log level - " + logLevel );
           }
   
  -        final Logger logger =
  -            Hierarchy.getDefaultHierarchy().getLoggerFor( "ant" );
  +        final Logger logger = Hierarchy.getDefaultHierarchy().getLoggerFor( "myrmidon"
);
   
           logger.setPriority( priority );
   
  @@ -416,26 +408,18 @@
       /**
        * Setup project listener.
        *
  -     * @param listenerName the name of project listener
  +     * @param listener the classname of project listener
        */
  -    protected ProjectListener createListener( final String listenerName )
  +    protected ProjectListener createListener( final String listener )
           throws TaskException
       {
  -        ProjectListener result = null;
  -
  -        try { result = (ProjectListener)Class.forName( listenerName ).newInstance(); }
  +        try { return (ProjectListener)Class.forName( listener ).newInstance(); }
           catch( final Throwable t )
           {
  -            throw new TaskException( "Error creating the listener " + listenerName +
  -                                    " due to " + ExceptionUtil.printStackTrace( t, 5, true
),
  -                                    t );
  +            throw new TaskException( "Error creating the listener " + listener +
  +                                     " due to " + ExceptionUtil.printStackTrace( t, 5,
true ),
  +                                     t );
           }
  -
  -        final LogTarget target = new LogTargetToListenerAdapter( result );
  -
  -        getLogger().setLogTargets( new LogTarget[] { target } );
  -
  -        return result;
       }
   
       /**
  @@ -476,32 +460,6 @@
           }
   
           return classLoader;
  -    }
  -
  -    /**
  -     * Setup the projects context so all the "default" properties are defined.
  -     * This also takes a hashmap that is added to context. Usually these are the
  -     * ones defined on command line.
  -     *
  -     * @param project the project
  -     * @param defines the defines
  -     * @exception TaskException if an error occurs
  -     */
  -    protected void setupContext( final TaskContext context, final HashMap defines )
  -        throws TaskException
  -    {
  -        //put these values into defines so that they overide
  -        //user-defined proeprties
  -        //defines.put( AntContextResources.HOME_DIR, m_homeDir );
  -        //defines.put( AntContextResources.BIN_DIR, m_binDir );
  -        //defines.put( AntContextResources.LIB_DIR, m_libDir );
  -        //defines.put( AntContextResources.TASKLIB_DIR, m_taskLibDir );
  -        //defines.put( TaskletContext.JAVA_VERSION, getJavaVersion() );
  -
  -        addToContext( context, defines );
  -
  -        //Add system properties second so that they overide user-defined properties
  -        addToContext( context, System.getProperties() );
       }
   
       /**
  
  
  
  1.9       +28 -32    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/MyrmidonEmbeddor.java
  
  Index: MyrmidonEmbeddor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/embeddor/MyrmidonEmbeddor.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MyrmidonEmbeddor.java	2001/05/29 12:06:20	1.8
  +++ MyrmidonEmbeddor.java	2001/05/29 15:24:15	1.9
  @@ -30,7 +30,8 @@
   import org.apache.myrmidon.components.deployer.TskDeployer;
   
   /**
  - * Default implementation of Ant runtime.
  + * Default implementation of Embeddor.
  + * Instantiate this to embed inside other applications.
    *
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
    */
  @@ -41,7 +42,7 @@
       private ConverterEngine          m_converterEngine;
       private DataTypeEngine           m_dataTypeEngine;
       private Executor                 m_executor;
  -    private ProjectManager            m_projectEngine;
  +    private ProjectManager           m_projectManager;
   
       private ProjectBuilder           m_builder;
       private TskDeployer              m_deployer;
  @@ -88,7 +89,7 @@
        */
       public ProjectManager getProjectManager()
       {
  -        return m_projectEngine;
  +        return m_projectManager;
       }
   
       /**
  @@ -136,7 +137,7 @@
           m_converterEngine = null;
           m_dataTypeEngine = null;
           m_executor = null;
  -        m_projectEngine = null;
  +        m_projectManager = null;
           m_builder = null;
           m_deployer = null;
           m_configurer = null;
  @@ -161,24 +162,23 @@
           final Parameters defaults = new Parameters();
   
           //create all the default properties for files/directories
  -        defaults.setParameter( "ant.path.bin", "bin" );
  -        defaults.setParameter( "ant.path.lib", "lib" );
  -        defaults.setParameter( "ant.path.task-lib", "lib" );
  +        defaults.setParameter( "myrmidon.bin.path", "bin" );
  +        defaults.setParameter( "myrmidon.lib.path", "lib" );
   
           //create all the default properties for components
  -        defaults.setParameter( "ant.comp.converter",
  +        defaults.setParameter( "myrmidon.comp.converter",
                                  "org.apache.ant.convert.engine.DefaultConverterEngine" );
  -        defaults.setParameter( "ant.comp.datatype",
  +        defaults.setParameter( "myrmidon.comp.datatype",
                                  "org.apache.ant.tasklet.engine.DefaultDataTypeEngine" );
  -        defaults.setParameter( "ant.comp.task",
  +        defaults.setParameter( "myrmidon.comp.task",
                                  "org.apache.myrmidon.components.executor.DefaultExecutor"
);
  -        defaults.setParameter( "ant.comp.project",
  +        defaults.setParameter( "myrmidon.comp.project",
                                  "org.apache.myrmidon.components.manager.DefaultProjectManager"
);
  -        defaults.setParameter( "ant.comp.builder",
  +        defaults.setParameter( "myrmidon.comp.builder",
                                  "org.apache.myrmidon.components.builder.DefaultProjectBuilder"
);
  -        defaults.setParameter( "ant.comp.deployer",
  +        defaults.setParameter( "myrmidon.comp.deployer",
                                  "org.apache.myrmidon.components.deployer.DefaultTskDeployer"
);
  -        defaults.setParameter( "ant.comp.configurer",
  +        defaults.setParameter( "myrmidon.comp.configurer",
                                  "org.apache.myrmidon.components.configurer.DefaultConfigurer"
);
   
           return defaults;
  @@ -200,7 +200,7 @@
           componentManager.put( "org.apache.avalon.framework.camelot.Factory", m_factory
);
   
           //Following components required when Myrmidon is used as build tool
  -        componentManager.put( "org.apache.myrmidon.components.manager.ProjectManager",
m_projectEngine );
  +        componentManager.put( "org.apache.myrmidon.components.manager.ProjectManager",
m_projectManager );
           componentManager.put( "org.apache.myrmidon.components.builder.ProjectBuilder",
m_builder );
   
           //Following components required when Myrmidon allows user deployment of tasks etal.
  @@ -223,25 +223,25 @@
       {
           String component = null;
   
  -        component = getParameter( "ant.comp.converter" );
  +        component = getParameter( "myrmidon.comp.converter" );
           m_converterEngine = (ConverterEngine)createComponent( component, ConverterEngine.class
);
   
  -        component = getParameter( "ant.comp.datatype" );
  +        component = getParameter( "myrmidon.comp.datatype" );
           m_dataTypeEngine = (DataTypeEngine)createComponent( component, DataTypeEngine.class
);
   
  -        component = getParameter( "ant.comp.task" );
  +        component = getParameter( "myrmidon.comp.task" );
           m_executor = (Executor)createComponent( component, Executor.class );
   
  -        component = getParameter( "ant.comp.project" );
  -        m_projectEngine = (ProjectManager)createComponent( component, ProjectManager.class
);
  +        component = getParameter( "myrmidon.comp.project" );
  +        m_projectManager = (ProjectManager)createComponent( component, ProjectManager.class
);
   
  -        component = getParameter( "ant.comp.builder" );
  +        component = getParameter( "myrmidon.comp.builder" );
           m_builder =(ProjectBuilder)createComponent( component, ProjectBuilder.class );
   
  -        component = getParameter( "ant.comp.deployer" );
  +        component = getParameter( "myrmidon.comp.deployer" );
           m_deployer = (TskDeployer)createComponent( component, TskDeployer.class );
   
  -        component = getParameter( "ant.comp.configurer" );
  +        component = getParameter( "myrmidon.comp.configurer" );
           m_configurer = (Configurer)createComponent( component, Configurer.class );
       }
   
  @@ -257,7 +257,7 @@
           setupComponent( m_converterEngine );
           setupComponent( m_dataTypeEngine );
           setupComponent( m_executor );
  -        setupComponent( m_projectEngine );
  +        setupComponent( m_projectManager );
           setupComponent( m_builder );
           setupComponent( m_deployer );
           setupComponent( m_configurer );
  @@ -293,17 +293,14 @@
       {
           String filepath = null;
   
  -        filepath = getParameter( "ant.home" );
  +        filepath = getParameter( "myrmidon.home" );
           m_homeDir = (new File( filepath )).getAbsoluteFile();
  -        checkDirectory( m_homeDir, "ant-home" );
  +        checkDirectory( m_homeDir, "home" );
   
  -        filepath = getParameter( "ant.path.bin" );
  +        filepath = getParameter( "myrmidon.bin.path" );
           m_binDir = resolveDirectory( filepath, "bin-dir" );
   
  -        filepath = getParameter( "ant.path.lib" );
  -        m_libDir = resolveDirectory( filepath, "lib-dir" );
  -
  -        filepath = getParameter( "ant.path.task-lib" );
  +        filepath = getParameter( "myrmidon.lib.path" );
           m_taskLibDir = resolveDirectory( filepath, "task-lib-dir" );
       }
   
  @@ -363,7 +360,6 @@
   
       /**
        * Helper method to retrieve current JVM version.
  -     * Basically stolen from original Ant sources.
        *
        * @return the current JVM version
        */
  
  
  
  1.3       +3 -3      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/launcher/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/launcher/Main.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Main.java	2001/05/29 10:47:55	1.2
  +++ Main.java	2001/05/29 15:24:18	1.3
  @@ -33,9 +33,9 @@
           try
           {
               //actually try to discover the install directory based on where
  -            // the ant.jar is
  +            // the myrmidon.jar is
               final File installDirectory = findInstallDir();
  -            System.setProperty( "ant.home", installDirectory.toString() );
  +            System.setProperty( "myrmidon.home", installDirectory.toString() );
   
               //setup classloader appropriately for myrmidon jar
               final File libDir = new File( installDirectory, "lib" );
  @@ -90,7 +90,7 @@
       }
   
       /**
  -     *  Finds the ant.jar file in the classpath.
  +     *  Finds the myrmidon.jar file in the classpath.
        */
       private final static File findInstallDir()
           throws Exception
  
  
  

Mime
View raw message