git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269047 13f79535-47bb-0310-9956-ffa450edef68master
@@ -1,19 +0,0 @@ | |||||
@echo off | |||||
echo. | |||||
echo Ant Build System | |||||
echo ---------------- | |||||
set ANT_HOME=tools | |||||
set LOCALCLASSPATH= | |||||
for %%i in (lib\*.jar) do call tools\bin\lcp.bat %%i | |||||
set CLASSPATH=%LOCALCLASSPATH% | |||||
set LOCALCLASSPATH= | |||||
%ANT_HOME%\bin\ant.bat -logger org.apache.tools.ant.NoBannerLogger -emacs %1 %2 %3 %4 %5 %6 %7 %8 | |||||
goto cleanup | |||||
:cleanup | |||||
set ANT_HOME= | |||||
set CLASSPATH= |
@@ -4,9 +4,12 @@ echo | |||||
echo "Ant Build System" | echo "Ant Build System" | ||||
echo "----------------" | echo "----------------" | ||||
chmod u+x $PWD/bin/antRun | |||||
chmod u+x $PWD/bin/ant | |||||
export MYRMIDON_HOME=tools | |||||
export ANT_HOME=. | |||||
chmod u+x $MYRMIDON_HOME/bin/antRun | |||||
chmod u+x $MYRMIDON_HOME/bin/ant | |||||
$PWD/bin/ant -emacs $@ | |||||
export ANT_HOME= | |||||
export CLASSPATH=lib/xerces.jar | |||||
$MYRMIDON_HOME/bin/ant -logger org.apache.tools.ant.NoBannerLogger -emacs $@ |
@@ -46,111 +46,39 @@ Legal: | |||||
<property name="build.lib" value="${build.dir}/lib"/> | <property name="build.lib" value="${build.dir}/lib"/> | ||||
<property name="build.src" value="${build.dir}/src"/> | <property name="build.src" value="${build.dir}/src"/> | ||||
<property name="build.classes" value="${build.dir}/classes"/> | <property name="build.classes" value="${build.dir}/classes"/> | ||||
<property name="build.javadocs" value="${build.dir}/javadocs"/> | |||||
<property name="build.docs" value="${build.dir}/docs"/> | |||||
<property name="src.base" value="src"/> | <property name="src.base" value="src"/> | ||||
<property name="manifest.dir" value="${src.base}/manifest"/> | <property name="manifest.dir" value="${src.base}/manifest"/> | ||||
<property name="xdocs.dir" value="${src.base}/xdocs"/> | |||||
<property name="java.dir" value="${src.base}/java"/> | <property name="java.dir" value="${src.base}/java"/> | ||||
<property name="skins.dir" value="${src.base}/skins"/> | |||||
<property name="script.dir" value="${src.base}/script"/> | <property name="script.dir" value="${src.base}/script"/> | ||||
<property name="lib.dir" value="lib"/> | <property name="lib.dir" value="lib"/> | ||||
<property name="dist.name" value="${Name}-${version}"/> | <property name="dist.name" value="${Name}-${version}"/> | ||||
<!-- <property name="dist.dir" value="${dist.name}"/> --> | |||||
<property name="dist.dir" value="dist"/> | <property name="dist.dir" value="dist"/> | ||||
<property name="dist.bin" value="${dist.dir}/bin"/> | <property name="dist.bin" value="${dist.dir}/bin"/> | ||||
<property name="dist.blocks" value="${dist.dir}/bin/blocks"/> | |||||
<property name="dist.lib" value="${dist.dir}/lib"/> | <property name="dist.lib" value="${dist.dir}/lib"/> | ||||
<property name="dist.docs" value="${dist.dir}/docs"/> | |||||
<property name="dist.javadocs" value="${dist.dir}/docs/api"/> | |||||
<property name="dist.src.base" value="${dist.dir}/src"/> | |||||
<property name="dist.conf" value="${dist.dir}/conf"/> | |||||
<property name="dist.log" value="${dist.dir}/logs"/> | |||||
<property name="constants.file" value="org/apache/ant/Constants.java"/> | <property name="constants.file" value="org/apache/ant/Constants.java"/> | ||||
<!-- | |||||
=================================================================== | |||||
Main target | |||||
=================================================================== | |||||
--> | |||||
<target name="main" depends="dist" /> | |||||
<path id="project.class.path"> | |||||
<pathelement path="${java.class.path}" /> | |||||
<fileset dir="${lib.dir}"> | |||||
<include name="*.jar" /> | |||||
</fileset> | |||||
<pathelement path="${build.classes}" /> | |||||
</path> | |||||
<!-- | |||||
=================================================================== | |||||
Help on usage | |||||
=================================================================== | |||||
--> | |||||
<target name="usage"> | |||||
<echo message=""/> | |||||
<echo message="${Name} Build file"/> | |||||
<echo message="-------------------------------------------------------------"/> | |||||
<echo message=""/> | |||||
<echo message=" available targets are:"/> | |||||
<echo message=""/> | |||||
<echo message=" jar -> generates the ${Name} jar files"/> | |||||
<echo message=" compile -> compiles the source code"/> | |||||
<echo message=" dist -> generates the ${Name} distribution (default)"/> | |||||
<echo message=" clean -> cleans up the created directories"/> | |||||
<echo message=" real-clean -> cleans up all genereated files and directories"/> | |||||
<!-- | |||||
<echo message=" test -> perform unit tests"/> | |||||
<echo message=" javadocs -> generates the API documentation (java 1.2+ only)"/> | |||||
<echo message=" docs -> generates the ${Name} documentation"/> | |||||
--> | |||||
<echo message=""/> | |||||
<echo message="-------------------------------------------------------------"/> | |||||
<echo message=""/> | |||||
</target> | |||||
<target name="help" depends="usage"/> | |||||
<!-- Main target --> | |||||
<target name="main" depends="dist" /> | |||||
<!-- Compiles the source code --> | |||||
<target name="compile"> | |||||
<!-- | |||||
=================================================================== | |||||
Prepares the build directory | |||||
=================================================================== | |||||
--> | |||||
<target name="prepare"> | |||||
<tstamp/> | <tstamp/> | ||||
<mkdir dir="${build.dir}"/> | |||||
</target> | |||||
<!-- | |||||
=================================================================== | |||||
Prepares the library code | |||||
=================================================================== | |||||
--> | |||||
<target name="prepare-lib" depends="prepare"> | |||||
<mkdir dir="${build.lib}"/> | |||||
<copy file="${lib.dir}/xerces.jar" todir="${build.lib}"/> | |||||
<copy file="${lib.dir}/avalonapi.jar" todir="${build.lib}"/> | |||||
</target> | |||||
<!-- | |||||
=================================================================== | |||||
Prepares the source code | |||||
=================================================================== | |||||
--> | |||||
<target name="prepare-src" depends="prepare"> | |||||
<mkdir dir="${build.src}"/> | <mkdir dir="${build.src}"/> | ||||
<copy todir="${build.src}"> | |||||
<fileset dir="${java.dir}"> | |||||
<include name="${constants.file}" /> | |||||
</fileset> | |||||
</copy> | |||||
<copy file="${java.dir}/${constants.file}" tofile="${build.src}/${constants.file}"/> | |||||
<replace file="${build.src}/${constants.file}" token="@@VERSION@@" value="${version}" /> | <replace file="${build.src}/${constants.file}" token="@@VERSION@@" value="${version}" /> | ||||
<replace file="${build.src}/${constants.file}" token="@@DATE@@" value="${TODAY}" /> | <replace file="${build.src}/${constants.file}" token="@@DATE@@" value="${TODAY}" /> | ||||
</target> | |||||
<!-- | |||||
=================================================================== | |||||
Compiles the source code | |||||
=================================================================== | |||||
--> | |||||
<target name="compile" depends="prepare-src,prepare-lib"> | |||||
<mkdir dir="${build.classes}"/> | <mkdir dir="${build.classes}"/> | ||||
<javac srcdir="${java.dir}" | <javac srcdir="${java.dir}" | ||||
@@ -158,43 +86,25 @@ Legal: | |||||
debug="${debug}" | debug="${debug}" | ||||
optimize="${optimize}" | optimize="${optimize}" | ||||
deprecation="${deprecation}"> | deprecation="${deprecation}"> | ||||
<classpath refid="project.class.path"/> | |||||
<exclude name="org/apache/ant/gui/**"/> | <exclude name="org/apache/ant/gui/**"/> | ||||
<exclude name="${constants.file}"/> | <exclude name="${constants.file}"/> | ||||
<src path="${build.src}" /> | <src path="${build.src}" /> | ||||
</javac> | </javac> | ||||
<!-- | |||||
<copy todir="${build.classes}"> | |||||
<fileset dir="${java.dir}"> | |||||
<include name="**/*.properties"/> | |||||
</fileset> | |||||
</copy> | |||||
--> | |||||
</target> | |||||
<mkdir dir="${build.classes}/TASK-LIB"/> | |||||
<copy file="${manifest.dir}/taskdefs.xml" todir="${build.classes}/TASK-LIB"/> | |||||
<!-- Creates the jars file --> | |||||
<target name="jars" depends="compile"> | |||||
</target> | |||||
<mkdir dir="${build.lib}"/> | |||||
<!-- | |||||
=================================================================== | |||||
Creates the ant.jar file | |||||
=================================================================== | |||||
--> | |||||
<target name="jar-ant" depends="compile"> | |||||
<jar jarfile="${build.lib}/ant.jar" | <jar jarfile="${build.lib}/ant.jar" | ||||
basedir="${build.classes}" | basedir="${build.classes}" | ||||
manifest="${manifest.dir}/ant-manifest.mf"> | manifest="${manifest.dir}/ant-manifest.mf"> | ||||
<include name="org/apache/ant/launcher/*" /> | <include name="org/apache/ant/launcher/*" /> | ||||
</jar> | </jar> | ||||
</target> | |||||
<!-- | |||||
=================================================================== | |||||
Creates the myrmidon.jar file | |||||
=================================================================== | |||||
--> | |||||
<target name="jar-myrmidon" depends="compile"> | |||||
<jar jarfile="${build.lib}/myrmidon.jar" | <jar jarfile="${build.lib}/myrmidon.jar" | ||||
basedir="${build.classes}" | basedir="${build.classes}" | ||||
manifest="${manifest.dir}/myrmidon-manifest.mf"> | manifest="${manifest.dir}/myrmidon-manifest.mf"> | ||||
@@ -203,32 +113,29 @@ Legal: | |||||
<exclude name="org/apache/ant/tasks/**" /> | <exclude name="org/apache/ant/tasks/**" /> | ||||
<exclude name="org/apache/ant/convert/core/**" /> | <exclude name="org/apache/ant/convert/core/**" /> | ||||
</jar> | </jar> | ||||
</target> | |||||
<!-- | |||||
=================================================================== | |||||
Creates the ant.jar file | |||||
=================================================================== | |||||
--> | |||||
<target name="jar-core" depends="compile"> | |||||
<jar jarfile="${build.lib}/core.tsk" basedir="${build.classes}"> | <jar jarfile="${build.lib}/core.tsk" basedir="${build.classes}"> | ||||
<include name="org/apache/ant/modules/**" /> | <include name="org/apache/ant/modules/**" /> | ||||
<include name="TASK-LIB/*" /> | |||||
<zipfileset dir="${manifest.dir}" fullpath="TASK-LIB/taskdefs.xml"> | |||||
<include name="taskdefs.xml"/> | |||||
</zipfileset> | |||||
</jar> | </jar> | ||||
</target> | </target> | ||||
<!-- | |||||
=================================================================== | |||||
Creates the distribution | |||||
=================================================================== | |||||
--> | |||||
<target name="dist" depends="jar-ant,jar-core,jar-myrmidon"> | |||||
<mkdir dir="${dist.dir}"/> | |||||
<!-- Creates the distribution --> | |||||
<target name="dist" depends="jars"> | |||||
<mkdir dir="${dist.bin}"/> | <mkdir dir="${dist.bin}"/> | ||||
<mkdir dir="${dist.lib}"/> | <mkdir dir="${dist.lib}"/> | ||||
<copy todir="${dist.lib}"> | <copy todir="${dist.lib}"> | ||||
<fileset dir="${build.lib}"> | |||||
<fileset dir="${build.lib}"/> | |||||
</copy> | |||||
<copy todir="${dist.lib}"> | |||||
<fileset dir="${lib.dir}"> | |||||
<exclude name="xalan*" /> | <exclude name="xalan*" /> | ||||
<exclude name="StyleBook*" /> | <exclude name="StyleBook*" /> | ||||
</fileset> | </fileset> | ||||
@@ -246,20 +153,7 @@ Legal: | |||||
</target> | </target> | ||||
<!-- | |||||
=================================================================== | |||||
Performs unit tests | |||||
=================================================================== | |||||
--> | |||||
<target name="test" depends="jar-ant" if="test-task.present"> | |||||
<ant antfile="build-test.xml" dir="src/make" target="test" /> | |||||
</target> | |||||
<!-- | |||||
=================================================================== | |||||
Cleans up build and distribution directories | |||||
=================================================================== | |||||
--> | |||||
<!-- Cleans up build and distribution directories --> | |||||
<target name="clean"> | <target name="clean"> | ||||
<delete dir="${build.dir}"/> | <delete dir="${build.dir}"/> | ||||
<delete dir="${dist.dir}"/> | <delete dir="${dist.dir}"/> | ||||
@@ -268,15 +162,4 @@ Legal: | |||||
</delete> | </delete> | ||||
</target> | </target> | ||||
<!-- | |||||
=================================================================== | |||||
Cleans absolutely everything up | |||||
=================================================================== | |||||
--> | |||||
<target name="real-clean" depends="clean"> | |||||
<delete file="${dist.name}.tar.gz"/> | |||||
<delete file="${dist.name}.zip"/> | |||||
<delete dir="${javadocs.dir}"/> | |||||
</target> | |||||
</project> | </project> |
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.ant; | package org.apache.ant; | ||||
import org.apache.avalon.CascadingRuntimeException; | |||||
import org.apache.avalon.framework.CascadingRuntimeException; | |||||
/** | /** | ||||
* AntException thrown when a problem with tasks etc. | * AntException thrown when a problem with tasks etc. | ||||
@@ -33,34 +33,35 @@ import org.apache.ant.runtime.DefaultAntEngine; | |||||
import org.apache.ant.tasklet.JavaVersion; | import org.apache.ant.tasklet.JavaVersion; | ||||
import org.apache.ant.tasklet.TaskletContext; | import org.apache.ant.tasklet.TaskletContext; | ||||
import org.apache.ant.tasklet.engine.TaskletEngine; | import org.apache.ant.tasklet.engine.TaskletEngine; | ||||
import org.apache.avalon.Disposable; | |||||
import org.apache.avalon.Initializable; | |||||
import org.apache.avalon.camelot.CamelotUtil; | |||||
import org.apache.avalon.camelot.Deployer; | |||||
import org.apache.avalon.camelot.DeploymentException; | |||||
import org.apache.avalon.util.ObjectUtil; | |||||
import org.apache.avalon.util.StringUtil; | |||||
import org.apache.avalon.util.cli.AbstractMain; | |||||
import org.apache.avalon.util.cli.CLOption; | |||||
import org.apache.avalon.util.cli.CLOptionDescriptor; | |||||
import org.apache.avalon.util.io.ExtensionFileFilter; | |||||
import org.apache.log.Category; | |||||
import org.apache.log.LogKit; | |||||
import org.apache.avalon.excalibur.cli.CLArgsParser; | |||||
import org.apache.avalon.excalibur.cli.CLOption; | |||||
import org.apache.avalon.excalibur.cli.CLUtil; | |||||
import org.apache.avalon.excalibur.cli.CLOptionDescriptor; | |||||
import org.apache.avalon.excalibur.io.ExtensionFileFilter; | |||||
import org.apache.avalon.framework.ExceptionUtil; | |||||
import org.apache.avalon.framework.activity.Disposable; | |||||
import org.apache.avalon.framework.activity.Initializable; | |||||
import org.apache.avalon.framework.camelot.CamelotUtil; | |||||
import org.apache.avalon.framework.camelot.Deployer; | |||||
import org.apache.avalon.framework.camelot.DeploymentException; | |||||
import org.apache.avalon.framework.logger.AbstractLoggable; | |||||
import org.apache.log.Hierarchy; | |||||
import org.apache.log.Logger; | import org.apache.log.Logger; | ||||
import org.apache.log.LogTarget; | |||||
import org.apache.log.Priority; | import org.apache.log.Priority; | ||||
/** | /** | ||||
* The class to kick the tires and light the fires. | * The class to kick the tires and light the fires. | ||||
* Starts ant, loads ProjectBuilder, builds project then uses ProjectEngine | * Starts ant, loads ProjectBuilder, builds project then uses ProjectEngine | ||||
* to run project. | * to run project. | ||||
* | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | ||||
*/ | */ | ||||
public class Main | public class Main | ||||
extends AbstractMain | |||||
extends AbstractLoggable | |||||
{ | { | ||||
//Constants to indicate the build of Ant/Myrmidon | //Constants to indicate the build of Ant/Myrmidon | ||||
public final static String VERSION = | |||||
public final static String VERSION = | |||||
"Ant " + Constants.BUILD_VERSION + " compiled on " + Constants.BUILD_DATE; | "Ant " + Constants.BUILD_VERSION + " compiled on " + Constants.BUILD_DATE; | ||||
//default log level | //default log level | ||||
@@ -69,7 +70,7 @@ public class Main | |||||
//Some defaults for file locations/names | //Some defaults for file locations/names | ||||
protected final static String DEFAULT_FILENAME = "build.ant"; | protected final static String DEFAULT_FILENAME = "build.ant"; | ||||
protected final static String DEFAULT_LISTENER = | |||||
protected final static String DEFAULT_LISTENER = | |||||
"org.apache.ant.project.DefaultProjectListener"; | "org.apache.ant.project.DefaultProjectListener"; | ||||
//defines for the Command Line options | //defines for the Command Line options | ||||
@@ -84,17 +85,17 @@ public class Main | |||||
private static final int TASKLIB_DIR_OPT = 5; | private static final int TASKLIB_DIR_OPT = 5; | ||||
private static final int INCREMENTAL_OPT = 6; | private static final int INCREMENTAL_OPT = 6; | ||||
private static final int HOME_DIR_OPT = 7; | private static final int HOME_DIR_OPT = 7; | ||||
//incompatable options for info options | //incompatable options for info options | ||||
private static final int[] INFO_OPT_INCOMPAT = new int[] | |||||
{ | |||||
HELP_OPT, QUIET_OPT, VERBOSE_OPT, FILE_OPT, | |||||
private static final int[] INFO_OPT_INCOMPAT = new int[] | |||||
{ | |||||
HELP_OPT, QUIET_OPT, VERBOSE_OPT, FILE_OPT, | |||||
LOG_LEVEL_OPT, VERSION_OPT, LISTENER_OPT, | LOG_LEVEL_OPT, VERSION_OPT, LISTENER_OPT, | ||||
DEFINE_OPT //TASKLIB_DIR_OPT, HOME_DIR_OPT | DEFINE_OPT //TASKLIB_DIR_OPT, HOME_DIR_OPT | ||||
}; | }; | ||||
//incompatable options for other logging options | //incompatable options for other logging options | ||||
private static final int[] LOG_OPT_INCOMPAT = new int[] | |||||
private static final int[] LOG_OPT_INCOMPAT = new int[] | |||||
{ | { | ||||
QUIET_OPT, VERBOSE_OPT, LOG_LEVEL_OPT | QUIET_OPT, VERBOSE_OPT, LOG_LEVEL_OPT | ||||
}; | }; | ||||
@@ -110,21 +111,32 @@ public class Main | |||||
public static void main( final String[] args ) | public static void main( final String[] args ) | ||||
{ | { | ||||
final Main main = new Main(); | final Main main = new Main(); | ||||
main.setLogger( LogKit.getLoggerFor( "default" ) ); | |||||
main.setLogger( Hierarchy.getDefaultHierarchy().getLoggerFor( "default" ) ); | |||||
try { main.execute( args ); } | try { main.execute( args ); } | ||||
catch( final AntException ae ) | catch( final AntException ae ) | ||||
{ | { | ||||
main.getLogger().error( "Error: " + ae.getMessage() ); | main.getLogger().error( "Error: " + ae.getMessage() ); | ||||
main.getLogger().debug( "Exception..." + StringUtil.printStackTrace( ae ) ); | |||||
main.getLogger().debug( "Exception..." + ExceptionUtil.printStackTrace( ae ) ); | |||||
} | } | ||||
catch( final Throwable throwable ) | catch( final Throwable throwable ) | ||||
{ | { | ||||
main.getLogger().error( "Error: " + throwable ); | main.getLogger().error( "Error: " + throwable ); | ||||
main.getLogger().debug( "Exception..." + StringUtil.printStackTrace( throwable ) ); | |||||
main.getLogger().debug( "Exception..." + ExceptionUtil.printStackTrace( throwable ) ); | |||||
} | } | ||||
} | } | ||||
/** | |||||
* Display usage report. | |||||
* | |||||
*/ | |||||
protected void usage( final CLOptionDescriptor[] options ) | |||||
{ | |||||
System.out.println( "java " + getClass().getName() + " [options]" ); | |||||
System.out.println( "\tAvailable options:"); | |||||
System.out.println( CLUtil.describeOptions( options ) ); | |||||
} | |||||
/** | /** | ||||
* Initialise the options for command line parser. | * Initialise the options for command line parser. | ||||
* This is called by super-class. | * This is called by super-class. | ||||
@@ -140,7 +152,7 @@ public class Main | |||||
HELP_OPT, | HELP_OPT, | ||||
"display this help message", | "display this help message", | ||||
INFO_OPT_INCOMPAT ); | INFO_OPT_INCOMPAT ); | ||||
options[1] = | options[1] = | ||||
new CLOptionDescriptor( "file", | new CLOptionDescriptor( "file", | ||||
CLOptionDescriptor.ARGUMENT_REQUIRED, | CLOptionDescriptor.ARGUMENT_REQUIRED, | ||||
@@ -206,14 +218,19 @@ public class Main | |||||
return options; | return options; | ||||
} | } | ||||
/** | |||||
* Entry point for standard ant. | |||||
* | |||||
* @param clOptions the list of command line options | |||||
*/ | |||||
protected void execute( final List clOptions ) | |||||
protected void execute( final String[] args ) | |||||
throws Exception | throws Exception | ||||
{ | { | ||||
final CLOptionDescriptor[] options = createCLOptions(); | |||||
final CLArgsParser parser = new CLArgsParser( args, options ); | |||||
if( null != parser.getErrorString() ) | |||||
{ | |||||
System.err.println( "Error: " + parser.getErrorString() ); | |||||
return; | |||||
} | |||||
final List clOptions = parser.getArguments(); | |||||
final int size = clOptions.size(); | final int size = clOptions.size(); | ||||
final ArrayList targets = new ArrayList(); | final ArrayList targets = new ArrayList(); | ||||
String filename = null; | String filename = null; | ||||
@@ -224,25 +241,25 @@ public class Main | |||||
boolean incremental = false; | boolean incremental = false; | ||||
HashMap defines = new HashMap(); | HashMap defines = new HashMap(); | ||||
for( int i = 0; i < size; i++ ) | |||||
for( int i = 0; i < size; i++ ) | |||||
{ | { | ||||
final CLOption option = (CLOption)clOptions.get( i ); | final CLOption option = (CLOption)clOptions.get( i ); | ||||
switch( option.getId() ) | switch( option.getId() ) | ||||
{ | { | ||||
case 0: targets.add( option.getArgument() ); break; | case 0: targets.add( option.getArgument() ); break; | ||||
case HELP_OPT: usage(); return; | |||||
case HELP_OPT: usage( options ); return; | |||||
case VERSION_OPT: System.out.println( VERSION ); return; | case VERSION_OPT: System.out.println( VERSION ); return; | ||||
case FILE_OPT: filename = option.getArgument(); break; | case FILE_OPT: filename = option.getArgument(); break; | ||||
case HOME_DIR_OPT: homeDir = option.getArgument(); break; | case HOME_DIR_OPT: homeDir = option.getArgument(); break; | ||||
case TASKLIB_DIR_OPT: taskLibDir = option.getArgument(); break; | case TASKLIB_DIR_OPT: taskLibDir = option.getArgument(); break; | ||||
case VERBOSE_OPT: logLevel = "INFO"; break; | case VERBOSE_OPT: logLevel = "INFO"; break; | ||||
case QUIET_OPT: logLevel = "ERROR"; break; | case QUIET_OPT: logLevel = "ERROR"; break; | ||||
case LOG_LEVEL_OPT: logLevel = option.getArgument(); break; | |||||
case LOG_LEVEL_OPT: logLevel = option.getArgument(); break; | |||||
case LISTENER_OPT: listenerName = option.getArgument(); break; | case LISTENER_OPT: listenerName = option.getArgument(); break; | ||||
case INCREMENTAL_OPT: incremental = true; break; | case INCREMENTAL_OPT: incremental = true; break; | ||||
case DEFINE_OPT: | |||||
case DEFINE_OPT: | |||||
defines.put( option.getArgument( 0 ), option.getArgument( 1 ) ); | defines.put( option.getArgument( 0 ), option.getArgument( 1 ) ); | ||||
break; | break; | ||||
} | } | ||||
@@ -255,7 +272,7 @@ public class Main | |||||
//handle logging... | //handle logging... | ||||
setLogger( createLogger( logLevel ) ); | setLogger( createLogger( logLevel ) ); | ||||
//if ant home not set then use system property ant.home | |||||
//if ant home not set then use system property ant.home | |||||
//that was set up by launcher. | //that was set up by launcher. | ||||
if( null == homeDir ) homeDir = System.getProperty( "ant.home" ); | if( null == homeDir ) homeDir = System.getProperty( "ant.home" ); | ||||
@@ -277,14 +294,14 @@ public class Main | |||||
{ | { | ||||
throw new AntException( "File " + buildFile + " is not a file or doesn't exist" ); | throw new AntException( "File " + buildFile + " is not a file or doesn't exist" ); | ||||
} | } | ||||
//setup classloader so that it will correctly load | //setup classloader so that it will correctly load | ||||
//the Project/ProjectBuilder/ProjectEngine and all dependencies | //the Project/ProjectBuilder/ProjectEngine and all dependencies | ||||
final ClassLoader classLoader = createClassLoader( libDir ); | final ClassLoader classLoader = createClassLoader( libDir ); | ||||
Thread.currentThread().setContextClassLoader( classLoader ); | Thread.currentThread().setContextClassLoader( classLoader ); | ||||
//handle listener.. | |||||
final ProjectListener listener = createListener( listenerName ); | |||||
//handle listener.. | |||||
final ProjectListener listener = createListener( listenerName ); | |||||
getLogger().warn( "Ant Build File: " + buildFile ); | getLogger().warn( "Ant Build File: " + buildFile ); | ||||
getLogger().info( "Ant Home Directory: " + m_homeDir ); | getLogger().info( "Ant Home Directory: " + m_homeDir ); | ||||
@@ -295,7 +312,7 @@ public class Main | |||||
final AntEngine antEngine = new DefaultAntEngine(); | final AntEngine antEngine = new DefaultAntEngine(); | ||||
setupLogger( antEngine ); | setupLogger( antEngine ); | ||||
antEngine.setProperties( properties ); | antEngine.setProperties( properties ); | ||||
antEngine.init(); | |||||
antEngine.initialize(); | |||||
final ProjectBuilder builder = antEngine.getProjectBuilder(); | final ProjectBuilder builder = antEngine.getProjectBuilder(); | ||||
@@ -324,9 +341,9 @@ public class Main | |||||
} | } | ||||
String line = reader.readLine(); | String line = reader.readLine(); | ||||
if( line.equalsIgnoreCase( "no" ) ) break; | if( line.equalsIgnoreCase( "no" ) ) break; | ||||
} | } | ||||
antEngine.dispose(); | antEngine.dispose(); | ||||
@@ -339,14 +356,14 @@ public class Main | |||||
* @param project the project | * @param project the project | ||||
* @param targets the targets to build as passed by CLI | * @param targets the targets to build as passed by CLI | ||||
*/ | */ | ||||
protected void doBuild( final ProjectEngine engine, | |||||
final Project project, | |||||
protected void doBuild( final ProjectEngine engine, | |||||
final Project project, | |||||
final ArrayList targets ) | final ArrayList targets ) | ||||
{ | { | ||||
try | try | ||||
{ | { | ||||
final int targetCount = targets.size(); | final int targetCount = targets.size(); | ||||
//if we didn't specify a target on CLI then choose default | //if we didn't specify a target on CLI then choose default | ||||
if( 0 == targetCount ) | if( 0 == targetCount ) | ||||
{ | { | ||||
@@ -363,10 +380,10 @@ public class Main | |||||
catch( final AntException ae ) | catch( final AntException ae ) | ||||
{ | { | ||||
getLogger().error( "BUILD FAILED" ); | getLogger().error( "BUILD FAILED" ); | ||||
getLogger().error( "Reason:\n" + StringUtil.printStackTrace( ae, 5, true ) ); | |||||
getLogger().error( "Reason:\n" + ExceptionUtil.printStackTrace( ae, 5, true ) ); | |||||
} | } | ||||
} | |||||
} | |||||
/** | /** | ||||
* Create Logger of appropriate log-level. | * Create Logger of appropriate log-level. | ||||
* | * | ||||
@@ -378,15 +395,19 @@ public class Main | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
final String logLevelCapitalized = logLevel.toUpperCase(); | final String logLevelCapitalized = logLevel.toUpperCase(); | ||||
final Priority.Enum priority = LogKit.getPriorityForName( logLevelCapitalized ); | |||||
final Priority priority = Priority.getPriorityForName( logLevelCapitalized ); | |||||
if( !priority.getName().equals( logLevelCapitalized ) ) | if( !priority.getName().equals( logLevelCapitalized ) ) | ||||
{ | { | ||||
throw new AntException( "Unknown log level - " + logLevel ); | throw new AntException( "Unknown log level - " + logLevel ); | ||||
} | } | ||||
final Logger logger = | |||||
Hierarchy.getDefaultHierarchy().getLoggerFor( "ant" ); | |||||
logger.setPriority( priority ); | |||||
final Category category = LogKit.createCategory( "ant", priority ); | |||||
return LogKit.createLogger( category ); | |||||
return logger; | |||||
} | } | ||||
/** | /** | ||||
@@ -399,15 +420,17 @@ public class Main | |||||
{ | { | ||||
ProjectListener result = null; | ProjectListener result = null; | ||||
try { result = (ProjectListener)ObjectUtil.createObject( listenerName ); } | |||||
try { result = (ProjectListener)Class.forName( listenerName ).newInstance(); } | |||||
catch( final Throwable t ) | catch( final Throwable t ) | ||||
{ | { | ||||
throw new AntException( "Error creating the listener " + listenerName + | |||||
" due to " + StringUtil.printStackTrace( t, 5, true ), | |||||
throw new AntException( "Error creating the listener " + listenerName + | |||||
" due to " + ExceptionUtil.printStackTrace( t, 5, true ), | |||||
t ); | t ); | ||||
} | } | ||||
getLogger().addLogTarget( new LogTargetToListenerAdapter( result ) ); | |||||
final LogTarget target = new LogTargetToListenerAdapter( result ); | |||||
getLogger().setLogTargets( new LogTarget[] { target } ); | |||||
return result; | return result; | ||||
} | } | ||||
@@ -420,41 +443,41 @@ public class Main | |||||
protected ClassLoader createClassLoader( final File libDir ) | protected ClassLoader createClassLoader( final File libDir ) | ||||
{ | { | ||||
final ClassLoader candidate = getClass().getClassLoader(); | final ClassLoader candidate = getClass().getClassLoader(); | ||||
if( !(candidate instanceof AntClassLoader) ) | if( !(candidate instanceof AntClassLoader) ) | ||||
{ | { | ||||
getLogger().warn( "Warning: Unable to add entries from " + | |||||
getLogger().warn( "Warning: Unable to add entries from " + | |||||
"lib-path to classloader" ); | "lib-path to classloader" ); | ||||
return candidate; | return candidate; | ||||
} | } | ||||
final AntClassLoader classLoader = (AntClassLoader)candidate; | final AntClassLoader classLoader = (AntClassLoader)candidate; | ||||
final ExtensionFileFilter filter = | |||||
final ExtensionFileFilter filter = | |||||
new ExtensionFileFilter( new String[] { ".jar", ".zip" } ); | new ExtensionFileFilter( new String[] { ".jar", ".zip" } ); | ||||
final File[] files = libDir.listFiles( filter ); | final File[] files = libDir.listFiles( filter ); | ||||
for( int i = 0; i < files.length; i++ ) | for( int i = 0; i < files.length; i++ ) | ||||
{ | { | ||||
//except for a few *special* files add all the | |||||
//except for a few *special* files add all the | |||||
//.zip/.jars to classloader | //.zip/.jars to classloader | ||||
final String name = files[ i ].getName(); | final String name = files[ i ].getName(); | ||||
if( !name.equals( "ant.jar" ) && | if( !name.equals( "ant.jar" ) && | ||||
!name.equals( "myrmidon.jar" ) && | !name.equals( "myrmidon.jar" ) && | ||||
!name.equals( "avalonapi.jar" ) ) | !name.equals( "avalonapi.jar" ) ) | ||||
{ | |||||
{ | |||||
try { classLoader.addURL( files[ i ].toURL() ); } | try { classLoader.addURL( files[ i ].toURL() ); } | ||||
catch( final MalformedURLException mue ) {} | catch( final MalformedURLException mue ) {} | ||||
} | } | ||||
} | |||||
} | |||||
return classLoader; | return classLoader; | ||||
} | } | ||||
/** | /** | ||||
* Setup the projects context so all the "default" properties are defined. | * 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 | |||||
* This also takes a hashmap that is added to context. Usually these are the | |||||
* ones defined on command line. | * ones defined on command line. | ||||
* | * | ||||
* @param project the project | * @param project the project | ||||
@@ -1,39 +0,0 @@ | |||||
/* | |||||
* 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.ant.configuration; | |||||
import org.apache.avalon.ConfigurationException; | |||||
/** | |||||
* This interface should be implemented by classes that need to be | |||||
* configured with custom parameters before initialization. | |||||
* <br /> | |||||
* | |||||
* The contract surrounding a <code>Configurable</code> is that the | |||||
* instantiating entity must call the <code>configure</code> | |||||
* method before it is valid. The <code>configure</code> method | |||||
* must be called after the constructor, and before any other method. | |||||
* | |||||
* @author <a href="mailto:fede@apache.org">Federico Barbieri</a> | |||||
* @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a> | |||||
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a> | |||||
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a> | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
*/ | |||||
public interface Configurable | |||||
{ | |||||
/** | |||||
* Pass the <code>Configuration</code> to the <code>Configurable</code> | |||||
* class. This method must always be called after the constructor | |||||
* and before any other method. | |||||
* | |||||
* @param configuration the class configurations. | |||||
*/ | |||||
void configure( Configuration configuration ) | |||||
throws ConfigurationException; | |||||
} |
@@ -1,34 +0,0 @@ | |||||
/* | |||||
* 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.ant.configuration; | |||||
import java.util.Iterator; | |||||
/** | |||||
* Fork of Avalon code that will be folded back when they get equivelent facilties. | |||||
* Note that the code is different package so it should not cause any issues. | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
*/ | |||||
public interface Configuration | |||||
extends org.apache.avalon.Configuration | |||||
{ | |||||
/** | |||||
* Retrieve a list of all child names. | |||||
* | |||||
* @return the child names | |||||
*/ | |||||
Iterator getChildren(); | |||||
/** | |||||
* Retrieve a list of all attribute names. | |||||
* | |||||
* @return the attribute names | |||||
*/ | |||||
Iterator getAttributeNames(); | |||||
} |
@@ -1,25 +0,0 @@ | |||||
/* | |||||
* 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.ant.configuration; | |||||
import org.xml.sax.SAXException; | |||||
/** | |||||
* Fork of Avalon code that will be folded back when they get equivelent facilties. | |||||
* Note that the code is different package so it should not cause any issues. | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
*/ | |||||
public class ConfigurationBuilder | |||||
extends org.apache.avalon.DefaultConfigurationBuilder | |||||
{ | |||||
protected org.apache.avalon.SAXConfigurationHandler getHandler() | |||||
{ | |||||
return new SAXConfigurationHandler(); | |||||
} | |||||
} |
@@ -7,13 +7,14 @@ | |||||
*/ | */ | ||||
package org.apache.ant.configuration; | package org.apache.ant.configuration; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.ConfigurationException; | |||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.component.Component; | |||||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||||
import org.apache.avalon.framework.configuration.Configuration; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* Class used to configure tasks. | * Class used to configure tasks. | ||||
* | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | ||||
*/ | */ | ||||
public interface Configurer | public interface Configurer | ||||
@@ -21,7 +22,7 @@ public interface Configurer | |||||
{ | { | ||||
/** | /** | ||||
* Configure an object based on a configuration in a particular context. | * Configure an object based on a configuration in a particular context. | ||||
* This configuring can be done in different ways for different | |||||
* This configuring can be done in different ways for different | |||||
* configurers. | * configurers. | ||||
* | * | ||||
* @param object the object | * @param object the object | ||||
@@ -1,48 +0,0 @@ | |||||
/* | |||||
* 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.ant.configuration; | |||||
import java.util.Iterator; | |||||
/** | |||||
* Fork of Avalon code that will be folded back when they get equivelent facilties. | |||||
* Note that the code is different package so it should not cause any issues. | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
*/ | |||||
public class DefaultConfiguration | |||||
extends org.apache.avalon.DefaultConfiguration | |||||
implements Configuration | |||||
{ | |||||
public DefaultConfiguration( final String localname, final String location ) | |||||
{ | |||||
super( localname, location ); | |||||
} | |||||
/** | |||||
* Retrieve a list of all child names. | |||||
* | |||||
* @return the child names | |||||
*/ | |||||
public Iterator getChildren() | |||||
{ | |||||
if( null == m_children ) return EMPTY_ITERATOR; | |||||
else return m_children.iterator(); | |||||
} | |||||
/** | |||||
* Retrieve a list of all attribute names. | |||||
* | |||||
* @return the attribute names | |||||
*/ | |||||
public Iterator getAttributeNames() | |||||
{ | |||||
if( null == m_attributes ) return EMPTY_ITERATOR; | |||||
else return m_attributes.keySet().iterator(); | |||||
} | |||||
} |
@@ -13,32 +13,34 @@ import java.util.ArrayList; | |||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.ant.convert.Converter; | import org.apache.ant.convert.Converter; | ||||
import org.apache.ant.convert.ConverterException; | import org.apache.ant.convert.ConverterException; | ||||
import org.apache.avalon.AbstractLoggable; | |||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.ConfigurationException; | |||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.Loggable; | |||||
import org.apache.avalon.util.PropertyException; | |||||
import org.apache.avalon.util.PropertyUtil; | |||||
import org.apache.avalon.excalibur.property.PropertyException; | |||||
import org.apache.avalon.excalibur.property.PropertyUtil; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.configuration.Configuration; | |||||
import org.apache.avalon.framework.configuration.Configurable; | |||||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||||
import org.apache.avalon.framework.context.Context; | |||||
import org.apache.avalon.framework.logger.AbstractLoggable; | |||||
import org.apache.avalon.framework.logger.Loggable; | |||||
import org.apache.log.Logger; | import org.apache.log.Logger; | ||||
/** | /** | ||||
* Class used to configure tasks. | * Class used to configure tasks. | ||||
* | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | ||||
*/ | */ | ||||
public class DefaultConfigurer | public class DefaultConfigurer | ||||
extends AbstractLoggable | extends AbstractLoggable | ||||
implements Configurer, Composer, Loggable | |||||
implements Configurer, Composable, Loggable | |||||
{ | { | ||||
protected final static String RESERVED_ATTRIBUTES[] = | |||||
protected final static String RESERVED_ATTRIBUTES[] = | |||||
{ | { | ||||
"id" | "id" | ||||
}; | }; | ||||
protected final static String RESERVED_ELEMENTS[] = | |||||
protected final static String RESERVED_ELEMENTS[] = | |||||
{ | { | ||||
"content" | "content" | ||||
}; | }; | ||||
@@ -47,16 +49,16 @@ public class DefaultConfigurer | |||||
protected Converter m_converter; | protected Converter m_converter; | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
m_converter = (Converter)componentManager.lookup( "org.apache.ant.convert.Converter" ); | m_converter = (Converter)componentManager.lookup( "org.apache.ant.convert.Converter" ); | ||||
} | } | ||||
/** | /** | ||||
* Configure a task based on a configuration in a particular context. | * Configure a task based on a configuration in a particular context. | ||||
* This configuring can be done in different ways for different | |||||
* configurers. | |||||
* This one does it by first checking if object implements Configurable | |||||
* This configuring can be done in different ways for different | |||||
* configurers. | |||||
* This one does it by first checking if object implements Configurable | |||||
* and if it does will pass the task the configuration - else it will use | * and if it does will pass the task the configuration - else it will use | ||||
* ants rules to map configuration to types | * ants rules to map configuration to types | ||||
* | * | ||||
@@ -65,59 +67,59 @@ public class DefaultConfigurer | |||||
* @param context the Context | * @param context the Context | ||||
* @exception ConfigurationException if an error occurs | * @exception ConfigurationException if an error occurs | ||||
*/ | */ | ||||
public void configure( final Object object, | |||||
public void configure( final Object object, | |||||
final Configuration configuration, | final Configuration configuration, | ||||
final Context context ) | final Context context ) | ||||
throws ConfigurationException | throws ConfigurationException | ||||
{ | { | ||||
if( DEBUG ) | if( DEBUG ) | ||||
{ | { | ||||
m_logger.debug( "Configuring " + object ); | |||||
getLogger().debug( "Configuring " + object ); | |||||
} | } | ||||
if( object instanceof Configurable ) | if( object instanceof Configurable ) | ||||
{ | { | ||||
if( DEBUG ) | |||||
if( DEBUG ) | |||||
{ | { | ||||
m_logger.debug( "Configuring object via Configurable interface" ); | |||||
getLogger().debug( "Configuring object via Configurable interface" ); | |||||
} | } | ||||
((Configurable)object).configure( configuration ); | ((Configurable)object).configure( configuration ); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
if( DEBUG ) | |||||
if( DEBUG ) | |||||
{ | { | ||||
m_logger.debug( "Configuring object via Configurable reflection" ); | |||||
getLogger().debug( "Configuring object via Configurable reflection" ); | |||||
} | } | ||||
final Iterator attributes = configuration.getAttributeNames(); | |||||
while( attributes.hasNext() ) | |||||
final String[] attributes = configuration.getAttributeNames(); | |||||
for( int i = 0; i < attributes.length; i++ ) | |||||
{ | { | ||||
final String name = (String)attributes.next(); | |||||
final String name = attributes[ i ]; | |||||
final String value = configuration.getAttribute( name ); | final String value = configuration.getAttribute( name ); | ||||
if( DEBUG ) | |||||
if( DEBUG ) | |||||
{ | { | ||||
m_logger.debug( "Configuring attribute name=" + name + | |||||
getLogger().debug( "Configuring attribute name=" + name + | |||||
" value=" + value ); | " value=" + value ); | ||||
} | } | ||||
configureAttribute( object, name, value, context ); | configureAttribute( object, name, value, context ); | ||||
} | } | ||||
final Iterator elements = configuration.getChildren(); | |||||
while( elements.hasNext() ) | |||||
final Configuration[] children = configuration.getChildren(); | |||||
for( int i = 0; i < children.length; i++ ) | |||||
{ | { | ||||
final Configuration element = (Configuration)elements.next(); | |||||
if( DEBUG ) | |||||
final Configuration child = children[ i ]; | |||||
if( DEBUG ) | |||||
{ | { | ||||
m_logger.debug( "Configuring subelement name=" + element.getName() ); | |||||
getLogger().debug( "Configuring subelement name=" + child.getName() ); | |||||
} | } | ||||
configureElement( object, element, context ); | |||||
configureElement( object, child, context ); | |||||
} | } | ||||
final String content = configuration.getValue( null ); | final String content = configuration.getValue( null ); | ||||
@@ -126,11 +128,11 @@ public class DefaultConfigurer | |||||
{ | { | ||||
if( !content.trim().equals( "" ) ) | if( !content.trim().equals( "" ) ) | ||||
{ | { | ||||
if( DEBUG ) | |||||
if( DEBUG ) | |||||
{ | { | ||||
m_logger.debug( "Configuring content " + content ); | |||||
getLogger().debug( "Configuring content " + content ); | |||||
} | } | ||||
configureContent( object, content, context ); | configureContent( object, content, context ); | ||||
} | } | ||||
} | } | ||||
@@ -145,7 +147,7 @@ public class DefaultConfigurer | |||||
* @param context the Context | * @param context the Context | ||||
* @exception ConfigurationException if an error occurs | * @exception ConfigurationException if an error occurs | ||||
*/ | */ | ||||
protected void configureContent( final Object object, | |||||
protected void configureContent( final Object object, | |||||
final String content, | final String content, | ||||
final Context context ) | final Context context ) | ||||
throws ConfigurationException | throws ConfigurationException | ||||
@@ -153,8 +155,8 @@ public class DefaultConfigurer | |||||
setValue( object, "addContent", content, context ); | setValue( object, "addContent", content, context ); | ||||
} | } | ||||
protected void configureAttribute( final Object object, | |||||
final String name, | |||||
protected void configureAttribute( final Object object, | |||||
final String name, | |||||
final String value, | final String value, | ||||
final Context context ) | final Context context ) | ||||
throws ConfigurationException | throws ConfigurationException | ||||
@@ -168,7 +170,7 @@ public class DefaultConfigurer | |||||
setValue( object, methodName, value, context ); | setValue( object, methodName, value, context ); | ||||
} | } | ||||
protected void setValue( final Object object, | |||||
protected void setValue( final Object object, | |||||
final String methodName, | final String methodName, | ||||
final String value, | final String value, | ||||
final Context context ) | final Context context ) | ||||
@@ -182,8 +184,8 @@ public class DefaultConfigurer | |||||
if( 0 == methods.length ) | if( 0 == methods.length ) | ||||
{ | { | ||||
throw new ConfigurationException( "Unable to set attribute via " + methodName + | |||||
" due to not finding any appropriate " + | |||||
throw new ConfigurationException( "Unable to set attribute via " + methodName + | |||||
" due to not finding any appropriate " + | |||||
"accessor method" ); | "accessor method" ); | ||||
} | } | ||||
@@ -198,7 +200,7 @@ public class DefaultConfigurer | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
final Object objectValue = | |||||
final Object objectValue = | |||||
PropertyUtil.resolveProperty( value, context, false ); | PropertyUtil.resolveProperty( value, context, false ); | ||||
setValue( object, objectValue, methods, context ); | setValue( object, objectValue, methods, context ); | ||||
@@ -210,8 +212,8 @@ public class DefaultConfigurer | |||||
} | } | ||||
} | } | ||||
protected void setValue( final Object object, | |||||
Object value, | |||||
protected void setValue( final Object object, | |||||
Object value, | |||||
final Method methods[], | final Method methods[], | ||||
final Context context ) | final Context context ) | ||||
throws ConfigurationException | throws ConfigurationException | ||||
@@ -226,14 +228,14 @@ public class DefaultConfigurer | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
throw new ConfigurationException( "Unable to set attribute via " + | |||||
methods[ 0 ].getName() + " as could not convert " + | |||||
throw new ConfigurationException( "Unable to set attribute via " + | |||||
methods[ 0 ].getName() + " as could not convert " + | |||||
source + " to a matching type" ); | source + " to a matching type" ); | ||||
} | } | ||||
protected boolean setValue( final Object object, | |||||
Object value, | |||||
protected boolean setValue( final Object object, | |||||
Object value, | |||||
final Method method, | final Method method, | ||||
final Class sourceClass, | final Class sourceClass, | ||||
final String source, | final String source, | ||||
@@ -245,7 +247,7 @@ public class DefaultConfigurer | |||||
{ | { | ||||
parameterType = getComplexTypeFor( parameterType ); | parameterType = getComplexTypeFor( parameterType ); | ||||
} | } | ||||
try | try | ||||
{ | { | ||||
value = m_converter.convert( parameterType, value, context ); | value = m_converter.convert( parameterType, value, context ); | ||||
@@ -254,18 +256,18 @@ public class DefaultConfigurer | |||||
{ | { | ||||
if( DEBUG ) | if( DEBUG ) | ||||
{ | { | ||||
m_logger.debug( "Failed to find converter ", ce ); | |||||
getLogger().debug( "Failed to find converter ", ce ); | |||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
catch( final Exception e ) | catch( final Exception e ) | ||||
{ | { | ||||
throw new ConfigurationException( "Error converting attribute for " + | |||||
throw new ConfigurationException( "Error converting attribute for " + | |||||
method.getName(), | method.getName(), | ||||
e ); | e ); | ||||
} | } | ||||
try | try | ||||
{ | { | ||||
method.invoke( object, new Object[] { value } ); | method.invoke( object, new Object[] { value } ); | ||||
@@ -273,13 +275,13 @@ public class DefaultConfigurer | |||||
catch( final IllegalAccessException iae ) | catch( final IllegalAccessException iae ) | ||||
{ | { | ||||
//should never happen .... | //should never happen .... | ||||
throw new ConfigurationException( "Error retrieving methods with " + | |||||
throw new ConfigurationException( "Error retrieving methods with " + | |||||
"correct access specifiers", | "correct access specifiers", | ||||
iae ); | iae ); | ||||
} | } | ||||
catch( final InvocationTargetException ite ) | catch( final InvocationTargetException ite ) | ||||
{ | { | ||||
throw new ConfigurationException( "Error calling method attribute " + | |||||
throw new ConfigurationException( "Error calling method attribute " + | |||||
method.getName(), | method.getName(), | ||||
ite ); | ite ); | ||||
} | } | ||||
@@ -308,11 +310,11 @@ public class DefaultConfigurer | |||||
{ | { | ||||
final Method methods[] = clazz.getMethods(); | final Method methods[] = clazz.getMethods(); | ||||
final ArrayList matches = new ArrayList(); | final ArrayList matches = new ArrayList(); | ||||
for( int i = 0; i < methods.length; i++ ) | for( int i = 0; i < methods.length; i++ ) | ||||
{ | { | ||||
final Method method = methods[ i ]; | final Method method = methods[ i ]; | ||||
if( methodName.equals( method.getName() ) && | |||||
if( methodName.equals( method.getName() ) && | |||||
Method.PUBLIC == (method.getModifiers() & Method.PUBLIC) ) | Method.PUBLIC == (method.getModifiers() & Method.PUBLIC) ) | ||||
{ | { | ||||
if( method.getReturnType().equals( Void.TYPE ) ) | if( method.getReturnType().equals( Void.TYPE ) ) | ||||
@@ -333,11 +335,11 @@ public class DefaultConfigurer | |||||
{ | { | ||||
final Method methods[] = clazz.getMethods(); | final Method methods[] = clazz.getMethods(); | ||||
final ArrayList matches = new ArrayList(); | final ArrayList matches = new ArrayList(); | ||||
for( int i = 0; i < methods.length; i++ ) | for( int i = 0; i < methods.length; i++ ) | ||||
{ | { | ||||
final Method method = methods[ i ]; | final Method method = methods[ i ]; | ||||
if( methodName.equals( method.getName() ) && | |||||
if( methodName.equals( method.getName() ) && | |||||
Method.PUBLIC == (method.getModifiers() & Method.PUBLIC) ) | Method.PUBLIC == (method.getModifiers() & Method.PUBLIC) ) | ||||
{ | { | ||||
final Class returnType = method.getReturnType(); | final Class returnType = method.getReturnType(); | ||||
@@ -352,7 +354,7 @@ public class DefaultConfigurer | |||||
} | } | ||||
} | } | ||||
} | } | ||||
return (Method[])matches.toArray( new Method[0] ); | return (Method[])matches.toArray( new Method[0] ); | ||||
} | } | ||||
@@ -364,10 +366,10 @@ public class DefaultConfigurer | |||||
protected String getJavaNameFor( final String name ) | protected String getJavaNameFor( final String name ) | ||||
{ | { | ||||
final StringBuffer sb = new StringBuffer(); | final StringBuffer sb = new StringBuffer(); | ||||
int index = name.indexOf( '-' ); | int index = name.indexOf( '-' ); | ||||
int last = 0; | int last = 0; | ||||
while( -1 != index ) | while( -1 != index ) | ||||
{ | { | ||||
final String word = name.substring( last, index ).toLowerCase(); | final String word = name.substring( last, index ).toLowerCase(); | ||||
@@ -376,16 +378,16 @@ public class DefaultConfigurer | |||||
last = index + 1; | last = index + 1; | ||||
index = name.indexOf( '-', last ); | index = name.indexOf( '-', last ); | ||||
} | } | ||||
index = name.length(); | index = name.length(); | ||||
final String word = name.substring( last, index ).toLowerCase(); | final String word = name.substring( last, index ).toLowerCase(); | ||||
sb.append( Character.toUpperCase( word.charAt( 0 ) ) ); | sb.append( Character.toUpperCase( word.charAt( 0 ) ) ); | ||||
sb.append( word.substring( 1, word.length() ) ); | sb.append( word.substring( 1, word.length() ) ); | ||||
return sb.toString(); | return sb.toString(); | ||||
} | |||||
} | |||||
protected void configureElement( final Object object, | |||||
protected void configureElement( final Object object, | |||||
final Configuration configuration, | final Configuration configuration, | ||||
final Context context ) | final Context context ) | ||||
throws ConfigurationException | throws ConfigurationException | ||||
@@ -403,7 +405,7 @@ public class DefaultConfigurer | |||||
// slow. Need to cache results per class etc. | // slow. Need to cache results per class etc. | ||||
final Class clazz = object.getClass(); | final Class clazz = object.getClass(); | ||||
Method methods[] = getMethodsFor( clazz, "add" + javaName ); | Method methods[] = getMethodsFor( clazz, "add" + javaName ); | ||||
if( 0 != methods.length ) | if( 0 != methods.length ) | ||||
{ | { | ||||
//guess it is first method ???? | //guess it is first method ???? | ||||
@@ -415,8 +417,8 @@ public class DefaultConfigurer | |||||
if( 0 == methods.length ) | if( 0 == methods.length ) | ||||
{ | { | ||||
throw new ConfigurationException( "Unable to set attribute " + javaName + | |||||
" due to not finding any appropriate " + | |||||
throw new ConfigurationException( "Unable to set attribute " + javaName + | |||||
" due to not finding any appropriate " + | |||||
"accessor method" ); | "accessor method" ); | ||||
} | } | ||||
@@ -425,7 +427,7 @@ public class DefaultConfigurer | |||||
} | } | ||||
} | } | ||||
protected void createElement( final Object object, | |||||
protected void createElement( final Object object, | |||||
final Method method, | final Method method, | ||||
final Configuration configuration, | final Configuration configuration, | ||||
final Context context ) | final Context context ) | ||||
@@ -446,7 +448,7 @@ public class DefaultConfigurer | |||||
} | } | ||||
} | } | ||||
protected void addElement( final Object object, | |||||
protected void addElement( final Object object, | |||||
final Method method, | final Method method, | ||||
final Configuration configuration, | final Configuration configuration, | ||||
final Context context ) | final Context context ) | ||||
@@ -1,24 +0,0 @@ | |||||
/* | |||||
* 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.ant.configuration; | |||||
/** | |||||
* Fork of Avalon code that will be folded back when they get equivelent facilties. | |||||
* Note that the code is different package so it should not cause any issues. | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
*/ | |||||
public class SAXConfigurationHandler | |||||
extends org.apache.avalon.SAXConfigurationHandler | |||||
{ | |||||
protected org.apache.avalon.DefaultConfiguration | |||||
createConfiguration( final String localName, final String location ) | |||||
{ | |||||
return new DefaultConfiguration( localName, location ); | |||||
} | |||||
} |
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.ant.convert; | package org.apache.ant.convert; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* Instances of this interface are used to convert between different types. | * Instances of this interface are used to convert between different types. | ||||
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.ant.convert; | package org.apache.ant.convert; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* Instances of this interface are used to convert between different types. | * Instances of this interface are used to convert between different types. | ||||
@@ -8,8 +8,8 @@ | |||||
package org.apache.ant.convert.engine; | package org.apache.ant.convert.engine; | ||||
import org.apache.ant.convert.Converter; | import org.apache.ant.convert.Converter; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.camelot.LocatorRegistry; | |||||
import org.apache.avalon.framework.component.Component; | |||||
import org.apache.avalon.framework.camelot.Registry; | |||||
/** | /** | ||||
* Converter engine to handle converting between types. | * Converter engine to handle converting between types. | ||||
@@ -24,7 +24,7 @@ public interface ConverterEngine | |||||
* | * | ||||
* @return the LocatorRegistry | * @return the LocatorRegistry | ||||
*/ | */ | ||||
LocatorRegistry getRegistry(); | |||||
Registry getRegistry(); | |||||
/** | /** | ||||
* Get registry for converterInfo objects. | * Get registry for converterInfo objects. | ||||
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.ant.convert.engine; | package org.apache.ant.convert.engine; | ||||
import org.apache.avalon.camelot.Info; | |||||
import org.apache.avalon.framework.camelot.Info; | |||||
/** | /** | ||||
* This info represents meta-information about a converter. | * This info represents meta-information about a converter. | ||||
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.ant.convert.engine; | package org.apache.ant.convert.engine; | ||||
import org.apache.avalon.camelot.Registry; | |||||
import org.apache.avalon.framework.camelot.Registry; | |||||
/** | /** | ||||
* Interface for registry for ConverterInfos. | * Interface for registry for ConverterInfos. | ||||
@@ -10,16 +10,16 @@ package org.apache.ant.convert.engine; | |||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.convert.Converter; | import org.apache.ant.convert.Converter; | ||||
import org.apache.ant.convert.ConverterException; | import org.apache.ant.convert.ConverterException; | ||||
import org.apache.avalon.AbstractLoggable; | |||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.camelot.DefaultFactory; | |||||
import org.apache.avalon.camelot.DefaultLocatorRegistry; | |||||
import org.apache.avalon.camelot.Factory; | |||||
import org.apache.avalon.camelot.Locator; | |||||
import org.apache.avalon.camelot.LocatorRegistry; | |||||
import org.apache.avalon.framework.logger.AbstractLoggable; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.context.Context; | |||||
import org.apache.avalon.framework.camelot.DefaultFactory; | |||||
import org.apache.avalon.framework.camelot.DefaultRegistry; | |||||
import org.apache.avalon.framework.camelot.Factory; | |||||
import org.apache.avalon.framework.camelot.Locator; | |||||
import org.apache.avalon.framework.camelot.Registry; | |||||
/** | /** | ||||
* Converter engine to handle converting between types. | * Converter engine to handle converting between types. | ||||
@@ -28,12 +28,12 @@ import org.apache.avalon.camelot.LocatorRegistry; | |||||
*/ | */ | ||||
public class DefaultConverterEngine | public class DefaultConverterEngine | ||||
extends AbstractLoggable | extends AbstractLoggable | ||||
implements ConverterEngine, Composer | |||||
implements ConverterEngine, Composable | |||||
{ | { | ||||
protected final static boolean DEBUG = false; | protected final static boolean DEBUG = false; | ||||
protected Factory m_factory; | protected Factory m_factory; | ||||
protected LocatorRegistry m_registry = new DefaultLocatorRegistry(); | |||||
protected Registry m_registry = new DefaultRegistry( Locator.class ); | |||||
protected ConverterRegistry m_infoRegistry = new DefaultConverterRegistry(); | protected ConverterRegistry m_infoRegistry = new DefaultConverterRegistry(); | ||||
/** | /** | ||||
@@ -41,7 +41,7 @@ public class DefaultConverterEngine | |||||
* | * | ||||
* @return the LocatorRegistry | * @return the LocatorRegistry | ||||
*/ | */ | ||||
public LocatorRegistry getRegistry() | |||||
public Registry getRegistry() | |||||
{ | { | ||||
return m_registry; | return m_registry; | ||||
} | } | ||||
@@ -60,12 +60,12 @@ public class DefaultConverterEngine | |||||
* Retrieve relevent services needed to deploy. | * Retrieve relevent services needed to deploy. | ||||
* | * | ||||
* @param componentManager the ComponentManager | * @param componentManager the ComponentManager | ||||
* @exception ComponentManagerException if an error occurs | |||||
* @exception ComponentException if an error occurs | |||||
*/ | */ | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
m_factory = (Factory)componentManager.lookup( "org.apache.avalon.camelot.Factory" ); | |||||
m_factory = (Factory)componentManager.lookup( "org.apache.avalon.framework.camelot.Factory" ); | |||||
} | } | ||||
/** | /** | ||||
@@ -89,8 +89,8 @@ public class DefaultConverterEngine | |||||
if( DEBUG ) | if( DEBUG ) | ||||
{ | { | ||||
m_logger.debug( "Looking for converter from " + originalClass.getName() + | |||||
" to " + destination.getName() ); | |||||
getLogger().debug( "Looking for converter from " + originalClass.getName() + | |||||
" to " + destination.getName() ); | |||||
} | } | ||||
//TODO: Start searching inheritance hierarchy for converter | //TODO: Start searching inheritance hierarchy for converter | ||||
@@ -106,7 +106,7 @@ public class DefaultConverterEngine | |||||
} | } | ||||
//TODO: Start caching converters instead of repeatedly instantiating em. | //TODO: Start caching converters instead of repeatedly instantiating em. | ||||
final Locator locator = m_registry.getLocator( name ); | |||||
final Locator locator = (Locator)m_registry.getInfo( name, Locator.class ); | |||||
final Converter converter = (Converter)m_factory.create( locator, Converter.class ); | final Converter converter = (Converter)m_factory.create( locator, Converter.class ); | ||||
return converter.convert( destination, original, context ); | return converter.convert( destination, original, context ); | ||||
} | } | ||||
@@ -8,9 +8,9 @@ | |||||
package org.apache.ant.convert.engine; | package org.apache.ant.convert.engine; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import org.apache.avalon.camelot.DefaultRegistry; | |||||
import org.apache.avalon.camelot.Info; | |||||
import org.apache.avalon.camelot.RegistryException; | |||||
import org.apache.avalon.framework.camelot.DefaultRegistry; | |||||
import org.apache.avalon.framework.camelot.Info; | |||||
import org.apache.avalon.framework.camelot.RegistryException; | |||||
/** | /** | ||||
* Default implementation of ConverterInfo registry. | * Default implementation of ConverterInfo registry. | ||||
@@ -8,10 +8,11 @@ | |||||
package org.apache.ant.launcher; | package org.apache.ant.launcher; | ||||
import java.io.File; | import java.io.File; | ||||
import java.lang.reflect.Method; | |||||
import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
import java.lang.reflect.Method; | |||||
import java.net.URL; | import java.net.URL; | ||||
import java.net.URLClassLoader; | import java.net.URLClassLoader; | ||||
import java.util.ArrayList; | |||||
import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
/** | /** | ||||
@@ -26,12 +27,12 @@ public final class AntLoader | |||||
/** | /** | ||||
* Magic entry point. | * Magic entry point. | ||||
* | * | ||||
* @param argsthe CLI arguments | |||||
* @param args the CLI arguments | |||||
* @exception Exception if an error occurs | * @exception Exception if an error occurs | ||||
*/ | */ | ||||
public final static void main( final String[] args ) | |||||
public final static void main( final String[] args ) | |||||
throws Exception | throws Exception | ||||
{ | |||||
{ | |||||
try | try | ||||
{ | { | ||||
//actually try to discover the install directory based on where | //actually try to discover the install directory based on where | ||||
@@ -40,40 +41,67 @@ public final class AntLoader | |||||
System.setProperty( "ant.home", installDirectory.toString() ); | System.setProperty( "ant.home", installDirectory.toString() ); | ||||
//setup classloader appropriately for myrmidon jar | //setup classloader appropriately for myrmidon jar | ||||
final File archive = | |||||
new File( installDirectory, "lib" + File.separator + "myrmidon.jar" ); | |||||
final AntClassLoader classLoader = | |||||
new AntClassLoader( new URL[] { archive.toURL() } ); | |||||
final File libDir = new File( installDirectory, "lib" ); | |||||
final URL[] urls = buildURLList( libDir ); | |||||
final AntClassLoader classLoader = new AntClassLoader( urls ); | |||||
//load class and retrieve appropriate main method. | //load class and retrieve appropriate main method. | ||||
final Class clazz = classLoader.loadClass( "org.apache.ant.Main" ); | final Class clazz = classLoader.loadClass( "org.apache.ant.Main" ); | ||||
final Method method = clazz.getMethod( "main", new Class[] { args.getClass() } ); | final Method method = clazz.getMethod( "main", new Class[] { args.getClass() } ); | ||||
//kick the tires and light the fires.... | //kick the tires and light the fires.... | ||||
method.invoke( null, new Object[] { args } ); | method.invoke( null, new Object[] { args } ); | ||||
} | } | ||||
catch( final InvocationTargetException ite ) | |||||
catch( final InvocationTargetException ite ) | |||||
{ | { | ||||
System.err.println( "Error: " + ite.getTargetException().getMessage() ); | System.err.println( "Error: " + ite.getTargetException().getMessage() ); | ||||
ite.getTargetException().printStackTrace(); | ite.getTargetException().printStackTrace(); | ||||
} | } | ||||
catch( final Throwable throwable ) | |||||
catch( final Throwable throwable ) | |||||
{ | { | ||||
System.err.println( "Error: " + throwable.getMessage() ); | System.err.println( "Error: " + throwable.getMessage() ); | ||||
throwable.printStackTrace(); | 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. | * Finds the ant.jar file in the classpath. | ||||
*/ | */ | ||||
protected final static File findInstallDir() | |||||
private final static File findInstallDir() | |||||
throws Exception | throws Exception | ||||
{ | { | ||||
final String classpath = System.getProperty( "java.class.path" ); | final String classpath = System.getProperty( "java.class.path" ); | ||||
final String pathSeparator = System.getProperty( "path.separator" ); | final String pathSeparator = System.getProperty( "path.separator" ); | ||||
final StringTokenizer tokenizer = new StringTokenizer( classpath, pathSeparator ); | final StringTokenizer tokenizer = new StringTokenizer( classpath, pathSeparator ); | ||||
while( tokenizer.hasMoreTokens() ) | while( tokenizer.hasMoreTokens() ) | ||||
{ | { | ||||
final String element = tokenizer.nextToken(); | final String element = tokenizer.nextToken(); | ||||
@@ -82,16 +110,16 @@ public final class AntLoader | |||||
{ | { | ||||
File file = (new File( element )).getAbsoluteFile(); | File file = (new File( element )).getAbsoluteFile(); | ||||
file = file.getParentFile(); | file = file.getParentFile(); | ||||
if( null != file ) | if( null != file ) | ||||
{ | { | ||||
file = file.getParentFile(); | file = file.getParentFile(); | ||||
} | } | ||||
return file; | |||||
return file; | |||||
} | } | ||||
} | } | ||||
throw new Exception( "Unable to locate ant.jar in classpath" ); | throw new Exception( "Unable to locate ant.jar in classpath" ); | ||||
} | } | ||||
} | } |
@@ -14,10 +14,10 @@ import org.apache.ant.project.ProjectEngine; | |||||
import org.apache.ant.tasklet.AbstractTasklet; | import org.apache.ant.tasklet.AbstractTasklet; | ||||
import org.apache.ant.tasklet.DefaultTaskletContext; | import org.apache.ant.tasklet.DefaultTaskletContext; | ||||
import org.apache.ant.tasklet.TaskletContext; | import org.apache.ant.tasklet.TaskletContext; | ||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* This is abstract base class for tasklets. | * This is abstract base class for tasklets. | ||||
@@ -26,7 +26,7 @@ import org.apache.avalon.Context; | |||||
*/ | */ | ||||
public class AntCall | public class AntCall | ||||
extends AbstractTasklet | extends AbstractTasklet | ||||
implements Composer | |||||
implements Composable | |||||
{ | { | ||||
protected ProjectEngine m_projectEngine; | protected ProjectEngine m_projectEngine; | ||||
protected Project m_project; | protected Project m_project; | ||||
@@ -42,7 +42,7 @@ public class AntCall | |||||
} | } | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
m_componentManager = componentManager; | m_componentManager = componentManager; | ||||
m_projectEngine = (ProjectEngine)componentManager. | m_projectEngine = (ProjectEngine)componentManager. | ||||
@@ -66,7 +66,7 @@ public class AntCall | |||||
return property; | return property; | ||||
} | } | ||||
public void run() | |||||
public void execute() | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
if( null == m_target ) | if( null == m_target ) | ||||
@@ -78,7 +78,7 @@ public class AntCall | |||||
for( int i = 0; i < size; i++ ) | for( int i = 0; i < size; i++ ) | ||||
{ | { | ||||
final Property property = (Property)m_properties.get( i ); | final Property property = (Property)m_properties.get( i ); | ||||
property.run(); | |||||
property.execute(); | |||||
} | } | ||||
getLogger().info( "Calling target " + m_target ); | getLogger().info( "Calling target " + m_target ); | ||||
@@ -25,7 +25,7 @@ public class Echo | |||||
m_message = message; | m_message = message; | ||||
} | } | ||||
public void run() | |||||
public void execute() | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
getLogger().warn( m_message ); | getLogger().warn( m_message ); | ||||
@@ -9,8 +9,6 @@ package org.apache.ant.modules.basic; | |||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.configuration.Configurable; | |||||
import org.apache.ant.configuration.Configuration; | |||||
import org.apache.ant.configuration.Configurer; | import org.apache.ant.configuration.Configurer; | ||||
import org.apache.ant.convert.Converter; | import org.apache.ant.convert.Converter; | ||||
import org.apache.ant.tasklet.DataType; | import org.apache.ant.tasklet.DataType; | ||||
@@ -18,11 +16,13 @@ import org.apache.ant.tasklet.engine.DataTypeEngine; | |||||
import org.apache.ant.tasklet.AbstractTasklet; | import org.apache.ant.tasklet.AbstractTasklet; | ||||
import org.apache.ant.tasklet.TaskletContext; | import org.apache.ant.tasklet.TaskletContext; | ||||
import org.apache.ant.tasklet.engine.TaskletEngine; | import org.apache.ant.tasklet.engine.TaskletEngine; | ||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.ConfigurationException; | |||||
import org.apache.avalon.Resolvable; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||||
import org.apache.avalon.framework.configuration.Configuration; | |||||
import org.apache.avalon.framework.configuration.Configurable; | |||||
import org.apache.avalon.framework.context.Resolvable; | |||||
/** | /** | ||||
* This is the property "task" to declare a binding of a datatype to a name. | * This is the property "task" to declare a binding of a datatype to a name. | ||||
@@ -31,7 +31,7 @@ import org.apache.avalon.Resolvable; | |||||
*/ | */ | ||||
public class Property | public class Property | ||||
extends AbstractTasklet | extends AbstractTasklet | ||||
implements Configurable, Composer | |||||
implements Configurable, Composable | |||||
{ | { | ||||
protected String m_name; | protected String m_name; | ||||
protected Object m_value; | protected Object m_value; | ||||
@@ -41,7 +41,7 @@ public class Property | |||||
protected Configurer m_configurer; | protected Configurer m_configurer; | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
m_configurer = (Configurer)componentManager. | m_configurer = (Configurer)componentManager. | ||||
lookup( "org.apache.ant.configuration.Configurer" ); | lookup( "org.apache.ant.configuration.Configurer" ); | ||||
@@ -55,11 +55,11 @@ public class Property | |||||
public void configure( final Configuration configuration ) | public void configure( final Configuration configuration ) | ||||
throws ConfigurationException | throws ConfigurationException | ||||
{ | { | ||||
final Iterator attributes = configuration.getAttributeNames(); | |||||
final String[] attributes = configuration.getAttributeNames(); | |||||
while( attributes.hasNext() ) | |||||
for( int i = 0; i < attributes.length; i++ ) | |||||
{ | { | ||||
final String name = (String)attributes.next(); | |||||
final String name = attributes[ i ]; | |||||
final String value = configuration.getAttribute( name ); | final String value = configuration.getAttribute( name ); | ||||
final Object object = getContext().resolveValue( value ); | final Object object = getContext().resolveValue( value ); | ||||
@@ -105,10 +105,11 @@ public class Property | |||||
} | } | ||||
} | } | ||||
final Iterator children = configuration.getChildren(); | |||||
while( children.hasNext() ) | |||||
final Configuration[] children = configuration.getChildren(); | |||||
for( int i = 0; i < children.length; i++ ) | |||||
{ | { | ||||
final Configuration child = (Configuration)children.next(); | |||||
final Configuration child = children[ i ]; | |||||
try | try | ||||
{ | { | ||||
@@ -144,7 +145,7 @@ public class Property | |||||
m_localScope = localScope; | m_localScope = localScope; | ||||
} | } | ||||
public void run() | |||||
public void execute() | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
if( null == m_name ) | if( null == m_name ) | ||||
@@ -8,7 +8,7 @@ | |||||
package org.apache.ant.modules.basic; | package org.apache.ant.modules.basic; | ||||
import org.apache.ant.convert.AbstractConverter; | import org.apache.ant.convert.AbstractConverter; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* String to byte converter | * String to byte converter | ||||
@@ -8,7 +8,7 @@ | |||||
package org.apache.ant.modules.basic; | package org.apache.ant.modules.basic; | ||||
import org.apache.ant.convert.AbstractConverter; | import org.apache.ant.convert.AbstractConverter; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* String to class converter | * String to class converter | ||||
@@ -8,7 +8,7 @@ | |||||
package org.apache.ant.modules.basic; | package org.apache.ant.modules.basic; | ||||
import org.apache.ant.convert.AbstractConverter; | import org.apache.ant.convert.AbstractConverter; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* String to double converter | * String to double converter | ||||
@@ -10,7 +10,7 @@ package org.apache.ant.modules.basic; | |||||
import java.io.File; | import java.io.File; | ||||
import org.apache.ant.convert.AbstractConverter; | import org.apache.ant.convert.AbstractConverter; | ||||
import org.apache.ant.tasklet.TaskletContext; | import org.apache.ant.tasklet.TaskletContext; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* String to file converter | * String to file converter | ||||
@@ -8,7 +8,7 @@ | |||||
package org.apache.ant.modules.basic; | package org.apache.ant.modules.basic; | ||||
import org.apache.ant.convert.AbstractConverter; | import org.apache.ant.convert.AbstractConverter; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* String to float converter | * String to float converter | ||||
@@ -8,7 +8,7 @@ | |||||
package org.apache.ant.modules.basic; | package org.apache.ant.modules.basic; | ||||
import org.apache.ant.convert.AbstractConverter; | import org.apache.ant.convert.AbstractConverter; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* String to integer converter. | * String to integer converter. | ||||
@@ -8,7 +8,7 @@ | |||||
package org.apache.ant.modules.basic; | package org.apache.ant.modules.basic; | ||||
import org.apache.ant.convert.AbstractConverter; | import org.apache.ant.convert.AbstractConverter; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* String to long converter | * String to long converter | ||||
@@ -8,7 +8,7 @@ | |||||
package org.apache.ant.modules.basic; | package org.apache.ant.modules.basic; | ||||
import org.apache.ant.convert.AbstractConverter; | import org.apache.ant.convert.AbstractConverter; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* String to short converter | * String to short converter | ||||
@@ -9,7 +9,7 @@ package org.apache.ant.modules.basic; | |||||
import java.net.URL; | import java.net.URL; | ||||
import org.apache.ant.convert.AbstractConverter; | import org.apache.ant.convert.AbstractConverter; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.framework.context.Context; | |||||
/** | /** | ||||
* String to url converter | * String to url converter | ||||
@@ -13,10 +13,10 @@ import java.net.URL; | |||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.tasklet.AbstractTasklet; | import org.apache.ant.tasklet.AbstractTasklet; | ||||
import org.apache.ant.tasklet.engine.TaskletEngine; | import org.apache.ant.tasklet.engine.TaskletEngine; | ||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.camelot.RegistryException; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.camelot.RegistryException; | |||||
/** | /** | ||||
* Method to register a single tasklet. | * Method to register a single tasklet. | ||||
@@ -25,7 +25,7 @@ import org.apache.avalon.camelot.RegistryException; | |||||
*/ | */ | ||||
public abstract class AbstractResourceRegisterer | public abstract class AbstractResourceRegisterer | ||||
extends AbstractTasklet | extends AbstractTasklet | ||||
implements Composer | |||||
implements Composable | |||||
{ | { | ||||
protected String m_lib; | protected String m_lib; | ||||
protected String m_name; | protected String m_name; | ||||
@@ -33,7 +33,7 @@ public abstract class AbstractResourceRegisterer | |||||
protected TaskletEngine m_engine; | protected TaskletEngine m_engine; | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
m_engine = (TaskletEngine)componentManager. | m_engine = (TaskletEngine)componentManager. | ||||
lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); | lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); | ||||
@@ -54,7 +54,7 @@ public abstract class AbstractResourceRegisterer | |||||
m_classname = classname; | m_classname = classname; | ||||
} | } | ||||
public void run() | |||||
public void execute() | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
if( null == m_name ) | if( null == m_name ) | ||||
@@ -15,12 +15,12 @@ import org.apache.ant.convert.engine.ConverterEngine; | |||||
import org.apache.ant.convert.engine.DefaultConverterInfo; | import org.apache.ant.convert.engine.DefaultConverterInfo; | ||||
import org.apache.ant.tasklet.AbstractTasklet; | import org.apache.ant.tasklet.AbstractTasklet; | ||||
import org.apache.ant.tasklet.engine.TaskletEngine; | import org.apache.ant.tasklet.engine.TaskletEngine; | ||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.camelot.DefaultLocator; | |||||
import org.apache.avalon.camelot.DeploymentException; | |||||
import org.apache.avalon.camelot.RegistryException; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.camelot.DefaultLocator; | |||||
import org.apache.avalon.framework.camelot.DeploymentException; | |||||
import org.apache.avalon.framework.camelot.RegistryException; | |||||
/** | /** | ||||
* Method to register a single converter. | * Method to register a single converter. | ||||
@@ -29,7 +29,7 @@ import org.apache.avalon.camelot.RegistryException; | |||||
*/ | */ | ||||
public class RegisterConverter | public class RegisterConverter | ||||
extends AbstractTasklet | extends AbstractTasklet | ||||
implements Composer | |||||
implements Composable | |||||
{ | { | ||||
protected String m_sourceType; | protected String m_sourceType; | ||||
protected String m_destinationType; | protected String m_destinationType; | ||||
@@ -38,7 +38,7 @@ public class RegisterConverter | |||||
protected TaskletEngine m_engine; | protected TaskletEngine m_engine; | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
m_engine = (TaskletEngine)componentManager. | m_engine = (TaskletEngine)componentManager. | ||||
lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); | lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); | ||||
@@ -64,7 +64,7 @@ public class RegisterConverter | |||||
m_destinationType = destinationType; | m_destinationType = destinationType; | ||||
} | } | ||||
public void run() | |||||
public void execute() | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
if( null == m_classname ) | if( null == m_classname ) | ||||
@@ -9,9 +9,9 @@ package org.apache.ant.modules.core; | |||||
import java.net.URL; | import java.net.URL; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.avalon.camelot.DefaultLocator; | |||||
import org.apache.avalon.camelot.DeploymentException; | |||||
import org.apache.avalon.camelot.RegistryException; | |||||
import org.apache.avalon.framework.camelot.DefaultLocator; | |||||
import org.apache.avalon.framework.camelot.DeploymentException; | |||||
import org.apache.avalon.framework.camelot.RegistryException; | |||||
/** | /** | ||||
* Method to register a single datatype. | * Method to register a single datatype. | ||||
@@ -9,9 +9,9 @@ package org.apache.ant.modules.core; | |||||
import java.net.URL; | import java.net.URL; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.avalon.camelot.DefaultLocator; | |||||
import org.apache.avalon.camelot.DeploymentException; | |||||
import org.apache.avalon.camelot.RegistryException; | |||||
import org.apache.avalon.framework.camelot.DefaultLocator; | |||||
import org.apache.avalon.framework.camelot.DeploymentException; | |||||
import org.apache.avalon.framework.camelot.RegistryException; | |||||
/** | /** | ||||
* Method to register a single tasklet. | * Method to register a single tasklet. | ||||
@@ -13,10 +13,10 @@ import java.net.URL; | |||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.tasklet.AbstractTasklet; | import org.apache.ant.tasklet.AbstractTasklet; | ||||
import org.apache.ant.tasklet.engine.TaskletEngine; | import org.apache.ant.tasklet.engine.TaskletEngine; | ||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.camelot.DeploymentException; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.camelot.DeploymentException; | |||||
/** | /** | ||||
* Method to register a tasklib. | * Method to register a tasklib. | ||||
@@ -25,13 +25,13 @@ import org.apache.avalon.camelot.DeploymentException; | |||||
*/ | */ | ||||
public class RegisterTasklib | public class RegisterTasklib | ||||
extends AbstractTasklet | extends AbstractTasklet | ||||
implements Composer | |||||
implements Composable | |||||
{ | { | ||||
protected String m_lib; | protected String m_lib; | ||||
protected TaskletEngine m_engine; | protected TaskletEngine m_engine; | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
m_engine = (TaskletEngine)componentManager. | m_engine = (TaskletEngine)componentManager. | ||||
lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); | lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); | ||||
@@ -42,7 +42,7 @@ public class RegisterTasklib | |||||
m_lib = lib; | m_lib = lib; | ||||
} | } | ||||
public void run() | |||||
public void execute() | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
if( null == m_lib ) | if( null == m_lib ) | ||||
@@ -8,10 +8,10 @@ | |||||
package org.apache.ant.modules.test; | package org.apache.ant.modules.test; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.configuration.Configurable; | |||||
import org.apache.ant.configuration.Configuration; | |||||
import org.apache.ant.tasklet.AbstractTasklet; | import org.apache.ant.tasklet.AbstractTasklet; | ||||
import org.apache.avalon.ConfigurationException; | |||||
import org.apache.avalon.framework.configuration.Configuration; | |||||
import org.apache.avalon.framework.configuration.Configurable; | |||||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||||
/** | /** | ||||
* This is to test self interpretation of configuration. | * This is to test self interpretation of configuration. | ||||
@@ -22,7 +22,7 @@ public class ConfigurationTest | |||||
extends AbstractTasklet | extends AbstractTasklet | ||||
implements Configurable | implements Configurable | ||||
{ | { | ||||
protected String m_message; | |||||
private String m_message; | |||||
public void configure( final Configuration configuration ) | public void configure( final Configuration configuration ) | ||||
throws ConfigurationException | throws ConfigurationException | ||||
@@ -39,7 +39,7 @@ public class ConfigurationTest | |||||
} | } | ||||
} | } | ||||
public void run() | |||||
public void execute() | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
getLogger().warn( m_message ); | getLogger().warn( m_message ); | ||||
@@ -30,7 +30,7 @@ public class ContentTest | |||||
} | } | ||||
*/ | */ | ||||
public void run() | |||||
public void execute() | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
} | } | ||||
@@ -84,7 +84,7 @@ public class PrimitiveTypesTest | |||||
getLogger().warn( "setString( " + value + " );" ); | getLogger().warn( "setString( " + value + " );" ); | ||||
} | } | ||||
public void run() | |||||
public void execute() | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
} | } | ||||
@@ -37,7 +37,7 @@ public class SubElementTest | |||||
System.out.println( "addBeeper(" + beep + ");" ); | System.out.println( "addBeeper(" + beep + ");" ); | ||||
} | } | ||||
public void run() | |||||
public void execute() | |||||
throws AntException | throws AntException | ||||
{ | { | ||||
} | } | ||||
@@ -11,13 +11,13 @@ import java.io.File; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.configuration.Configuration; | |||||
import org.apache.ant.configuration.ConfigurationBuilder; | |||||
import org.apache.ant.util.Condition; | |||||
import org.apache.ant.tasklet.TaskletContext; | import org.apache.ant.tasklet.TaskletContext; | ||||
import org.apache.avalon.AbstractLoggable; | |||||
import org.apache.avalon.ConfigurationException; | |||||
import org.apache.avalon.util.StringUtil; | |||||
import org.apache.ant.util.Condition; | |||||
import org.apache.avalon.framework.ExceptionUtil; | |||||
import org.apache.avalon.framework.configuration.Configuration; | |||||
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; | |||||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||||
import org.apache.avalon.framework.logger.AbstractLoggable; | |||||
import org.apache.log.Logger; | import org.apache.log.Logger; | ||||
import org.xml.sax.InputSource; | import org.xml.sax.InputSource; | ||||
import org.xml.sax.SAXException; | import org.xml.sax.SAXException; | ||||
@@ -31,11 +31,11 @@ public class DefaultProjectBuilder | |||||
extends AbstractLoggable | extends AbstractLoggable | ||||
implements ProjectBuilder | implements ProjectBuilder | ||||
{ | { | ||||
protected ConfigurationBuilder m_builder; | |||||
protected DefaultConfigurationBuilder m_builder; | |||||
public DefaultProjectBuilder() | public DefaultProjectBuilder() | ||||
{ | { | ||||
m_builder = new ConfigurationBuilder(); | |||||
m_builder = new DefaultConfigurationBuilder(); | |||||
} | } | ||||
/** | /** | ||||
@@ -63,7 +63,7 @@ public class DefaultProjectBuilder | |||||
/** | /** | ||||
* Utility method to build a Configuration tree from a source. | * Utility method to build a Configuration tree from a source. | ||||
* Overide this in sub-classes if you want to provide extra | |||||
* Overide this in sub-classes if you want to provide extra | |||||
* functionality (ie xslt/css). | * functionality (ie xslt/css). | ||||
* | * | ||||
* @param location the location | * @param location the location | ||||
@@ -76,7 +76,7 @@ public class DefaultProjectBuilder | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
return (Configuration)m_builder.build( location ); | |||||
return (Configuration)m_builder.buildFromFile( location ); | |||||
} | } | ||||
catch( final SAXException se ) | catch( final SAXException se ) | ||||
{ | { | ||||
@@ -108,7 +108,7 @@ public class DefaultProjectBuilder | |||||
final String projectName = configuration.getAttribute( "name" ); | final String projectName = configuration.getAttribute( "name" ); | ||||
//determine base directory for project | //determine base directory for project | ||||
final File baseDirectory = | |||||
final File baseDirectory = | |||||
(new File( file.getParentFile(), baseDirectoryName )).getAbsoluteFile(); | (new File( file.getParentFile(), baseDirectoryName )).getAbsoluteFile(); | ||||
getLogger().debug( "Project " + projectName + " base directory: " + baseDirectory ); | getLogger().debug( "Project " + projectName + " base directory: " + baseDirectory ); | ||||
@@ -116,7 +116,7 @@ public class DefaultProjectBuilder | |||||
//create project and ... | //create project and ... | ||||
final DefaultProject project = new DefaultProject(); | final DefaultProject project = new DefaultProject(); | ||||
project.setDefaultTargetName( defaultTarget ); | project.setDefaultTargetName( defaultTarget ); | ||||
//setup basic context of project | //setup basic context of project | ||||
final TaskletContext context = project.getContext(); | final TaskletContext context = project.getContext(); | ||||
context.setProperty( TaskletContext.BASE_DIRECTORY, baseDirectory ); | context.setProperty( TaskletContext.BASE_DIRECTORY, baseDirectory ); | ||||
@@ -136,15 +136,15 @@ public class DefaultProjectBuilder | |||||
* @param configuration the Configuration | * @param configuration the Configuration | ||||
* @exception AntException if an error occurs | * @exception AntException if an error occurs | ||||
*/ | */ | ||||
protected void buildTopLevelProject( final DefaultProject project, | |||||
protected void buildTopLevelProject( final DefaultProject project, | |||||
final Configuration configuration ) | final Configuration configuration ) | ||||
throws AntException | throws AntException | ||||
{ | { | ||||
final Iterator elements = configuration.getChildren(); | |||||
final Configuration[] children = configuration.getChildren(); | |||||
while( elements.hasNext() ) | |||||
for( int i = 0; i < children.length; i++ ) | |||||
{ | { | ||||
final Configuration element = (Configuration)elements.next(); | |||||
final Configuration element = children[ i ]; | |||||
final String name = element.getName(); | final String name = element.getName(); | ||||
//handle individual elements | //handle individual elements | ||||
@@ -152,7 +152,7 @@ public class DefaultProjectBuilder | |||||
else if( name.equals( "property" ) ) buildImplicitTask( project, element ); | else if( name.equals( "property" ) ) buildImplicitTask( project, element ); | ||||
else | else | ||||
{ | { | ||||
throw new AntException( "Unknown top-level element " + name + | |||||
throw new AntException( "Unknown top-level element " + name + | |||||
" at " + element.getLocation() ); | " at " + element.getLocation() ); | ||||
} | } | ||||
} | } | ||||
@@ -173,16 +173,16 @@ public class DefaultProjectBuilder | |||||
if( null == name ) | if( null == name ) | ||||
{ | { | ||||
throw new AntException( "Discovered un-named target at " + | |||||
throw new AntException( "Discovered un-named target at " + | |||||
target.getLocation() ); | target.getLocation() ); | ||||
} | |||||
} | |||||
getLogger().debug( "Parsing target: " + name ); | getLogger().debug( "Parsing target: " + name ); | ||||
if( null != ifCondition && null != unlessCondition ) | if( null != ifCondition && null != unlessCondition ) | ||||
{ | { | ||||
throw new AntException( "Discovered invalid target that has both a if and " + | throw new AntException( "Discovered invalid target that has both a if and " + | ||||
"unless condition at " + target.getLocation() ); | |||||
"unless condition at " + target.getLocation() ); | |||||
} | } | ||||
Condition condition = null; | Condition condition = null; | ||||
@@ -203,7 +203,7 @@ public class DefaultProjectBuilder | |||||
//apply depends attribute | //apply depends attribute | ||||
if( null != depends ) | if( null != depends ) | ||||
{ | { | ||||
final String[] elements = StringUtil.splitString( depends, "," ); | |||||
final String[] elements = ExceptionUtil.splitString( depends, "," ); | |||||
for( int i = 0; i < elements.length; i++ ) | for( int i = 0; i < elements.length; i++ ) | ||||
{ | { | ||||
@@ -211,22 +211,21 @@ public class DefaultProjectBuilder | |||||
if( 0 == dependency.length() ) | if( 0 == dependency.length() ) | ||||
{ | { | ||||
throw new AntException( "Discovered empty dependency in target " + | |||||
target.getName() + " at " + target.getLocation() ); | |||||
throw new AntException( "Discovered empty dependency in target " + | |||||
target.getName() + " at " + target.getLocation() ); | |||||
} | } | ||||
getLogger().debug( "Target dependency: " + dependency ); | getLogger().debug( "Target dependency: " + dependency ); | ||||
defaultTarget.addDependency( dependency ); | defaultTarget.addDependency( dependency ); | ||||
} | |||||
} | |||||
} | } | ||||
//add all the targets from element | //add all the targets from element | ||||
final Iterator tasks = target.getChildren(); | |||||
while( tasks.hasNext() ) | |||||
final Configuration[] tasks = target.getChildren(); | |||||
for( int i = 0; i < tasks.length; i++ ) | |||||
{ | { | ||||
final Configuration task = (Configuration)tasks.next(); | |||||
getLogger().debug( "Parsed task: " + task.getName() ); | |||||
defaultTarget.addTask( task ); | |||||
getLogger().debug( "Parsed task: " + tasks[ i ].getName() ); | |||||
defaultTarget.addTask( tasks[ i ] ); | |||||
} | } | ||||
//add target to project | //add target to project | ||||
@@ -240,9 +239,9 @@ public class DefaultProjectBuilder | |||||
* @param task the configuration | * @param task the configuration | ||||
*/ | */ | ||||
protected void buildImplicitTask( final DefaultProject project, final Configuration task ) | protected void buildImplicitTask( final DefaultProject project, final Configuration task ) | ||||
{ | |||||
{ | |||||
DefaultTarget target = (DefaultTarget)project.getImplicitTarget(); | DefaultTarget target = (DefaultTarget)project.getImplicitTarget(); | ||||
if( null == target ) | if( null == target ) | ||||
{ | { | ||||
target = new DefaultTarget(); | target = new DefaultTarget(); | ||||
@@ -10,35 +10,35 @@ package org.apache.ant.project; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.configuration.Configuration; | |||||
import org.apache.ant.tasklet.DefaultTaskletContext; | import org.apache.ant.tasklet.DefaultTaskletContext; | ||||
import org.apache.ant.tasklet.TaskletContext; | import org.apache.ant.tasklet.TaskletContext; | ||||
import org.apache.ant.tasklet.engine.DefaultTaskletEngine; | import org.apache.ant.tasklet.engine.DefaultTaskletEngine; | ||||
import org.apache.ant.tasklet.engine.TaskletEngine; | import org.apache.ant.tasklet.engine.TaskletEngine; | ||||
import org.apache.ant.util.Condition; | import org.apache.ant.util.Condition; | ||||
import org.apache.avalon.AbstractLoggable; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.DefaultComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.DefaultComponentManager; | |||||
import org.apache.avalon.Disposable; | |||||
import org.apache.avalon.Initializable; | |||||
import org.apache.avalon.framework.activity.Disposable; | |||||
import org.apache.avalon.framework.activity.Initializable; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.component.DefaultComponentManager; | |||||
import org.apache.avalon.framework.component.DefaultComponentManager; | |||||
import org.apache.avalon.framework.configuration.Configuration; | |||||
import org.apache.avalon.framework.logger.AbstractLoggable; | |||||
import org.apache.log.Logger; | import org.apache.log.Logger; | ||||
/** | /** | ||||
* This is the default implementation of ProjectEngine. | * This is the default implementation of ProjectEngine. | ||||
* | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | ||||
*/ | */ | ||||
public class DefaultProjectEngine | public class DefaultProjectEngine | ||||
extends AbstractLoggable | extends AbstractLoggable | ||||
implements ProjectEngine, Composer | |||||
implements ProjectEngine, Composable | |||||
{ | { | ||||
protected TaskletEngine m_taskletEngine; | protected TaskletEngine m_taskletEngine; | ||||
protected ProjectListenerSupport m_listenerSupport = new ProjectListenerSupport(); | protected ProjectListenerSupport m_listenerSupport = new ProjectListenerSupport(); | ||||
protected DefaultComponentManager m_componentManager; | protected DefaultComponentManager m_componentManager; | ||||
/** | /** | ||||
* Add a listener to project events. | * Add a listener to project events. | ||||
* | * | ||||
@@ -48,7 +48,7 @@ public class DefaultProjectEngine | |||||
{ | { | ||||
m_listenerSupport.addProjectListener( listener ); | m_listenerSupport.addProjectListener( listener ); | ||||
} | } | ||||
/** | /** | ||||
* Remove a listener from project events. | * Remove a listener from project events. | ||||
* | * | ||||
@@ -58,15 +58,15 @@ public class DefaultProjectEngine | |||||
{ | { | ||||
m_listenerSupport.removeProjectListener( listener ); | m_listenerSupport.removeProjectListener( listener ); | ||||
} | } | ||||
/** | /** | ||||
* Retrieve relevent services needed for engine. | * Retrieve relevent services needed for engine. | ||||
* | * | ||||
* @param componentManager the ComponentManager | * @param componentManager the ComponentManager | ||||
* @exception ComponentManagerException if an error occurs | |||||
* @exception ComponentException if an error occurs | |||||
*/ | */ | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
m_componentManager = (DefaultComponentManager)componentManager; | m_componentManager = (DefaultComponentManager)componentManager; | ||||
m_taskletEngine = (TaskletEngine)componentManager. | m_taskletEngine = (TaskletEngine)componentManager. | ||||
@@ -80,7 +80,7 @@ public class DefaultProjectEngine | |||||
* @param project the Project | * @param project the Project | ||||
* @param target the name of the target | * @param target the name of the target | ||||
* @exception AntException if an error occurs | * @exception AntException if an error occurs | ||||
*/ | |||||
*/ | |||||
public void execute( final Project project, final String target ) | public void execute( final Project project, final String target ) | ||||
throws AntException | throws AntException | ||||
{ | { | ||||
@@ -125,8 +125,8 @@ public class DefaultProjectEngine | |||||
* @param done the list of targets already executed in current run | * @param done the list of targets already executed in current run | ||||
* @exception AntException if an error occurs | * @exception AntException if an error occurs | ||||
*/ | */ | ||||
protected void execute( final Project project, | |||||
final String targetName, | |||||
protected void execute( final Project project, | |||||
final String targetName, | |||||
final TaskletContext context, | final TaskletContext context, | ||||
final ArrayList done ) | final ArrayList done ) | ||||
throws AntException | throws AntException | ||||
@@ -137,7 +137,7 @@ public class DefaultProjectEngine | |||||
{ | { | ||||
throw new AntException( "Unable to find target " + targetName ); | throw new AntException( "Unable to find target " + targetName ); | ||||
} | } | ||||
//add target to list of targets executed | //add target to list of targets executed | ||||
done.add( targetName ); | done.add( targetName ); | ||||
@@ -163,8 +163,8 @@ public class DefaultProjectEngine | |||||
* @param context the context in which to execute | * @param context the context in which to execute | ||||
* @exception AntException if an error occurs | * @exception AntException if an error occurs | ||||
*/ | */ | ||||
protected void executeTarget( final String targetName, | |||||
final Target target, | |||||
protected void executeTarget( final String targetName, | |||||
final Target target, | |||||
final TaskletContext context ) | final TaskletContext context ) | ||||
throws AntException | throws AntException | ||||
{ | { | ||||
@@ -175,13 +175,13 @@ public class DefaultProjectEngine | |||||
//create project context and set target name | //create project context and set target name | ||||
final TaskletContext targetContext = new DefaultTaskletContext( context ); | final TaskletContext targetContext = new DefaultTaskletContext( context ); | ||||
targetContext.setProperty( Project.TARGET, targetName ); | targetContext.setProperty( Project.TARGET, targetName ); | ||||
//notify listeners | //notify listeners | ||||
m_listenerSupport.targetStarted( targetName ); | m_listenerSupport.targetStarted( targetName ); | ||||
//actually do the execution work | |||||
//actually do the execution work | |||||
executeTargetWork( targetName, target, targetContext ); | executeTargetWork( targetName, target, targetContext ); | ||||
//notify listeners | //notify listeners | ||||
m_listenerSupport.targetFinished(); | m_listenerSupport.targetFinished(); | ||||
} | } | ||||
@@ -194,8 +194,8 @@ public class DefaultProjectEngine | |||||
* @param target the target | * @param target the target | ||||
* @param context the context | * @param context the context | ||||
*/ | */ | ||||
protected void executeTargetWork( final String name, | |||||
final Target target, | |||||
protected void executeTargetWork( final String name, | |||||
final Target target, | |||||
final TaskletContext context ) | final TaskletContext context ) | ||||
{ | { | ||||
//check the condition associated with target. | //check the condition associated with target. | ||||
@@ -205,7 +205,7 @@ public class DefaultProjectEngine | |||||
{ | { | ||||
if( false == condition.evaluate( context ) ) | if( false == condition.evaluate( context ) ) | ||||
{ | { | ||||
getLogger().debug( "Skipping target " + name + | |||||
getLogger().debug( "Skipping target " + name + | |||||
" as it does not satisfy condition" ); | " as it does not satisfy condition" ); | ||||
return; | return; | ||||
} | } | ||||
@@ -226,7 +226,7 @@ public class DefaultProjectEngine | |||||
* Execute a task. | * Execute a task. | ||||
* | * | ||||
* @param task the task definition | * @param task the task definition | ||||
* @param context the context | |||||
* @param context the context | |||||
* @exception AntException if an error occurs | * @exception AntException if an error occurs | ||||
*/ | */ | ||||
protected void executeTask( final Configuration task, final TaskletContext context ) | protected void executeTask( final Configuration task, final TaskletContext context ) | ||||
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.ant.project; | package org.apache.ant.project; | ||||
import org.apache.avalon.util.StringUtil; | |||||
import org.apache.avalon.framework.ExceptionUtil; | |||||
/** | /** | ||||
* Default listener that emulates the old ant listener notifications. | * Default listener that emulates the old ant listener notifications. | ||||
@@ -89,7 +89,7 @@ public class DefaultProjectListener | |||||
*/ | */ | ||||
public void log( String message, Throwable throwable ) | public void log( String message, Throwable throwable ) | ||||
{ | { | ||||
output( message + "\n" + StringUtil.printStackTrace( throwable, 5, true ) ); | |||||
output( message + "\n" + ExceptionUtil.printStackTrace( throwable, 5, true ) ); | |||||
} | } | ||||
/** | /** | ||||
@@ -9,8 +9,8 @@ package org.apache.ant.project; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.ant.configuration.Configuration; | |||||
import org.apache.ant.util.Condition; | import org.apache.ant.util.Condition; | ||||
import org.apache.avalon.framework.configuration.Configuration; | |||||
/** | /** | ||||
* Default implementation of target. | * Default implementation of target. | ||||
@@ -41,7 +41,7 @@ public class DefaultTarget | |||||
{ | { | ||||
this( null ); | this( null ); | ||||
} | } | ||||
/** | /** | ||||
* Get condition under which target is executed. | * Get condition under which target is executed. | ||||
* | * | ||||
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.ant.project; | package org.apache.ant.project; | ||||
import org.apache.log.LogEntry; | |||||
import org.apache.log.LogEvent; | |||||
import org.apache.log.LogTarget; | import org.apache.log.LogTarget; | ||||
/** | /** | ||||
@@ -31,19 +31,19 @@ public class LogTargetToListenerAdapter | |||||
} | } | ||||
/** | /** | ||||
* Process a log entry. | |||||
* Process a log event. | |||||
* | * | ||||
* @param entry the entry | |||||
* @param event the event | |||||
*/ | */ | ||||
public void processEntry( final LogEntry entry ) | |||||
public void processEvent( final LogEvent event ) | |||||
{ | { | ||||
if( null == entry.getThrowable() ) | |||||
if( null == event.getThrowable() ) | |||||
{ | { | ||||
m_listener.log( entry.getMessage() ); | |||||
m_listener.log( event.getMessage() ); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
m_listener.log( entry.getMessage(), entry.getThrowable() ); | |||||
m_listener.log( event.getMessage(), event.getThrowable() ); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -10,7 +10,7 @@ package org.apache.ant.project; | |||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.tasklet.TaskletContext; | import org.apache.ant.tasklet.TaskletContext; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.framework.component.Component; | |||||
/** | /** | ||||
* Interface through which to interact with projects. | * Interface through which to interact with projects. | ||||
@@ -10,7 +10,7 @@ package org.apache.ant.project; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.framework.component.Component; | |||||
/** | /** | ||||
* Interface implemented by components that build projects from sources. | * Interface implemented by components that build projects from sources. | ||||
@@ -10,7 +10,7 @@ package org.apache.ant.project; | |||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.tasklet.TaskletContext; | import org.apache.ant.tasklet.TaskletContext; | ||||
import org.apache.ant.tasklet.engine.TaskletEngine; | import org.apache.ant.tasklet.engine.TaskletEngine; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.framework.component.Component; | |||||
/** | /** | ||||
* This is the interface between ProjectEngine and rest of the system. | * This is the interface between ProjectEngine and rest of the system. | ||||
@@ -9,7 +9,7 @@ package org.apache.ant.project; | |||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.ant.util.Condition; | import org.apache.ant.util.Condition; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.framework.component.Component; | |||||
/** | /** | ||||
* Interface to represent targets in build file. | * Interface to represent targets in build file. | ||||
@@ -10,9 +10,9 @@ package org.apache.ant.runtime; | |||||
import java.util.Properties; | import java.util.Properties; | ||||
import org.apache.ant.project.ProjectBuilder; | import org.apache.ant.project.ProjectBuilder; | ||||
import org.apache.ant.project.ProjectEngine; | import org.apache.ant.project.ProjectEngine; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.Disposable; | |||||
import org.apache.avalon.Initializable; | |||||
import org.apache.avalon.framework.activity.Disposable; | |||||
import org.apache.avalon.framework.activity.Initializable; | |||||
import org.apache.avalon.framework.component.Component; | |||||
/** | /** | ||||
* Interface to the Ant runtime. | * Interface to the Ant runtime. | ||||
@@ -23,7 +23,7 @@ public interface AntEngine | |||||
extends Component, Initializable, Disposable | extends Component, Initializable, Disposable | ||||
{ | { | ||||
/** | /** | ||||
* Setup basic properties of engine. | |||||
* Setup basic properties of engine. | |||||
* Called before init() and can be used to specify alternate components in system. | * Called before init() and can be used to specify alternate components in system. | ||||
* | * | ||||
* @param properties the properties | * @param properties the properties | ||||
@@ -37,7 +37,7 @@ public interface AntEngine | |||||
* @return the ProjectBuilder | * @return the ProjectBuilder | ||||
*/ | */ | ||||
ProjectBuilder getProjectBuilder(); | ProjectBuilder getProjectBuilder(); | ||||
/** | /** | ||||
* Retrieve project engine for runtime. | * Retrieve project engine for runtime. | ||||
* Valid after init() call | * Valid after init() call | ||||
@@ -18,17 +18,16 @@ import org.apache.ant.tasklet.JavaVersion; | |||||
import org.apache.ant.tasklet.engine.DataTypeEngine; | import org.apache.ant.tasklet.engine.DataTypeEngine; | ||||
import org.apache.ant.tasklet.engine.TaskletEngine; | import org.apache.ant.tasklet.engine.TaskletEngine; | ||||
import org.apache.ant.tasklet.engine.TskDeployer; | import org.apache.ant.tasklet.engine.TskDeployer; | ||||
import org.apache.avalon.AbstractLoggable; | |||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.DefaultComponentManager; | |||||
import org.apache.avalon.Initializable; | |||||
import org.apache.avalon.camelot.CamelotUtil; | |||||
import org.apache.avalon.camelot.DefaultFactory; | |||||
import org.apache.avalon.camelot.Deployer; | |||||
import org.apache.avalon.camelot.Factory; | |||||
import org.apache.avalon.util.ObjectUtil; | |||||
import org.apache.avalon.util.io.FileUtil; | |||||
import org.apache.avalon.framework.logger.AbstractLoggable; | |||||
import org.apache.avalon.framework.component.Component; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.component.DefaultComponentManager; | |||||
import org.apache.avalon.framework.activity.Initializable; | |||||
import org.apache.avalon.framework.camelot.CamelotUtil; | |||||
import org.apache.avalon.framework.camelot.DefaultFactory; | |||||
import org.apache.avalon.framework.camelot.Deployer; | |||||
import org.apache.avalon.framework.camelot.Factory; | |||||
import org.apache.avalon.excalibur.io.FileUtil; | |||||
/** | /** | ||||
* Default implementation of Ant runtime. | * Default implementation of Ant runtime. | ||||
@@ -97,7 +96,7 @@ public class DefaultAntEngine | |||||
* | * | ||||
* @exception Exception if an error occurs | * @exception Exception if an error occurs | ||||
*/ | */ | ||||
public void init() | |||||
public void initialize() | |||||
throws Exception | throws Exception | ||||
{ | { | ||||
//setup default properties | //setup default properties | ||||
@@ -193,7 +192,7 @@ public class DefaultAntEngine | |||||
componentManager.put( "org.apache.ant.tasklet.engine.DataTypeEngine", m_dataTypeEngine ); | componentManager.put( "org.apache.ant.tasklet.engine.DataTypeEngine", m_dataTypeEngine ); | ||||
componentManager.put( "org.apache.ant.project.ProjectBuilder", m_builder ); | componentManager.put( "org.apache.ant.project.ProjectBuilder", m_builder ); | ||||
componentManager.put( "org.apache.ant.tasklet.engine.TskDeployer", m_deployer ); | componentManager.put( "org.apache.ant.tasklet.engine.TskDeployer", m_deployer ); | ||||
componentManager.put( "org.apache.avalon.camelot.Factory", m_factory ); | |||||
componentManager.put( "org.apache.avalon.framework.camelot.Factory", m_factory ); | |||||
componentManager.put( "org.apache.ant.configuration.Configurer", m_configurer ); | componentManager.put( "org.apache.ant.configuration.Configurer", m_configurer ); | ||||
return componentManager; | return componentManager; | ||||
@@ -260,14 +259,14 @@ public class DefaultAntEngine | |||||
{ | { | ||||
setupLogger( component ); | setupLogger( component ); | ||||
if( component instanceof Composer ) | |||||
if( component instanceof Composable ) | |||||
{ | { | ||||
((Composer)component).compose( m_componentManager ); | |||||
((Composable)component).compose( m_componentManager ); | |||||
} | } | ||||
if( component instanceof Initializable ) | if( component instanceof Initializable ) | ||||
{ | { | ||||
((Initializable)component).init(); | |||||
((Initializable)component).initialize(); | |||||
} | } | ||||
} | } | ||||
@@ -383,7 +382,7 @@ public class DefaultAntEngine | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
final Object object = ObjectUtil.createObject( component ); | |||||
final Object object = Class.forName( component ).newInstance(); | |||||
if( !clazz.isInstance( object ) ) | if( !clazz.isInstance( object ) ) | ||||
{ | { | ||||
@@ -8,9 +8,11 @@ | |||||
package org.apache.ant.tasklet; | package org.apache.ant.tasklet; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.avalon.AbstractLoggable; | |||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.Initializable; | |||||
import org.apache.avalon.framework.activity.Disposable; | |||||
import org.apache.avalon.framework.activity.Initializable; | |||||
import org.apache.avalon.framework.context.Context; | |||||
import org.apache.avalon.framework.context.Contextualizable; | |||||
import org.apache.avalon.framework.logger.AbstractLoggable; | |||||
/** | /** | ||||
* This is abstract base class for tasklets. | * This is abstract base class for tasklets. | ||||
@@ -19,11 +21,9 @@ import org.apache.avalon.Initializable; | |||||
*/ | */ | ||||
public abstract class AbstractTasklet | public abstract class AbstractTasklet | ||||
extends AbstractLoggable | extends AbstractLoggable | ||||
implements Tasklet, Initializable | |||||
implements Tasklet, Contextualizable, Initializable, Disposable | |||||
{ | { | ||||
//the user should set this in constructors of sub-classes | |||||
protected JavaVersion m_requiredJavaVersion; | |||||
///Variable to hold context for use by sub-classes | |||||
private TaskletContext m_context; | private TaskletContext m_context; | ||||
/** | /** | ||||
@@ -37,27 +37,24 @@ public abstract class AbstractTasklet | |||||
} | } | ||||
/** | /** | ||||
* This will be called before run() method and checks any preconditions. | |||||
* | |||||
* Intially preconditions just include JVM version but in future it | |||||
* will automagically also check if all required parameters are present. | |||||
* This will be called before execute() method and checks any preconditions. | |||||
* | * | ||||
* @exception AntException if an error occurs | |||||
* @exception Exception if an error occurs | |||||
*/ | */ | ||||
public void init() | |||||
throws AntException | |||||
public void initialize() | |||||
throws Exception | |||||
{ | { | ||||
if( null != m_requiredJavaVersion ) | |||||
{ | |||||
final JavaVersion suppliedVersion = m_context.getJavaVersion(); | |||||
} | |||||
if( m_requiredJavaVersion.isLessThan( suppliedVersion ) ) | |||||
{ | |||||
throw new AntException( "Task requires a JavaVersion of at least " + | |||||
m_requiredJavaVersion + " but current version is " + | |||||
suppliedVersion ); | |||||
} | |||||
} | |||||
/** | |||||
* This will be called after execute() method. | |||||
* Use this to clean up any resources associated with task. | |||||
* | |||||
* @exception Exception if an error occurs | |||||
*/ | |||||
public void dispose() | |||||
throws Exception | |||||
{ | |||||
} | } | ||||
/** | /** | ||||
@@ -65,7 +62,7 @@ public abstract class AbstractTasklet | |||||
* | * | ||||
* @return the context | * @return the context | ||||
*/ | */ | ||||
protected TaskletContext getContext() | |||||
protected final TaskletContext getContext() | |||||
{ | { | ||||
return m_context; | return m_context; | ||||
} | } | ||||
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.ant.tasklet; | package org.apache.ant.tasklet; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.framework.component.Component; | |||||
/** | /** | ||||
* Base class for those classes that can appear inside the build file | * Base class for those classes that can appear inside the build file | ||||
@@ -9,10 +9,11 @@ package org.apache.ant.tasklet; | |||||
import java.io.File; | import java.io.File; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.avalon.DefaultContext; | |||||
import org.apache.avalon.util.PropertyException; | |||||
import org.apache.avalon.util.PropertyUtil; | |||||
import org.apache.avalon.util.io.FileUtil; | |||||
import org.apache.avalon.framework.context.DefaultContext; | |||||
import org.apache.avalon.framework.context.ContextException; | |||||
import org.apache.avalon.excalibur.property.PropertyException; | |||||
import org.apache.avalon.excalibur.property.PropertyUtil; | |||||
import org.apache.avalon.excalibur.io.FileUtil; | |||||
/** | /** | ||||
* Default implementation of TaskletContext. | * Default implementation of TaskletContext. | ||||
@@ -42,7 +43,7 @@ public class DefaultTaskletContext | |||||
if( null != parent ) | if( null != parent ) | ||||
{ | { | ||||
m_baseDirectory = (File)parent.get( BASE_DIRECTORY ); | |||||
m_baseDirectory = (File)parent.getBaseDirectory(); | |||||
} | } | ||||
} | } | ||||
@@ -53,7 +54,14 @@ public class DefaultTaskletContext | |||||
*/ | */ | ||||
public JavaVersion getJavaVersion() | public JavaVersion getJavaVersion() | ||||
{ | { | ||||
return (JavaVersion)get( JAVA_VERSION ); | |||||
try | |||||
{ | |||||
return (JavaVersion)get( JAVA_VERSION ); | |||||
} | |||||
catch( final ContextException ce ) | |||||
{ | |||||
throw new IllegalStateException( "No JavaVersion in Context" ); | |||||
} | |||||
} | } | ||||
@@ -64,7 +72,14 @@ public class DefaultTaskletContext | |||||
*/ | */ | ||||
public String getName() | public String getName() | ||||
{ | { | ||||
return (String)get( NAME ); | |||||
try | |||||
{ | |||||
return (String)get( NAME ); | |||||
} | |||||
catch( final ContextException ce ) | |||||
{ | |||||
throw new IllegalStateException( "No Name in Context" ); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -119,7 +134,11 @@ public class DefaultTaskletContext | |||||
*/ | */ | ||||
public Object getProperty( final String name ) | public Object getProperty( final String name ) | ||||
{ | { | ||||
return get( name ); | |||||
try { return get( name ); } | |||||
catch( final ContextException ce ) | |||||
{ | |||||
return null; | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -7,7 +7,7 @@ | |||||
*/ | */ | ||||
package org.apache.ant.tasklet; | package org.apache.ant.tasklet; | ||||
import org.apache.avalon.util.ValuedEnum; | |||||
import org.apache.avalon.framework.ValuedEnum; | |||||
/** | /** | ||||
* Type safe wrapper class for Java Version enums. | * Type safe wrapper class for Java Version enums. | ||||
@@ -7,16 +7,14 @@ | |||||
*/ | */ | ||||
package org.apache.ant.tasklet; | package org.apache.ant.tasklet; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.Contextualizable; | |||||
import org.apache.avalon.Loggable; | |||||
import org.apache.avalon.framework.component.Component; | |||||
/** | /** | ||||
* This represents the individual tasks. | * This represents the individual tasks. | ||||
* Particular instances can also implement Initializable | * Particular instances can also implement Initializable | ||||
* and/or Disposable, in which case init()/dispose() will | * and/or Disposable, in which case init()/dispose() will | ||||
* be called at appropriate time. | * be called at appropriate time. | ||||
* The task can also implement Composer in which case required | |||||
* The task can also implement Composable in which case required | |||||
* facilities will be passed via a ComponentManager. The actual | * facilities will be passed via a ComponentManager. The actual | ||||
* facilties is determined by particular task engine but will usually | * facilties is determined by particular task engine but will usually | ||||
* include ProjectEngine and TaskEngine. | * include ProjectEngine and TaskEngine. | ||||
@@ -24,6 +22,8 @@ import org.apache.avalon.Loggable; | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | ||||
*/ | */ | ||||
public interface Tasklet | public interface Tasklet | ||||
extends Component, Loggable, Contextualizable, Runnable | |||||
extends Component | |||||
{ | { | ||||
void execute() | |||||
throws Exception; | |||||
} | } |
@@ -8,9 +8,9 @@ | |||||
package org.apache.ant.tasklet; | package org.apache.ant.tasklet; | ||||
import java.io.File; | import java.io.File; | ||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.util.Enum; | |||||
import org.apache.avalon.util.ValuedEnum; | |||||
import org.apache.avalon.framework.context.Context; | |||||
import org.apache.avalon.framework.Enum; | |||||
import org.apache.avalon.framework.ValuedEnum; | |||||
/** | /** | ||||
* This represents the *Context* in which a task can be executed. | * This represents the *Context* in which a task can be executed. | ||||
@@ -8,10 +8,10 @@ | |||||
package org.apache.ant.tasklet.engine; | package org.apache.ant.tasklet.engine; | ||||
import org.apache.ant.tasklet.DataType; | import org.apache.ant.tasklet.DataType; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.camelot.FactoryException; | |||||
import org.apache.avalon.camelot.LocatorRegistry; | |||||
import org.apache.avalon.camelot.RegistryException; | |||||
import org.apache.avalon.framework.component.Component; | |||||
import org.apache.avalon.framework.camelot.FactoryException; | |||||
import org.apache.avalon.framework.camelot.Registry; | |||||
import org.apache.avalon.framework.camelot.RegistryException; | |||||
/** | /** | ||||
* This is basically a engine that can be used to access data-types. | * This is basically a engine that can be used to access data-types. | ||||
@@ -28,7 +28,7 @@ public interface DataTypeEngine | |||||
* | * | ||||
* @return the registry | * @return the registry | ||||
*/ | */ | ||||
LocatorRegistry getRegistry(); | |||||
Registry getRegistry(); | |||||
/** | /** | ||||
* Create a data-type of type registered under name. | * Create a data-type of type registered under name. | ||||
@@ -8,16 +8,16 @@ | |||||
package org.apache.ant.tasklet.engine; | package org.apache.ant.tasklet.engine; | ||||
import org.apache.ant.tasklet.DataType; | import org.apache.ant.tasklet.DataType; | ||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.camelot.DefaultLocatorRegistry; | |||||
import org.apache.avalon.camelot.Factory; | |||||
import org.apache.avalon.camelot.FactoryException; | |||||
import org.apache.avalon.camelot.Locator; | |||||
import org.apache.avalon.camelot.LocatorRegistry; | |||||
import org.apache.avalon.camelot.RegistryException; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.camelot.DefaultRegistry; | |||||
import org.apache.avalon.framework.camelot.Factory; | |||||
import org.apache.avalon.framework.camelot.FactoryException; | |||||
import org.apache.avalon.framework.camelot.Locator; | |||||
import org.apache.avalon.framework.camelot.Registry; | |||||
import org.apache.avalon.framework.camelot.RegistryException; | |||||
/** | /** | ||||
* This is basically a engine that can be used to access data-types. | * This is basically a engine that can be used to access data-types. | ||||
@@ -26,10 +26,10 @@ import org.apache.avalon.camelot.RegistryException; | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | ||||
*/ | */ | ||||
public class DefaultDataTypeEngine | public class DefaultDataTypeEngine | ||||
implements DataTypeEngine, Composer | |||||
implements DataTypeEngine, Composable | |||||
{ | { | ||||
protected Factory m_factory; | protected Factory m_factory; | ||||
protected LocatorRegistry m_registry = new DefaultLocatorRegistry(); | |||||
protected Registry m_registry = new DefaultRegistry( Locator.class ); | |||||
/** | /** | ||||
* Retrieve registry of data-types. | * Retrieve registry of data-types. | ||||
@@ -37,7 +37,7 @@ public class DefaultDataTypeEngine | |||||
* | * | ||||
* @return the registry | * @return the registry | ||||
*/ | */ | ||||
public LocatorRegistry getRegistry() | |||||
public Registry getRegistry() | |||||
{ | { | ||||
return m_registry; | return m_registry; | ||||
} | } | ||||
@@ -46,12 +46,12 @@ public class DefaultDataTypeEngine | |||||
* Retrieve relevent services needed to deploy. | * Retrieve relevent services needed to deploy. | ||||
* | * | ||||
* @param componentManager the ComponentManager | * @param componentManager the ComponentManager | ||||
* @exception ComponentManagerException if an error occurs | |||||
* @exception ComponentException if an error occurs | |||||
*/ | */ | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
m_factory = (Factory)componentManager.lookup( "org.apache.avalon.camelot.Factory" ); | |||||
m_factory = (Factory)componentManager.lookup( "org.apache.avalon.framework.camelot.Factory" ); | |||||
} | } | ||||
/** | /** | ||||
@@ -65,7 +65,7 @@ public class DefaultDataTypeEngine | |||||
public DataType createDataType( final String name ) | public DataType createDataType( final String name ) | ||||
throws RegistryException, FactoryException | throws RegistryException, FactoryException | ||||
{ | { | ||||
final Locator locator = m_registry.getLocator( name ); | |||||
final Locator locator = (Locator)m_registry.getInfo( name, Locator.class ); | |||||
return (DataType)m_factory.create( locator, DataType.class ); | return (DataType)m_factory.create( locator, DataType.class ); | ||||
} | } | ||||
} | } |
@@ -9,41 +9,41 @@ package org.apache.ant.tasklet.engine; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.configuration.Configurable; | |||||
import org.apache.ant.configuration.Configuration; | |||||
import org.apache.ant.configuration.Configurer; | import org.apache.ant.configuration.Configurer; | ||||
import org.apache.ant.configuration.DefaultConfigurer; | import org.apache.ant.configuration.DefaultConfigurer; | ||||
import org.apache.avalon.framework.configuration.Configuration; | |||||
import org.apache.avalon.framework.configuration.Configurable; | |||||
import org.apache.ant.convert.engine.ConverterEngine; | import org.apache.ant.convert.engine.ConverterEngine; | ||||
import org.apache.ant.tasklet.Tasklet; | import org.apache.ant.tasklet.Tasklet; | ||||
import org.apache.ant.tasklet.TaskletContext; | import org.apache.ant.tasklet.TaskletContext; | ||||
import org.apache.avalon.AbstractLoggable; | |||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.DefaultComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.Contextualizable; | |||||
import org.apache.avalon.DefaultComponentManager; | |||||
import org.apache.avalon.Disposable; | |||||
import org.apache.avalon.Initializable; | |||||
import org.apache.avalon.Loggable; | |||||
import org.apache.avalon.camelot.DefaultFactory; | |||||
import org.apache.avalon.camelot.DefaultLocatorRegistry; | |||||
import org.apache.avalon.camelot.Factory; | |||||
import org.apache.avalon.camelot.FactoryException; | |||||
import org.apache.avalon.camelot.Locator; | |||||
import org.apache.avalon.camelot.LocatorRegistry; | |||||
import org.apache.avalon.camelot.RegistryException; | |||||
import org.apache.avalon.framework.logger.AbstractLoggable; | |||||
import org.apache.avalon.framework.component.Component; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.DefaultComponentManager; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.context.Context; | |||||
import org.apache.avalon.framework.context.Contextualizable; | |||||
import org.apache.avalon.framework.component.DefaultComponentManager; | |||||
import org.apache.avalon.framework.activity.Disposable; | |||||
import org.apache.avalon.framework.activity.Initializable; | |||||
import org.apache.avalon.framework.logger.Loggable; | |||||
import org.apache.avalon.framework.camelot.DefaultFactory; | |||||
import org.apache.avalon.framework.camelot.DefaultRegistry; | |||||
import org.apache.avalon.framework.camelot.Factory; | |||||
import org.apache.avalon.framework.camelot.FactoryException; | |||||
import org.apache.avalon.framework.camelot.Locator; | |||||
import org.apache.avalon.framework.camelot.Registry; | |||||
import org.apache.avalon.framework.camelot.RegistryException; | |||||
import org.apache.log.Logger; | import org.apache.log.Logger; | ||||
public class DefaultTaskletEngine | public class DefaultTaskletEngine | ||||
extends AbstractLoggable | extends AbstractLoggable | ||||
implements TaskletEngine, Composer | |||||
implements TaskletEngine, Composable | |||||
{ | { | ||||
protected TskDeployer m_tskDeployer; | protected TskDeployer m_tskDeployer; | ||||
protected Factory m_factory; | protected Factory m_factory; | ||||
protected LocatorRegistry m_locatorRegistry = new DefaultLocatorRegistry(); | |||||
protected Registry m_locatorRegistry = new DefaultRegistry( Locator.class ); | |||||
protected Configurer m_configurer; | protected Configurer m_configurer; | ||||
protected DataTypeEngine m_dataTypeEngine; | protected DataTypeEngine m_dataTypeEngine; | ||||
protected ConverterEngine m_converterEngine; | protected ConverterEngine m_converterEngine; | ||||
@@ -60,7 +60,7 @@ public class DefaultTaskletEngine | |||||
return m_converterEngine; | return m_converterEngine; | ||||
} | } | ||||
public LocatorRegistry getRegistry() | |||||
public Registry getRegistry() | |||||
{ | { | ||||
return m_locatorRegistry; | return m_locatorRegistry; | ||||
} | } | ||||
@@ -79,15 +79,15 @@ public class DefaultTaskletEngine | |||||
* Retrieve relevent services needed to deploy. | * Retrieve relevent services needed to deploy. | ||||
* | * | ||||
* @param componentManager the ComponentManager | * @param componentManager the ComponentManager | ||||
* @exception ComponentManagerException if an error occurs | |||||
* @exception ComponentException if an error occurs | |||||
*/ | */ | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
//cache CM so it can be used while executing tasks | //cache CM so it can be used while executing tasks | ||||
m_componentManager = componentManager; | m_componentManager = componentManager; | ||||
m_factory = (Factory)componentManager.lookup( "org.apache.avalon.camelot.Factory" ); | |||||
m_factory = (Factory)componentManager.lookup( "org.apache.avalon.framework.camelot.Factory" ); | |||||
m_tskDeployer = (TskDeployer)componentManager. | m_tskDeployer = (TskDeployer)componentManager. | ||||
lookup( "org.apache.ant.tasklet.engine.TskDeployer" ); | lookup( "org.apache.ant.tasklet.engine.TskDeployer" ); | ||||
m_configurer = (Configurer)componentManager. | m_configurer = (Configurer)componentManager. | ||||
@@ -118,7 +118,11 @@ public class DefaultTaskletEngine | |||||
doInitialize( tasklet, task ); | doInitialize( tasklet, task ); | ||||
getLogger().debug( "Running" ); | getLogger().debug( "Running" ); | ||||
tasklet.run(); | |||||
try { tasklet.execute(); } | |||||
catch( final Exception e ) | |||||
{ | |||||
throw new AntException( "Error executing task", e ); | |||||
} | |||||
getLogger().debug( "Disposing" ); | getLogger().debug( "Disposing" ); | ||||
doDispose( tasklet, task ); | doDispose( tasklet, task ); | ||||
@@ -129,7 +133,7 @@ public class DefaultTaskletEngine | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
final Locator locator = m_locatorRegistry.getLocator( name ); | |||||
final Locator locator = (Locator)m_locatorRegistry.getInfo( name, Locator.class ); | |||||
return (Tasklet)m_factory.create( locator, Tasklet.class ); | return (Tasklet)m_factory.create( locator, Tasklet.class ); | ||||
} | } | ||||
catch( final RegistryException re ) | catch( final RegistryException re ) | ||||
@@ -159,9 +163,9 @@ public class DefaultTaskletEngine | |||||
protected void doCompose( final Tasklet tasklet, final Configuration task ) | protected void doCompose( final Tasklet tasklet, final Configuration task ) | ||||
throws AntException | throws AntException | ||||
{ | { | ||||
if( tasklet instanceof Composer ) | |||||
if( tasklet instanceof Composable ) | |||||
{ | { | ||||
try { ((Composer)tasklet).compose( m_componentManager ); } | |||||
try { ((Composable)tasklet).compose( m_componentManager ); } | |||||
catch( final Throwable throwable ) | catch( final Throwable throwable ) | ||||
{ | { | ||||
throw new AntException( "Error composing task " + task.getName() + " at " + | throw new AntException( "Error composing task " + task.getName() + " at " + | ||||
@@ -176,7 +180,13 @@ public class DefaultTaskletEngine | |||||
final TaskletContext context ) | final TaskletContext context ) | ||||
throws AntException | throws AntException | ||||
{ | { | ||||
try { tasklet.contextualize( context ); } | |||||
try | |||||
{ | |||||
if( tasklet instanceof Contextualizable ) | |||||
{ | |||||
((Contextualizable)tasklet).contextualize( context ); | |||||
} | |||||
} | |||||
catch( final Throwable throwable ) | catch( final Throwable throwable ) | ||||
{ | { | ||||
throw new AntException( "Error contextualizing task " + task.getName() + " at " + | throw new AntException( "Error contextualizing task " + task.getName() + " at " + | ||||
@@ -205,7 +215,7 @@ public class DefaultTaskletEngine | |||||
{ | { | ||||
if( tasklet instanceof Initializable ) | if( tasklet instanceof Initializable ) | ||||
{ | { | ||||
try { ((Initializable)tasklet).init(); } | |||||
try { ((Initializable)tasklet).initialize(); } | |||||
catch( final Throwable throwable ) | catch( final Throwable throwable ) | ||||
{ | { | ||||
throw new AntException( "Error initializing task " + task.getName() + " at " + | throw new AntException( "Error initializing task " + task.getName() + " at " + | ||||
@@ -18,20 +18,20 @@ import java.util.zip.ZipFile; | |||||
import org.apache.ant.convert.engine.ConverterEngine; | import org.apache.ant.convert.engine.ConverterEngine; | ||||
import org.apache.ant.convert.engine.ConverterRegistry; | import org.apache.ant.convert.engine.ConverterRegistry; | ||||
import org.apache.ant.convert.engine.DefaultConverterInfo; | import org.apache.ant.convert.engine.DefaultConverterInfo; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.ComponentManagerException; | |||||
import org.apache.avalon.Composer; | |||||
import org.apache.avalon.Configuration; | |||||
import org.apache.avalon.ConfigurationException; | |||||
import org.apache.avalon.camelot.AbstractZipDeployer; | |||||
import org.apache.avalon.camelot.DefaultLocator; | |||||
import org.apache.avalon.camelot.DefaultLocatorRegistry; | |||||
import org.apache.avalon.camelot.DeploymentException; | |||||
import org.apache.avalon.camelot.DeployerUtil; | |||||
import org.apache.avalon.camelot.Loader; | |||||
import org.apache.avalon.camelot.LocatorRegistry; | |||||
import org.apache.avalon.camelot.RegistryException; | |||||
import org.apache.avalon.framework.component.Component; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.component.ComponentException; | |||||
import org.apache.avalon.framework.component.Composable; | |||||
import org.apache.avalon.framework.configuration.Configuration; | |||||
import org.apache.avalon.framework.configuration.ConfigurationException; | |||||
import org.apache.avalon.framework.camelot.AbstractDeployer; | |||||
import org.apache.avalon.framework.camelot.DefaultLocator; | |||||
import org.apache.avalon.framework.camelot.DefaultRegistry; | |||||
import org.apache.avalon.framework.camelot.DeploymentException; | |||||
import org.apache.avalon.framework.camelot.DeployerUtil; | |||||
import org.apache.avalon.framework.camelot.Loader; | |||||
import org.apache.avalon.framework.camelot.Registry; | |||||
import org.apache.avalon.framework.camelot.RegistryException; | |||||
import org.apache.log.Logger; | import org.apache.log.Logger; | ||||
/** | /** | ||||
@@ -40,14 +40,14 @@ import org.apache.log.Logger; | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | ||||
*/ | */ | ||||
public class DefaultTskDeployer | public class DefaultTskDeployer | ||||
extends AbstractZipDeployer | |||||
implements Composer, TskDeployer | |||||
extends AbstractDeployer | |||||
implements Composable, TskDeployer | |||||
{ | { | ||||
protected final static String TSKDEF_FILE = "TASK-LIB/taskdefs.xml"; | protected final static String TSKDEF_FILE = "TASK-LIB/taskdefs.xml"; | ||||
protected LocatorRegistry m_dataTypeRegistry; | |||||
protected LocatorRegistry m_taskletRegistry; | |||||
protected LocatorRegistry m_converterRegistry; | |||||
protected Registry m_dataTypeRegistry; | |||||
protected Registry m_taskletRegistry; | |||||
protected Registry m_converterRegistry; | |||||
protected ConverterRegistry m_converterInfoRegistry; | protected ConverterRegistry m_converterInfoRegistry; | ||||
/** | /** | ||||
@@ -64,10 +64,10 @@ public class DefaultTskDeployer | |||||
* Retrieve relevent services needed to deploy. | * Retrieve relevent services needed to deploy. | ||||
* | * | ||||
* @param componentManager the ComponentManager | * @param componentManager the ComponentManager | ||||
* @exception ComponentManagerException if an error occurs | |||||
* @exception ComponentException if an error occurs | |||||
*/ | */ | ||||
public void compose( final ComponentManager componentManager ) | public void compose( final ComponentManager componentManager ) | ||||
throws ComponentManagerException | |||||
throws ComponentException | |||||
{ | { | ||||
final TaskletEngine taskletEngine = (TaskletEngine)componentManager. | final TaskletEngine taskletEngine = (TaskletEngine)componentManager. | ||||
lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); | lookup( "org.apache.ant.tasklet.engine.TaskletEngine" ); | ||||
@@ -86,6 +86,37 @@ public class DefaultTskDeployer | |||||
m_dataTypeRegistry = dataTypeEngine.getRegistry(); | m_dataTypeRegistry = dataTypeEngine.getRegistry(); | ||||
} | } | ||||
/** | |||||
* Deploy a file. | |||||
* Eventually this should be cached for performance reasons. | |||||
* | |||||
* @param location the location | |||||
* @param file the file | |||||
* @exception DeploymentException if an error occurs | |||||
*/ | |||||
protected void deployFromFile( final String location, final File file ) | |||||
throws DeploymentException | |||||
{ | |||||
final ZipFile zipFile = DeployerUtil.getZipFileFor( file ); | |||||
URL url = null; | |||||
try | |||||
{ | |||||
try { url = file.toURL(); } | |||||
catch( final MalformedURLException mue ) | |||||
{ | |||||
throw new DeploymentException( "Unable to form url", mue ); | |||||
} | |||||
loadResources( zipFile, location, url ); | |||||
} | |||||
finally | |||||
{ | |||||
try { zipFile.close(); } | |||||
catch( final IOException ioe ) {} | |||||
} | |||||
} | |||||
protected void loadResources( final ZipFile zipFile, final String location, final URL url ) | protected void loadResources( final ZipFile zipFile, final String location, final URL url ) | ||||
throws DeploymentException | throws DeploymentException | ||||
{ | { | ||||
@@ -93,25 +124,22 @@ public class DefaultTskDeployer | |||||
try | try | ||||
{ | { | ||||
final Iterator tasks = taskdefs.getChildren( "task" ); | |||||
while( tasks.hasNext() ) | |||||
final Configuration[] tasks = taskdefs.getChildren( "task" ); | |||||
for( int i = 0; i < tasks.length; i++ ) | |||||
{ | { | ||||
final Configuration task = (Configuration)tasks.next(); | |||||
handleTasklet( task, url ); | |||||
handleTasklet( tasks[ i ], url ); | |||||
} | } | ||||
final Iterator converters = taskdefs.getChildren( "converter" ); | |||||
while( converters.hasNext() ) | |||||
final Configuration[] converters = taskdefs.getChildren( "converter" ); | |||||
for( int i = 0; i < converters.length; i++ ) | |||||
{ | { | ||||
final Configuration converter = (Configuration)converters.next(); | |||||
handleConverter( converter, url ); | |||||
handleConverter( converters[ i ], url ); | |||||
} | } | ||||
final Iterator datatypes = taskdefs.getChildren( "datatype" ); | |||||
while( datatypes.hasNext() ) | |||||
final Configuration[] datatypes = taskdefs.getChildren( "datatype" ); | |||||
for( int i = 0; i < datatypes.length; i++ ) | |||||
{ | { | ||||
final Configuration datatype = (Configuration)datatypes.next(); | |||||
handleDataType( datatype, url ); | |||||
handleDataType( datatypes[ i ], url ); | |||||
} | } | ||||
} | } | ||||
catch( final ConfigurationException ce ) | catch( final ConfigurationException ce ) | ||||
@@ -129,13 +157,12 @@ public class DefaultTskDeployer | |||||
try | try | ||||
{ | { | ||||
final Iterator converters = taskdefs.getChildren( "converter" ); | |||||
while( converters.hasNext() ) | |||||
final Configuration[] converters = taskdefs.getChildren( "converter" ); | |||||
for( int i = 0; i < converters.length; i++ ) | |||||
{ | { | ||||
final Configuration converter = (Configuration)converters.next(); | |||||
if( converter.getAttribute( "classname" ).equals( name ) ) | |||||
if( converters[ i ].getAttribute( "classname" ).equals( name ) ) | |||||
{ | { | ||||
handleConverter( converter, url ); | |||||
handleConverter( converters[ i ], url ); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -156,13 +183,12 @@ public class DefaultTskDeployer | |||||
try | try | ||||
{ | { | ||||
final Iterator datatypes = datatypedefs.getChildren( "datatype" ); | |||||
while( datatypes.hasNext() ) | |||||
final Configuration[] datatypes = datatypedefs.getChildren( "datatype" ); | |||||
for( int i = 0; i < datatypes.length; i++ ) | |||||
{ | { | ||||
final Configuration datatype = (Configuration)datatypes.next(); | |||||
if( datatype.getAttribute( "name" ).equals( name ) ) | |||||
if( datatypes[ i ].getAttribute( "name" ).equals( name ) ) | |||||
{ | { | ||||
handleDataType( datatype, url ); | |||||
handleDataType( datatypes[ i ], url ); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -182,13 +208,12 @@ public class DefaultTskDeployer | |||||
try | try | ||||
{ | { | ||||
final Iterator tasks = taskdefs.getChildren( "task" ); | |||||
while( tasks.hasNext() ) | |||||
final Configuration[] tasks = taskdefs.getChildren( "task" ); | |||||
for( int i = 0; i < tasks.length; i++ ) | |||||
{ | { | ||||
final Configuration task = (Configuration)tasks.next(); | |||||
if( task.getAttribute( "name" ).equals( name ) ) | |||||
if( tasks[ i ].getAttribute( "name" ).equals( name ) ) | |||||
{ | { | ||||
handleTasklet( task, url ); | |||||
handleTasklet( tasks[ i ], url ); | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -226,7 +251,7 @@ public class DefaultTskDeployer | |||||
re ); | re ); | ||||
} | } | ||||
m_logger.debug( "Registered converter " + name + " that converts from " + | |||||
getLogger().debug( "Registered converter " + name + " that converts from " + | |||||
source + " to " + destination ); | source + " to " + destination ); | ||||
} | } | ||||
@@ -245,7 +270,7 @@ public class DefaultTskDeployer | |||||
re ); | re ); | ||||
} | } | ||||
m_logger.debug( "Registered tasklet " + name + " as " + classname ); | |||||
getLogger().debug( "Registered tasklet " + name + " as " + classname ); | |||||
} | } | ||||
protected void handleDataType( final Configuration datatype, final URL url ) | protected void handleDataType( final Configuration datatype, final URL url ) | ||||
@@ -263,6 +288,6 @@ public class DefaultTskDeployer | |||||
re ); | re ); | ||||
} | } | ||||
m_logger.debug( "Registered datatype " + name + " as " + classname ); | |||||
getLogger().debug( "Registered datatype " + name + " as " + classname ); | |||||
} | } | ||||
} | } |
@@ -8,14 +8,14 @@ | |||||
package org.apache.ant.tasklet.engine; | package org.apache.ant.tasklet.engine; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.ant.configuration.Configuration; | |||||
import org.apache.ant.convert.engine.ConverterEngine; | import org.apache.ant.convert.engine.ConverterEngine; | ||||
import org.apache.ant.tasklet.engine.DataTypeEngine; | import org.apache.ant.tasklet.engine.DataTypeEngine; | ||||
import org.apache.ant.tasklet.TaskletContext; | import org.apache.ant.tasklet.TaskletContext; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.ComponentManager; | |||||
import org.apache.avalon.Loggable; | |||||
import org.apache.avalon.camelot.LocatorRegistry; | |||||
import org.apache.avalon.framework.configuration.Configuration; | |||||
import org.apache.avalon.framework.component.Component; | |||||
import org.apache.avalon.framework.component.ComponentManager; | |||||
import org.apache.avalon.framework.logger.Loggable; | |||||
import org.apache.avalon.framework.camelot.Registry; | |||||
import org.apache.log.Logger; | import org.apache.log.Logger; | ||||
/** | /** | ||||
@@ -38,7 +38,7 @@ public interface TaskletEngine | |||||
* | * | ||||
* @return the LocatorRegistry | * @return the LocatorRegistry | ||||
*/ | */ | ||||
LocatorRegistry getRegistry(); | |||||
Registry getRegistry(); | |||||
/** | /** | ||||
* Retrieve converter engine. | * Retrieve converter engine. | ||||
@@ -8,9 +8,9 @@ | |||||
package org.apache.ant.tasklet.engine; | package org.apache.ant.tasklet.engine; | ||||
import java.net.URL; | import java.net.URL; | ||||
import org.apache.avalon.Loggable; | |||||
import org.apache.avalon.camelot.Deployer; | |||||
import org.apache.avalon.camelot.DeploymentException; | |||||
import org.apache.avalon.framework.logger.Loggable; | |||||
import org.apache.avalon.framework.camelot.Deployer; | |||||
import org.apache.avalon.framework.camelot.DeploymentException; | |||||
import org.apache.log.Logger; | import org.apache.log.Logger; | ||||
/** | /** | ||||
@@ -8,10 +8,11 @@ | |||||
package org.apache.ant.util; | package org.apache.ant.util; | ||||
import org.apache.ant.AntException; | import org.apache.ant.AntException; | ||||
import org.apache.avalon.Component; | |||||
import org.apache.avalon.Context; | |||||
import org.apache.avalon.util.PropertyException; | |||||
import org.apache.avalon.util.PropertyUtil; | |||||
import org.apache.avalon.framework.component.Component; | |||||
import org.apache.avalon.framework.context.Context; | |||||
import org.apache.avalon.framework.context.ContextException; | |||||
import org.apache.avalon.excalibur.property.PropertyException; | |||||
import org.apache.avalon.excalibur.property.PropertyUtil; | |||||
/** | /** | ||||
* Class representing a condition. | * Class representing a condition. | ||||
@@ -21,8 +22,8 @@ import org.apache.avalon.util.PropertyUtil; | |||||
public class Condition | public class Condition | ||||
implements Component | implements Component | ||||
{ | { | ||||
protected String m_condition; | |||||
protected boolean m_isIfCondition; | |||||
private String m_condition; | |||||
private boolean m_isIfCondition; | |||||
public Condition( final boolean isIfCondition, final String condition ) | public Condition( final boolean isIfCondition, final String condition ) | ||||
{ | { | ||||
@@ -42,29 +43,37 @@ public class Condition | |||||
public boolean evaluate( final Context context ) | public boolean evaluate( final Context context ) | ||||
{ | { | ||||
boolean result = false; | |||||
try | try | ||||
{ | { | ||||
final Object resolved = | final Object resolved = | ||||
PropertyUtil.resolveProperty( m_condition, context, false ); | |||||
boolean result = false; | |||||
PropertyUtil.resolveProperty( getCondition(), context, false ); | |||||
if( null != resolved ) | if( null != resolved ) | ||||
{ | { | ||||
result = ( null != context.get( resolved ) ); | |||||
} | |||||
if( !m_isIfCondition ) | |||||
{ | |||||
result = !result; | |||||
final Object object = context.get( resolved ); | |||||
//TODO: Do more than just check for presence???????????? | |||||
//true as object present | |||||
result = true; | |||||
} | } | ||||
return result; | |||||
} | |||||
catch( final ContextException ce ) | |||||
{ | |||||
result = false; | |||||
} | } | ||||
catch( final PropertyException pe ) | catch( final PropertyException pe ) | ||||
{ | { | ||||
throw new AntException( "Error resolving " + m_condition, pe ); | throw new AntException( "Error resolving " + m_condition, pe ); | ||||
} | } | ||||
if( !m_isIfCondition ) | |||||
{ | |||||
result = !result; | |||||
} | |||||
return result; | |||||
} | } | ||||
} | } | ||||
@@ -1,28 +0,0 @@ | |||||
/* | |||||
* 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.ant.util; | |||||
import org.apache.ant.tasklet.DataType; | |||||
/** | |||||
* Interface for ItemSet. | |||||
* An item set contains a number of items. Example item sets include | |||||
* PatternSets, FileSets, FilterSets etc. | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
*/ | |||||
public interface ItemSet | |||||
extends DataType | |||||
{ | |||||
/** | |||||
* Returns an array containing the items(s) contained within set. | |||||
* | |||||
* Question: should ItemSet be context sensitive???? | |||||
*/ | |||||
Object[] getItems( /* Context context??? */ ); | |||||
} |
@@ -1,35 +0,0 @@ | |||||
/* | |||||
* 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.ant.util; | |||||
import org.apache.ant.tasklet.DataType; | |||||
/** | |||||
* Interface for Mappers. | |||||
* Mappers are responsible for mapping source items to targets items. | |||||
* Example mappers will map source files to destination files | |||||
* (ie A.java to A.class). | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> | |||||
*/ | |||||
public interface Mapper | |||||
extends DataType | |||||
{ | |||||
/** | |||||
* Returns an array containing the target items(s) for the | |||||
* given source file. | |||||
* | |||||
* <p>if the given rule doesn't apply to the input item, | |||||
* implementation must return null. Scanner will then | |||||
* omit the item in question.</p> | |||||
* | |||||
* @param item the item to be mapped | |||||
*/ | |||||
Object[] mapItem( Object item ); | |||||
} |
@@ -1,20 +0,0 @@ | |||||
/* | |||||
* 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.ant.util; | |||||
import org.apache.avalon.Component; | |||||
/** | |||||
* Interface for Scanners. | |||||
* | |||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||||
*/ | |||||
public interface Scanner | |||||
extends Component | |||||
{ | |||||
} |