* No project name * tasklet->task git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269051 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -102,7 +102,7 @@ Legal: | |||
| <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" | |||
| @@ -21,8 +21,7 @@ import java.util.Iterator; | |||
| 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 @@ public class Main | |||
| //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 @@ public class Main | |||
| { | |||
| 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 @@ public class Main | |||
| //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 | |||
| @@ -35,7 +35,7 @@ public class DefaultProjectEngine | |||
| 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 @@ public class DefaultProjectEngine | |||
| throws ComponentException | |||
| { | |||
| m_componentManager = (DefaultComponentManager)componentManager; | |||
| m_taskletEngine = (TaskletEngine)componentManager. | |||
| m_taskEngine = (TaskletEngine)componentManager. | |||
| lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); | |||
| } | |||
| @@ -87,13 +87,7 @@ public class DefaultProjectEngine | |||
| //HACK: should do this a better way !!!!!! | |||
| m_componentManager.put( "org.apache.ant.project.Project", project ); | |||
| //final TaskContext context = project.getContext(); | |||
| final String projectName = (String)context.getProperty( Project.PROJECT ); | |||
| m_listenerSupport.projectStarted( projectName ); | |||
| //context = new DefaultTaskletContext( context ); | |||
| m_listenerSupport.projectStarted(); | |||
| executeTargetWork( "<init>", project.getImplicitTarget(), context ); | |||
| @@ -236,7 +230,6 @@ public class DefaultProjectEngine | |||
| 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 @@ public class DefaultProjectEngine | |||
| 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(); | |||
| } | |||
| } | |||
| @@ -17,16 +17,13 @@ import org.apache.avalon.framework.ExceptionUtil; | |||
| 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 @@ public class DefaultProjectListener | |||
| } | |||
| /** | |||
| * 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 @@ public class DefaultProjectListener | |||
| */ | |||
| 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; | |||
| } | |||
| } | |||
| @@ -18,7 +18,7 @@ import org.apache.log.LogTarget; | |||
| public class LogTargetToListenerAdapter | |||
| implements LogTarget | |||
| { | |||
| protected final ProjectListener m_listener; | |||
| private final ProjectListener m_listener; | |||
| /** | |||
| * Constructor taking listener to convert to. | |||
| @@ -31,5 +31,3 @@ public interface ProjectBuilder | |||
| Project build( File source ) | |||
| throws IOException, AntException; | |||
| } | |||
| @@ -17,10 +17,8 @@ public interface ProjectListener | |||
| { | |||
| /** | |||
| * Notify listener of projectStarted event. | |||
| * | |||
| * @param projectName the projectName | |||
| */ | |||
| void projectStarted( String projectName ); | |||
| void projectStarted(); | |||
| /** | |||
| * Notify listener of projectFinished event. | |||
| @@ -40,16 +38,16 @@ public interface ProjectListener | |||
| 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. | |||
| @@ -15,7 +15,7 @@ package org.apache.ant.project; | |||
| 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 @@ public class ProjectListenerSupport | |||
| /** | |||
| * 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 @@ public class ProjectListenerSupport | |||
| * | |||
| * @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(); | |||
| } | |||
| } | |||
| @@ -5,7 +5,7 @@ | |||
| * version 1.1, a copy of which has been included with this distribution in | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.ant.launcher; | |||
| package org.apache.myrmidon.launcher; | |||
| import java.io.File; | |||
| import java.lang.reflect.Method; | |||
| @@ -14,11 +14,12 @@ import java.net.URLClassLoader; | |||
| import java.util.StringTokenizer; | |||
| /** | |||
| * Basic classloader that allows modification at runtime. | |||
| * 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 AntClassLoader | |||
| public final class LauncherClassLoader | |||
| extends URLClassLoader | |||
| { | |||
| /** | |||
| @@ -26,7 +27,7 @@ public final class AntClassLoader | |||
| * | |||
| * @param urls the Starting URLS | |||
| */ | |||
| public AntClassLoader( final URL[] urls ) | |||
| public LauncherClassLoader( final URL[] urls ) | |||
| { | |||
| super( urls ); | |||
| } | |||
| @@ -40,17 +41,19 @@ public final class AntClassLoader | |||
| { | |||
| super.addURL( url ); | |||
| } | |||
| /** | |||
| * Add an array of URLs to classloader | |||
| * | |||
| * @param url the url | |||
| */ | |||
| public void addURLs( final URL[] urls ) | |||
| /* | |||
| void addURLs( final URL[] urls ) | |||
| { | |||
| for( int i = 0; i < urls.length; i++ ) | |||
| { | |||
| addURL( urls[ i ] ); | |||
| } | |||
| } | |||
| */ | |||
| } | |||
| @@ -5,24 +5,21 @@ | |||
| * version 1.1, a copy of which has been included with this distribution in | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.ant.launcher; | |||
| 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.net.URLClassLoader; | |||
| import java.util.ArrayList; | |||
| import java.util.StringTokenizer; | |||
| /** | |||
| * Basic Loader that is responsible for all the hackery to get classloader to work. | |||
| * Other classes can call AntLoader.getLoader() and add to their own classloader. | |||
| * | |||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
| * @author <a href="mailto:mpfoemme@thoughtworks.com">Matthew Foemmel</a> | |||
| */ | |||
| public final class AntLoader | |||
| public final class Main | |||
| { | |||
| /** | |||
| * Magic entry point. | |||
| @@ -44,7 +41,7 @@ public final class AntLoader | |||
| final File libDir = new File( installDirectory, "lib" ); | |||
| final URL[] urls = buildURLList( libDir ); | |||
| final AntClassLoader classLoader = new AntClassLoader( urls ); | |||
| final LauncherClassLoader classLoader = new LauncherClassLoader( urls ); | |||
| //load class and retrieve appropriate main method. | |||
| final Class clazz = classLoader.loadClass( "org.apache.ant.Main" ); | |||
| @@ -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 | |||