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/manifest ant-manifest.mf
Date Mon, 28 May 2001 10:28:01 GMT
donaldp     01/05/28 03:28:00

  Modified:    proposal/myrmidon build.xml
               proposal/myrmidon/src/java/org/apache/ant Main.java
               proposal/myrmidon/src/java/org/apache/ant/project
                        DefaultProjectEngine.java
                        DefaultProjectListener.java
                        LogTargetToListenerAdapter.java ProjectBuilder.java
                        ProjectListener.java ProjectListenerSupport.java
               proposal/myrmidon/src/manifest ant-manifest.mf
  Added:       proposal/myrmidon/src/java/org/apache/myrmidon/launcher
                        LauncherClassLoader.java Main.java
  Removed:     proposal/myrmidon/src/java/org/apache/ant/launcher
                        AntClassLoader.java AntLoader.java
  Log:
  Update Launcher package and update ProjectListener* to reflect
  * No project name
  * tasklet->task
  
  Revision  Changes    Path
  1.10      +1 -1      jakarta-ant/proposal/myrmidon/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/build.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- build.xml	2001/05/28 07:36:39	1.9
  +++ build.xml	2001/05/28 10:27:47	1.10
  @@ -102,7 +102,7 @@
       <jar jarfile="${build.lib}/ant.jar" 
            basedir="${build.classes}" 
            manifest="${manifest.dir}/ant-manifest.mf">
  -      <include name="org/apache/ant/launcher/*" />
  +      <include name="org/apache/myrmidon/launcher/*" />
       </jar>
   
       <jar jarfile="${build.lib}/myrmidon.jar" 
  
  
  
  1.14      +4 -5      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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Main.java	2001/05/28 09:06:45	1.13
  +++ Main.java	2001/05/28 10:27:49	1.14
  @@ -21,8 +21,7 @@
   import java.util.List;
   import java.util.Map;
   import java.util.Properties;
  -import org.apache.ant.launcher.AntClassLoader;
  -import org.apache.ant.launcher.AntLoader;
  +import org.apache.myrmidon.launcher.LauncherClassLoader;
   import org.apache.ant.project.LogTargetToListenerAdapter;
   import org.apache.ant.project.Project;
   import org.apache.ant.project.ProjectBuilder;
  @@ -297,6 +296,7 @@
   
           //setup classloader so that it will correctly load
           //the Project/ProjectBuilder/ProjectEngine and all dependencies
  +        //FIXEME: Use separate classloader instead of injecting
           final ClassLoader classLoader = createClassLoader( libDir );
           Thread.currentThread().setContextClassLoader( classLoader );
   
  @@ -451,14 +451,14 @@
       {
           final ClassLoader candidate = getClass().getClassLoader();
   
  -        if( !(candidate instanceof AntClassLoader) )
  +        if( !(candidate instanceof LauncherClassLoader) )
           {
               getLogger().warn( "Warning: Unable to add entries from " +
                                 "lib-path to classloader" );
               return candidate;
           }
   
  -        final AntClassLoader classLoader = (AntClassLoader)candidate;
  +        final LauncherClassLoader classLoader = (LauncherClassLoader)candidate;
   
           final ExtensionFileFilter filter =
               new ExtensionFileFilter( new String[] { ".jar", ".zip" } );
  @@ -502,7 +502,6 @@
           //defines.put( AntContextResources.TASKLIB_DIR, m_taskLibDir );
           //defines.put( TaskletContext.JAVA_VERSION, getJavaVersion() );
   
  -        //final TaskContext context = project.getContext();
           addToContext( context, defines );
   
           //Add system properties second so that they overide user-defined properties
  
  
  
  1.10      +6 -13     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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultProjectEngine.java	2001/05/28 09:06:47	1.9
  +++ DefaultProjectEngine.java	2001/05/28 10:27:53	1.10
  @@ -35,7 +35,7 @@
       extends AbstractLoggable
       implements ProjectEngine, Composable
   {
  -    protected TaskletEngine            m_taskletEngine;
  +    protected TaskletEngine            m_taskEngine;
       protected ProjectListenerSupport   m_listenerSupport = new ProjectListenerSupport();
       protected DefaultComponentManager  m_componentManager;
   
  @@ -69,7 +69,7 @@
           throws ComponentException
       {
           m_componentManager = (DefaultComponentManager)componentManager;
  -        m_taskletEngine = (TaskletEngine)componentManager.
  +        m_taskEngine = (TaskletEngine)componentManager.
               lookup( "org.apache.ant.tasklet.engine.TaskletEngine" );
       }
   
  @@ -87,14 +87,8 @@
           //HACK: should do this a better way !!!!!!
           m_componentManager.put( "org.apache.ant.project.Project", project );
   
  -        //final TaskContext context = project.getContext();
  +        m_listenerSupport.projectStarted();
   
  -        final String projectName = (String)context.getProperty( Project.PROJECT );
  -
  -        m_listenerSupport.projectStarted( projectName );
  -
  -        //context = new DefaultTaskletContext( context );
  -
           executeTargetWork( "<init>", project.getImplicitTarget(), context );
   
           execute( project, target, context );
  @@ -236,7 +230,6 @@
           getLogger().debug( "Executing task " + name );
   
           //Set up context for task...
  -
           //is Only necessary if we are multi-threaded
           //final TaskletContext targetContext = new DefaultTaskletContext( context );
   
  @@ -244,12 +237,12 @@
           context.setProperty( TaskContext.NAME, name );
   
           //notify listeners
  -        m_listenerSupport.taskletStarted( name );
  +        m_listenerSupport.taskStarted( name );
   
           //run task
  -        m_taskletEngine.execute( task, context );
  +        m_taskEngine.execute( task, context );
   
           //notify listeners task has ended
  -        m_listenerSupport.taskletFinished();
  +        m_listenerSupport.taskFinished();
       }
   }
  
  
  
  1.5       +20 -13    jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectListener.java
  
  Index: DefaultProjectListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/DefaultProjectListener.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultProjectListener.java	2001/05/28 06:28:11	1.4
  +++ DefaultProjectListener.java	2001/05/28 10:27:53	1.5
  @@ -17,16 +17,13 @@
   public class DefaultProjectListener
       implements ProjectListener
   {
  -    protected String        m_prefix;
  +    private String        m_prefix;
   
       /**
        * Notify listener of projectStarted event.
  -     *
  -     * @param projectName the projectName
        */
  -    public void projectStarted( final String projectName )
  +    public void projectStarted()
       {
  -        output( "Starting project " + projectName + "\n" );
       }
       
       /**
  @@ -54,21 +51,21 @@
       }
       
       /**
  -     * Notify listener of taskletStarted event.
  +     * Notify listener of taskStarted event.
        *
  -     * @param taskletName the name of tasklet
  +     * @param taskName the name of task
        */
  -    public void taskletStarted( final String taskletName )
  +    public void taskStarted( final String taskName )
       {
  -        m_prefix = taskletName;
  +        setPrefix( taskName );
       }
       
       /**
  -     * Notify listener of taskletFinished event.
  +     * Notify listener of taskFinished event.
        */
  -    public void taskletFinished()
  +    public void taskFinished()
       {
  -        m_prefix = null;
  +        setPrefix( null );
       }
       
       /**
  @@ -100,7 +97,17 @@
        */
       protected void output( final String data )
       {
  -        if( null != m_prefix ) System.out.println( "\t[" + m_prefix + "] " + data );
  +        if( null != getPrefix() ) System.out.println( "\t[" + getPrefix() + "] " + data
);
           else System.out.println( data );
  +    }
  +
  +    protected final String getPrefix()
  +    {
  +        return m_prefix;
  +    }
  +
  +    protected final void setPrefix( final String prefix )
  +    {
  +        m_prefix = prefix;
       }
   }
  
  
  
  1.4       +1 -1      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/LogTargetToListenerAdapter.java
  
  Index: LogTargetToListenerAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/LogTargetToListenerAdapter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LogTargetToListenerAdapter.java	2001/05/28 06:28:11	1.3
  +++ LogTargetToListenerAdapter.java	2001/05/28 10:27:54	1.4
  @@ -18,7 +18,7 @@
   public class LogTargetToListenerAdapter
       implements LogTarget
   {
  -    protected final ProjectListener    m_listener;
  +    private final ProjectListener    m_listener;
   
       /**
        * Constructor taking listener to convert to.
  
  
  
  1.4       +0 -2      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/ProjectBuilder.java
  
  Index: ProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/ProjectBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProjectBuilder.java	2001/05/28 06:28:11	1.3
  +++ ProjectBuilder.java	2001/05/28 10:27:55	1.4
  @@ -31,5 +31,3 @@
       Project build( File source )
           throws IOException, AntException;
   }
  -
  -
  
  
  
  1.4       +6 -8      jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/ProjectListener.java
  
  Index: ProjectListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/ProjectListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ProjectListener.java	2001/01/08 04:36:45	1.3
  +++ ProjectListener.java	2001/05/28 10:27:55	1.4
  @@ -17,10 +17,8 @@
   {
       /**
        * Notify listener of projectStarted event.
  -     *
  -     * @param projectName the projectName
        */
  -    void projectStarted( String projectName );
  +    void projectStarted();
   
       /**
        * Notify listener of projectFinished event.
  @@ -40,16 +38,16 @@
       void targetFinished();
   
       /**
  -     * Notify listener of taskletStarted event.
  +     * Notify listener of taskStarted event.
        *
  -     * @param taskletName the name of tasklet
  +     * @param taskName the name of task
        */
  -    void taskletStarted( String taskletName );
  +    void taskStarted( String taskName );
   
       /**
  -     * Notify listener of taskletFinished event.
  +     * Notify listener of taskFinished event.
        */
  -    void taskletFinished();
  +    void taskFinished();
   
       /**
        * Notify listener of log message event.
  
  
  
  1.3       +8 -10     jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/ProjectListenerSupport.java
  
  Index: ProjectListenerSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/ant/project/ProjectListenerSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProjectListenerSupport.java	2001/01/08 04:36:45	1.2
  +++ ProjectListenerSupport.java	2001/05/28 10:27:55	1.3
  @@ -15,7 +15,7 @@
   public class ProjectListenerSupport
       implements ProjectListener
   {
  -    protected ProjectListener[]   m_listeners = new ProjectListener[ 0 ];
  +    private ProjectListener[]   m_listeners = new ProjectListener[ 0 ];
   
       /**
        * Add an extra project listener that wants to receive notification of listener events.
  @@ -61,14 +61,12 @@
   
       /**
        * Fire a projectStarted event.
  -     *
  -     * @param projectName the projectName
        */
  -    public void projectStarted( final String projectName )
  +    public void projectStarted()
       {
           for( int i = 0; i < m_listeners.length; i++ )
           {
  -            m_listeners[ i ].projectStarted( projectName );
  +            m_listeners[ i ].projectStarted();
           }
       }
   
  @@ -112,22 +110,22 @@
        *
        * @param targetName the name of target
        */
  -    public void taskletStarted( String taskletName )
  +    public void taskStarted( String taskName )
       {
           for( int i = 0; i < m_listeners.length; i++ )
           {
  -            m_listeners[ i ].taskletStarted( taskletName );
  +            m_listeners[ i ].taskStarted( taskName );
           }
       }
   
       /**
  -     * Fire a taskletFinished event.
  +     * Fire a taskFinished event.
        */
  -    public void taskletFinished()
  +    public void taskFinished()
       {
           for( int i = 0; i < m_listeners.length; i++ )
           {
  -            m_listeners[ i ].taskletFinished();
  +            m_listeners[ i ].taskFinished();
           }
       }
   
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/launcher/LauncherClassLoader.java
  
  Index: LauncherClassLoader.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.launcher;
  
  import java.io.File;
  import java.lang.reflect.Method;
  import java.net.URL;
  import java.net.URLClassLoader;
  import java.util.StringTokenizer;
  
  /**
   * Basic classloader that allows addition of URLs at runtime.
   * Used from Main.class to inject Classes into ClassLoader.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public final class LauncherClassLoader
      extends URLClassLoader
  {
      /**
       * Basic constructor.
       *
       * @param urls the Starting URLS
       */
      public LauncherClassLoader( final URL[] urls )
      {
          super( urls );
      }
  
      /**
       * Add a URL to classloader
       *
       * @param url the url
       */
      public void addURL( final URL url )
      {
          super.addURL( url );
      }
  
      /**
       * Add an array of URLs to classloader
       *
       * @param url the url
       */
  /*
      void addURLs( final URL[] urls )
      {
          for( int i = 0; i < urls.length; i++ )
          {
              addURL( urls[ i ] );
          }
      }
  */
  }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/launcher/Main.java
  
  Index: Main.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.launcher;
  
  import java.io.File;
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.StringTokenizer;
  
  /**
   * Basic Loader that is responsible for all the hackery to get classloader to work.
   *
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public final class Main
  {
      /**
       * Magic entry point.
       *
       * @param args the CLI arguments
       * @exception Exception if an error occurs
       */
      public final static void main( final String[] args )
          throws Exception
      {
          try
          {
              //actually try to discover the install directory based on where
              // the ant.jar is
              final File installDirectory = findInstallDir();
              System.setProperty( "ant.home", installDirectory.toString() );
  
              //setup classloader appropriately for myrmidon jar
              final File libDir = new File( installDirectory, "lib" );
              final URL[] urls = buildURLList( libDir );
  
              final LauncherClassLoader classLoader = new LauncherClassLoader( urls );
  
              //load class and retrieve appropriate main method.
              final Class clazz = classLoader.loadClass( "org.apache.ant.Main" );
              final Method method = clazz.getMethod( "main", new Class[] { args.getClass()
} );
  
              //kick the tires and light the fires....
              method.invoke( null, new Object[] { args } );
          }
          catch( final InvocationTargetException ite )
          {
              System.err.println( "Error: " + ite.getTargetException().getMessage() );
              ite.getTargetException().printStackTrace();
          }
          catch( final Throwable throwable )
          {
              System.err.println( "Error: " + throwable.getMessage() );
              throwable.printStackTrace();
          }
      }
  
      private final static URL[] buildURLList( final File dir )
          throws Exception
      {
          final ArrayList urlList = new ArrayList();
  
          final File[] contents = dir.listFiles();
  
          if( null == contents )
          {
              return new URL[ 0 ];
          }
  
          for( int i = 0; i < contents.length; i++ )
          {
              final File file = contents[ i ];
  
              if( !file.isFile() || !file.canRead() )
              {
                  continue;
              }
  
              urlList.add( file.toURL() );
          }
  
          return (URL[])urlList.toArray( new URL[ 0 ] );
      }
  
      /**
       *  Finds the ant.jar file in the classpath.
       */
      private final static File findInstallDir()
          throws Exception
      {
          final String classpath = System.getProperty( "java.class.path" );
          final String pathSeparator = System.getProperty( "path.separator" );
          final StringTokenizer tokenizer = new StringTokenizer( classpath, pathSeparator
);
  
          while( tokenizer.hasMoreTokens() )
          {
              final String element = tokenizer.nextToken();
  
              if( element.endsWith( "ant.jar" ) )
              {
                  File file = (new File( element )).getAbsoluteFile();
                  file = file.getParentFile();
  
                  if( null != file )
                  {
                      file = file.getParentFile();
                  }
  
                  return file;
              }
          }
  
          throw new Exception( "Unable to locate ant.jar in classpath" );
      }
  }
  
  
  
  1.2       +1 -1      jakarta-ant/proposal/myrmidon/src/manifest/ant-manifest.mf
  
  Index: ant-manifest.mf
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/manifest/ant-manifest.mf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ant-manifest.mf	2000/12/05 09:22:03	1.1
  +++ ant-manifest.mf	2001/05/28 10:27:59	1.2
  @@ -1,3 +1,3 @@
   Manifest-Version: 1.0
  -Main-Class: org.apache.ant.launcher.AntLoader
  +Main-Class: org.apache.myrmidon.launcher.Main
   Created-By: Apache Ant Project
  
  
  

Mime
View raw message