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 Mon, 18 Feb 2002 09:14:37 GMT
donaldp     02/02/18 01:14:37

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/frontends
                        CLIMain.java
  Log:
  Start simplifying so that metrics task does not complain as much
  
  Revision  Changes    Path
  1.25      +106 -50   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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- CLIMain.java	13 Feb 2002 03:02:54 -0000	1.24
  +++ CLIMain.java	18 Feb 2002 09:14:37 -0000	1.25
  @@ -42,7 +42,7 @@
    * to run project.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.24 $ $Date: 2002/02/13 03:02:54 $
  + * @version $Revision: 1.25 $ $Date: 2002/02/18 09:14:37 $
    */
   public class CLIMain
       extends AbstractLogEnabled
  @@ -318,37 +318,11 @@
               return;
           }
   
  -        //handle logging...
  -        final String logLevel = m_parameters.getParameter( "log.level", null );
  -        enableLogging( new LogKitLogger( createLogger( logLevel ) ) );
  -
  -        final String home = m_parameters.getParameter( "myrmidon.home", null );
  -        final File homeDir = ( new File( home ) ).getAbsoluteFile();
  -        if( !homeDir.isDirectory() )
  -        {
  -            final String message = REZ.getString( "home-not-dir.error", homeDir );
  -            throw new Exception( message );
  -        }
  -
  -        final String filename = m_parameters.getParameter( "filename", null );
  -        final File buildFile = ( new File( filename ) ).getCanonicalFile();
  -        if( !buildFile.isFile() )
  -        {
  -            final String message = REZ.getString( "bad-file.error", buildFile );
  -            throw new Exception( message );
  -        }
  +        prepareLogging();
   
  -        if( getLogger().isInfoEnabled() )
  -        {
  -            final String message = REZ.getString( "buildfile.notice", buildFile );
  -            getLogger().info( message );
  -        }
  +        final File homeDir = getHomeDir();
  +        final File buildFile = getBuildFile();
   
  -        if( getLogger().isInfoEnabled() )
  -        {
  -            final String message = REZ.getString( "homedir.notice", homeDir );
  -            getLogger().info( message );
  -        }
           //getLogger().info( "Ant Bin Directory: " + m_binDir );
           //getLogger().debug( "Ant Lib Directory: " + m_libDir );
           //getLogger().debug( "Ant Task Lib Directory: " + m_taskLibDir );
  @@ -359,36 +333,37 @@
                                          "org.apache.myrmidon.components.executor.PrintingExecutor"
);
           }
   
  -        final Embeddor embeddor = createEmbeddor();
  -        setupLogger( embeddor );
  -        embeddor.parameterize( m_parameters );
  -        embeddor.initialize();
  -        embeddor.start();
  -
  -        //create the listener
  -        final String listenerName = m_parameters.getParameter( "listener", null );
  -        final ProjectListener listener = embeddor.createListener( listenerName );
  +        final Embeddor embeddor = prepareEmbeddor();
  +        final ProjectListener listener = prepareListener( embeddor );
   
           //create the project
           final Project project =
               embeddor.createProject( buildFile.toString(), null, m_builderParameters );
   
  -        BufferedReader reader = null;
  -
           //loop over build if we are in incremental mode..
           final boolean incremental = m_parameters.getParameterAsBoolean( "incremental",
false );
  -        while( true )
  +        if( !incremental )
           {
  -            //actually do the build ...
  -            final Workspace workspace = embeddor.createWorkspace( m_defines );
  -            workspace.addProjectListener( listener );
  +            executeBuild( embeddor, project, listener );
  +        }
  +        else
  +        {
  +            executeIncrementalBuild( embeddor, project, listener );
  +        }
   
  -            doBuild( workspace, project, m_targets );
  +        shutdownEmbeddor( embeddor );
  +    }
   
  -            if( !incremental )
  -            {
  -                break;
  -            }
  +    private void executeIncrementalBuild( final Embeddor embeddor,
  +                                          final Project project,
  +                                          final ProjectListener listener )
  +        throws Exception
  +    {
  +        BufferedReader reader = null;
  +
  +        while( true )
  +        {
  +            executeBuild( embeddor, project, listener );
   
               final String message = REZ.getString( "repeat.notice" );
               System.out.println( message );
  @@ -406,9 +381,90 @@
               }
   
           }
  +    }
  +
  +    private void executeBuild( final Embeddor embeddor,
  +                               final Project project,
  +                               final ProjectListener listener )
  +        throws Exception
  +    {
  +        //actually do the build ...
  +        final Workspace workspace = embeddor.createWorkspace( m_defines );
  +        workspace.addProjectListener( listener );
  +
  +        doBuild( workspace, project, m_targets );
  +    }
  +
  +    private File getBuildFile() throws Exception
  +    {
  +        final String filename = m_parameters.getParameter( "filename", null );
  +        final File buildFile = ( new File( filename ) ).getCanonicalFile();
  +        if( !buildFile.isFile() )
  +        {
  +            final String message = REZ.getString( "bad-file.error", buildFile );
  +            throw new Exception( message );
  +        }
  +
  +        if( getLogger().isInfoEnabled() )
  +        {
  +            final String message = REZ.getString( "buildfile.notice", buildFile );
  +            getLogger().info( message );
  +        }
  +
  +        return buildFile;
  +    }
  +
  +    private File getHomeDir() throws Exception
  +    {
  +        final String home = m_parameters.getParameter( "myrmidon.home", null );
  +        final File homeDir = ( new File( home ) ).getAbsoluteFile();
  +        if( !homeDir.isDirectory() )
  +        {
  +            final String message = REZ.getString( "home-not-dir.error", homeDir );
  +            throw new Exception( message );
  +        }
   
  +        if( getLogger().isInfoEnabled() )
  +        {
  +            final String message = REZ.getString( "homedir.notice", homeDir );
  +            getLogger().info( message );
  +        }
  +
  +        return homeDir;
  +    }
  +
  +    private void prepareLogging() throws Exception
  +    {
  +        //handle logging...
  +        final String logLevel = m_parameters.getParameter( "log.level", null );
  +        enableLogging( new LogKitLogger( createLogger( logLevel ) ) );
  +    }
  +
  +    private void shutdownEmbeddor( final Embeddor embeddor )
  +        throws Exception
  +    {
           embeddor.stop();
           embeddor.dispose();
  +    }
  +
  +    private ProjectListener prepareListener( final Embeddor embeddor )
  +        throws Exception
  +    {
  +        //create the listener
  +        final String listenerName = m_parameters.getParameter( "listener", null );
  +        final ProjectListener listener = embeddor.createListener( listenerName );
  +        return listener;
  +    }
  +
  +    private Embeddor prepareEmbeddor()
  +        throws Exception
  +    {
  +        final Embeddor embeddor = createEmbeddor();
  +        setupLogger( embeddor );
  +        embeddor.parameterize( m_parameters );
  +        embeddor.initialize();
  +        embeddor.start();
  +        return embeddor;
       }
   
       private Embeddor createEmbeddor()
  
  
  

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