conor 02/02/11 07:42:19
Modified: proposal/mutant ant1compat.xml build.xml
proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib
AntLibManager.java AntLibrary.java
DynamicLibrary.java
proposal/mutant/src/java/antcore/org/apache/ant/antcore/config
AntConfig.java
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution
BuildEventSupport.java ComponentManager.java
ExecutionContext.java ExecutionManager.java
Frame.java ImportInfo.java Reflector.java
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant
Project.java
proposal/mutant/src/java/antlibs/system antlib.xml
proposal/mutant/src/java/cli/org/apache/ant/cli
Commandline.java DefaultLogger.java
proposal/mutant/src/java/common/org/apache/ant/common/antlib
AntLibFactory.java StandardLibFactory.java
proposal/mutant/src/java/common/org/apache/ant/common/event
BuildEvent.java
proposal/mutant/src/java/common/org/apache/ant/common/service
ComponentService.java
Added: proposal/mutant script.xml
proposal/mutant/lib/antlib/script readme.txt
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution
DeferredSetter.java Setter.java
proposal/mutant/src/java/antlibs/script antlib.xml
proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script
ScriptBase.java ScriptDef.java ScriptFactory.java
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system
Ant.java AntBase.java AntCall.java
FileConverter.java Import.java LibPath.java
LoadLib.java PrimitiveConverter.java Taskdef.java
Typedef.java URLConverter.java
proposal/mutant/src/java/common/org/apache/ant/common/antlib
DeferredTask.java
proposal/mutant/src/java/common/org/apache/ant/common/event
MessageLevel.java
Removed:
proposal/mutant/src/java/antlibs/system/code/org/apache/ant/antlib/system
Ant.java AntBase.java AntCall.java
FileConverter.java Import.java LibPath.java
LoadLib.java PrimitiveConverter.java Taskdef.java
Typedef.java URLConverter.java
proposal/mutant/src/java/common/org/apache/ant/common/util
MessageLevel.java
Log:
Add ability to define tasks using BSF scripts - experimental
Revision Changes Path
1.7 +1 -1 jakarta-ant/proposal/mutant/ant1compat.xml
Index: ant1compat.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/mutant/ant1compat.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -u -r1.6 -r1.7
--- ant1compat.xml 7 Feb 2002 14:48:43 -0000 1.6
+++ ant1compat.xml 11 Feb 2002 15:42:17 -0000 1.7
@@ -59,7 +59,7 @@
<include name="org/apache/tools/ant/AntClassLoader.java"/>
<include name="org/apache/tools/ant/BuildEvent.java"/>
<include name="org/apache/tools/ant/BuildListener.java"/>
- <patternset refid="deprecated"/>
+ <!-- <patternset refid="deprecated"/> -->
<patternset refid="toohard"/>
<patternset refid="converted"/>
</fileset>
1.12 +5 -4 jakarta-ant/proposal/mutant/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/mutant/build.xml,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -u -r1.11 -r1.12
--- build.xml 8 Feb 2002 13:04:45 -0000 1.11
+++ build.xml 11 Feb 2002 15:42:17 -0000 1.12
@@ -38,8 +38,8 @@
<available file="../checkstyle" property="checkstyle.available"/>
<mkdir dir="${bin.dir}"/>
<mkdir dir="${distlib.dir}"/>
- <copy todir="${distlib.dir}">
- <fileset dir="${lib.dir}"/>
+ <copy todir="${distlib.dir}/parser">
+ <fileset dir="${lib.dir}/parser"/>
</copy>
</target>
@@ -130,6 +130,7 @@
<antcall target="build-lib" inheritall="false">
<param name="libset" value="system"/>
</antcall>
+ <ant antfile="script.xml" inheritAll="false"/>
</target>
<target name="build-lib">
@@ -139,10 +140,10 @@
<path refid="classpath.common"/>
<pathelement location="${distlib.dir}/common/common.jar"/>
</path>
- <depend destdir="${bin.dir}/antlibs/${libset}"
srcdir="${java.dir}/antlibs/${libset}/code">
+ <depend destdir="${bin.dir}/antlibs/${libset}"
srcdir="${java.dir}/antlibs/${libset}">
<classpath refid="classpath.antlibs"/>
</depend>
- <javac destdir="${bin.dir}/antlibs/${libset}"
srcdir="${java.dir}/antlibs/${libset}/code" debug="${debug}">
+ <javac destdir="${bin.dir}/antlibs/${libset}"
srcdir="${java.dir}/antlibs/${libset}" debug="${debug}">
<classpath refid="classpath.antlibs"/>
</javac>
<jar basedir="${bin.dir}/antlibs/${libset}"
jarfile="${distlib.dir}/antlibs/${libset}.tsk">
1.1 jakarta-ant/proposal/mutant/script.xml
Index: script.xml
===================================================================
<project default="build" name="Ant2 script tasks">
<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="java.dir" value="${src.dir}/java"/>
<property name="bin.dir" value="bin"/>
<property name="dist.dir" value="dist"/>
<property name="javadocs.dir" value="${dist.dir}/javadocs"/>
<property name="distlib.dir" value="${dist.dir}/lib"/>
<property name="debug" value="true"/>
<property name="ant.package" value="org/apache/tools/ant"/>
<property name="optional.package" value="${ant.package}/taskdefs/optional"/>
<property name="optional.type.package"
value="${ant.package}/types/optional"/>
<property name="util.package" value="${ant.package}/util"/>
<property name="regexp.package" value="${util.package}/regexp"/>
<path id="classpath.script">
<pathelement location="${distlib.dir}/init.jar"/>
<fileset dir="${lib.dir}/antlib/script" includes="*.jar"/>
<pathelement location="${distlib.dir}/common/common.jar"/>
</path>
<target name="check_bsf">
<available property="bsf.present"
classname="com.ibm.bsf.BSFManager"
classpathref="classpath.script" />
</target>
<target name="nobsf" unless="bsf.present">
<echo message="You must provide the bsf.jar library in the
${lib.dir}/antlib/script directory"/>
</target>
<target name="build" depends="check_bsf, nobsf" if="bsf.present">
<mkdir dir="${bin.dir}/antlibs/script"/>
<mkdir dir="${distlib.dir}/antlibs"/>
<depend destdir="${bin.dir}/antlibs/script"
srcdir="${java.dir}/antlibs/script">
<classpath refid="classpath.script"/>
</depend>
<javac destdir="${bin.dir}/antlibs/script"
srcdir="${java.dir}/antlibs/script" debug="${debug}">
<classpath refid="classpath.script"/>
</javac>
<jar basedir="${bin.dir}/antlibs/script"
jarfile="${distlib.dir}/antlibs/script.tsk">
<metainf dir="${java.dir}/antlibs/script"
includes="antlib.xml"/>
</jar>
</target>
</project>
1.1 jakarta-ant/proposal/mutant/lib/antlib/script/readme.txt
Index: readme.txt
===================================================================
Please any jars in here which should be used when building the script antlib
1.3 +36 -6
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibManager.java
Index: AntLibManager.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -u -r1.2 -r1.3
--- AntLibManager.java 5 Feb 2002 11:49:04 -0000 1.2
+++ AntLibManager.java 11 Feb 2002 15:42:17 -0000 1.3
@@ -149,11 +149,12 @@
* @param librarySpecs the loaded specifications of the Ant libraries
* @param initConfig the Ant initialization configuration
* @param libraries the collection of libraries already configured
+ * @param libPathsMap a map of lists of library patsh fro each library
* @exception ExecutionException if a library cannot be configured from
* the given specification
*/
public void configLibraries(InitConfig initConfig, Map librarySpecs,
- Map libraries)
+ Map libraries, Map libPathsMap)
throws ExecutionException {
// check if any already defined
@@ -174,7 +175,7 @@
String libraryId = (String)i.next();
if (!libraries.containsKey(libraryId)) {
configLibrary(initConfig, librarySpecs, libraryId,
- configuring, libraries);
+ configuring, libraries, libPathsMap);
}
}
}
@@ -189,7 +190,7 @@
* @exception MalformedURLException if the library's location cannot be
* formed
*/
- public void loadLib(Map librarySpecs, String libLocationString)
+ public void loadLibs(Map librarySpecs, String libLocationString)
throws ExecutionException, MalformedURLException {
File libLocation = new File(libLocationString);
@@ -213,6 +214,24 @@
}
/**
+ * add a library path to the given library
+ *
+ * @param antLibrary the library to which the path is to be added
+ * @param path the path to be added
+ * @exception ExecutionException if remote paths are not allowed by
+ * configuration
+ */
+ public void addLibPath(AntLibrary antLibrary, URL path)
+ throws ExecutionException {
+ if (!path.getProtocol().equals("file")
+ && !remoteAllowed) {
+ throw new ExecutionException("Remote libpaths are not"
+ + " allowed: " + path);
+ }
+ antLibrary.addLibraryURL(path);
+ }
+
+ /**
* Configure a library from a specification and the Ant init config.
*
* @param initConfig Ant's init config passed in from the front end.
@@ -223,12 +242,13 @@
* dependencies.
* @param libraries the collection of libraries which have already been
* configured
+ * @param libPathsMap a map of lists of library patsh fro each library
* @exception ExecutionException if the library cannot be configured.
*/
private void configLibrary(InitConfig initConfig, Map librarySpecs,
String libraryId,
CircularDependencyChecker configuring,
- Map libraries)
+ Map libraries, Map libPathsMap)
throws ExecutionException {
try {
@@ -245,7 +265,7 @@
+ libraryId + " depends");
}
configLibrary(initConfig, librarySpecs, extendsId,
- configuring, libraries);
+ configuring, libraries, libPathsMap);
}
}
@@ -265,8 +285,8 @@
urlsList.add(initConfig.getToolsJarURL());
}
- URL[] parserURLs = initConfig.getParserURLs();
if (librarySpec.usesAntXML()) {
+ URL[] parserURLs = initConfig.getParserURLs();
for (int i = 0; i < parserURLs.length; ++i) {
urlsList.add(parserURLs[i]);
}
@@ -282,11 +302,21 @@
}
antLibrary.setParentLoader(initConfig.getCommonLoader());
libraries.put(libraryId, antLibrary);
+
+ List libPaths = (List)libPathsMap.get(libraryId);
+ if (libPaths != null) {
+ for (Iterator j = libPaths.iterator(); j.hasNext(); ) {
+ URL pathURL = (URL)j.next();
+ addLibPath(antLibrary, pathURL);
+ }
+ }
+
configuring.leaveNode(libraryId);
} catch (CircularDependencyException e) {
throw new ExecutionException(e);
}
}
+
/**
* Read an Ant library definition from a URL
1.6 +0 -3
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibrary.java
Index: AntLibrary.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/AntLibrary.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -u -r1.5 -r1.6
--- AntLibrary.java 8 Feb 2002 13:04:45 -0000 1.5
+++ AntLibrary.java 11 Feb 2002 15:42:17 -0000 1.6
@@ -69,9 +69,6 @@
* @created 14 January 2002
*/
public class AntLibrary implements ComponentLibrary {
- /** A counter for generating unique ids */
- private static int implicitLibCount = 0;
-
/**
* This is the globally unique name of this library. It uses the same
* conventions as the Java package space - i.e. reverse order DNS names
1.2 +2 -1
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/DynamicLibrary.java
Index: DynamicLibrary.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/antlib/DynamicLibrary.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -u -r1.1 -r1.2
--- DynamicLibrary.java 8 Feb 2002 13:04:45 -0000 1.1
+++ DynamicLibrary.java 11 Feb 2002 15:42:17 -0000 1.2
@@ -97,7 +97,8 @@
public DynamicLibrary(AntLibFactory factory, ClassLoader loader) {
int dynamicId = 0;
synchronized (DynamicLibrary.class) {
- dynamicId = dynamicIdCounter++;
+ dynamicId = dynamicIdCounter;
+ dynamicIdCounter++;
}
this.libraryId = DYNAMIC_LIB_PREFIX + dynamicId;
this.loader = loader;
1.6 +12 -0
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/config/AntConfig.java
Index: AntConfig.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/config/AntConfig.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -u -r1.5 -r1.6
--- AntConfig.java 6 Feb 2002 12:52:57 -0000 1.5
+++ AntConfig.java 11 Feb 2002 15:42:18 -0000 1.6
@@ -142,6 +142,18 @@
return libraryPathList;
}
+
+ /**
+ * Get the map of library paths. This map contains a collection of List
+ * instances, indexed by the libraryIds. Each list is a set of
+ * additional classpath entries for the given library
+ *
+ * @return the library paths map
+ */
+ public Map getLibraryPathsMap() {
+ return libPaths;
+ }
+
/**
* Gets the libraryIds of the AntConfig
*
1.3 +3 -3
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/BuildEventSupport.java
Index: BuildEventSupport.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/BuildEventSupport.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -u -r1.2 -r1.3
--- BuildEventSupport.java 5 Feb 2002 11:49:04 -0000 1.2
+++ BuildEventSupport.java 11 Feb 2002 15:42:18 -0000 1.3
@@ -191,13 +191,13 @@
/**
* Send a message event
*
- * @param element the build element with which the event is associated
+ * @param source the build element with which the event is associated
* @param message the message to be sent
* @param priority the priority of the message
*/
- public void fireMessageLogged(ModelElement element,
+ public void fireMessageLogged(Object source,
String message, int priority) {
- BuildEvent event = new BuildEvent(element, message, priority);
+ BuildEvent event = new BuildEvent(source, message, priority);
for (Iterator i = listeners.iterator(); i.hasNext(); ) {
BuildListener listener = (BuildListener)i.next();
listener.messageLogged(event);
1.4 +95 -24
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ComponentManager.java
Index: ComponentManager.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ComponentManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -u -r1.3 -r1.4
--- ComponentManager.java 8 Feb 2002 13:04:45 -0000 1.3
+++ ComponentManager.java 11 Feb 2002 15:42:18 -0000 1.4
@@ -53,9 +53,14 @@
*/
package org.apache.ant.antcore.execution;
import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.ant.antcore.antlib.AntLibDefinition;
import org.apache.ant.antcore.antlib.AntLibManager;
import org.apache.ant.antcore.antlib.AntLibrary;
@@ -64,6 +69,7 @@
import org.apache.ant.common.antlib.AntLibFactory;
import org.apache.ant.common.antlib.Converter;
import org.apache.ant.common.antlib.StandardLibFactory;
+import org.apache.ant.common.event.MessageLevel;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.ExecutionException;
@@ -84,6 +90,9 @@
*/
private Map converters = new HashMap();
+ /** This is the set of libraries whose converters have been loaded */
+ private Set loadedConverters = new HashSet();
+
/** The factory objects for each library, indexed by the library Id */
private Map libFactories = new HashMap();
@@ -106,17 +115,26 @@
private Map definitions = new HashMap();
/**
+ * This map stores a list of additional paths for each library indexed
+ * by the libraryId
+ */
+ private Map libPathsMap;
+
+ /**
* Constructor
*
* @param frame the frame containing this context
* @param allowRemoteLibs true if remote libraries can be loaded though
* this service.
+ * @param configLibPaths the additional library paths specified in the
+ * configuration
*/
- protected ComponentManager(Frame frame,
- boolean allowRemoteLibs) {
+ protected ComponentManager(Frame frame, boolean allowRemoteLibs,
+ Map configLibPaths) {
this.frame = frame;
libManager = new AntLibManager(allowRemoteLibs);
dynamicLibraries = new HashMap();
+ libPathsMap = new HashMap(configLibPaths);
}
/**
@@ -132,9 +150,9 @@
throws ExecutionException {
try {
Map librarySpecs = new HashMap();
- libManager.loadLib(librarySpecs, libLocation);
+ libManager.loadLibs(librarySpecs, libLocation);
libManager.configLibraries(frame.getInitConfig(), librarySpecs,
- antLibraries);
+ antLibraries, libPathsMap);
if (importAll) {
Iterator i = librarySpecs.keySet().iterator();
@@ -184,6 +202,72 @@
}
/**
+ * Add a library path for the given library
+ *
+ * @param libraryId the unique id of the library for which an additional
+ * path is being defined
+ * @param libPath the library path (usually a jar)
+ * @exception ExecutionException if the path cannot be specified
+ */
+ public void addLibPath(String libraryId, URL libPath)
+ throws ExecutionException {
+ List libPaths = (List)libPathsMap.get(libraryId);
+ if (libPaths == null) {
+ libPaths = new ArrayList();
+ libPathsMap.put(libraryId, libPaths);
+ }
+ libPaths.add(libPath);
+
+ // If this library already exists give it the new path now
+ AntLibrary library = (AntLibrary)antLibraries.get(libraryId);
+ if (library != null) {
+ libManager.addLibPath(library, libPath);
+ }
+ }
+
+ /**
+ * Import a complete library into the current execution frame
+ *
+ * @param libraryId The id of the library to be imported
+ * @exception ExecutionException if the library cannot be imported
+ */
+ public void importLibrary(String libraryId) throws ExecutionException {
+ AntLibrary library = (AntLibrary)antLibraries.get(libraryId);
+ if (library == null) {
+ throw new ExecutionException("Unable to import library " +
libraryId
+ + " as it has not been loaded");
+ }
+ for (Iterator i = library.getDefinitionNames(); i.hasNext(); ) {
+ String defName = (String)i.next();
+ importLibraryDef(library, defName, null);
+ }
+ addLibraryConverters(library);
+ }
+
+ /**
+ * Import a single component from a library, optionally aliasing it to a
+ * new name
+ *
+ * @param libraryId the unique id of the library from which the
+ * component is being imported
+ * @param defName the name of the component within its library
+ * @param alias the name under which this component will be used in the
+ * build scripts. If this is null, the components default name is
+ * used.
+ * @exception ExecutionException if the component cannot be imported
+ */
+ public void importComponent(String libraryId, String defName,
+ String alias) throws ExecutionException {
+ AntLibrary library = (AntLibrary)antLibraries.get(libraryId);
+ if (library == null) {
+ throw new ExecutionException("Unable to import component from "
+ + "library \"" + libraryId + "\" as it has not been
loaded");
+ }
+ importLibraryDef(library, defName, alias);
+ addLibraryConverters(library);
+ }
+
+ /**
* Set the standard libraries (i.e. those which are independent of the
* build files) to be used in this component manager
*
@@ -253,25 +337,6 @@
}
/**
- * Import a complete library into this frame
- *
- * @param libraryId The id of the library to be imported
- * @exception ExecutionException if the library cannot be imported
- */
- protected void importLibrary(String libraryId) throws ExecutionException
{
- AntLibrary library = (AntLibrary)antLibraries.get(libraryId);
- if (library == null) {
- throw new ExecutionException("Unable to import library " +
libraryId
- + " as it has not been loaded");
- }
- for (Iterator i = library.getDefinitionNames(); i.hasNext(); ) {
- String defName = (String)i.next();
- importLibraryDef(library, defName, null);
- }
- addLibraryConverters(library);
- }
-
- /**
* Import a single component from the given library
*
* @param library the library which provides the component
@@ -287,6 +352,9 @@
}
AntLibDefinition libDef = library.getDefinition(defName);
+ frame.log("Adding component <" + defName + "> as <" + label
+ + "> from library \"" + library.getLibraryId() + "\", class: "
+ + libDef.getClassName(), MessageLevel.MSG_DEBUG);
definitions.put(label, new ImportInfo(library, libDef));
}
@@ -313,6 +381,7 @@
importLibraryDef(dynamicLibrary, componentName, null);
}
+
/**
* Add the converters from the given library to those managed by this
* frame.
@@ -323,7 +392,8 @@
*/
private void addLibraryConverters(AntLibrary library)
throws ExecutionException {
- if (!library.hasConverters()) {
+ if (!library.hasConverters()
+ || loadedConverters.contains(library.getLibraryId())) {
return;
}
@@ -351,6 +421,7 @@
converters.put(converterTypes[j], converter);
}
}
+ loadedConverters.add(library.getLibraryId());
} catch (ClassNotFoundException e) {
throw new ExecutionException("In Ant library \""
+ library.getLibraryId() + "\" converter class "
1.6 +5 -2
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionContext.java
Index: ExecutionContext.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionContext.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -u -r1.5 -r1.6
--- ExecutionContext.java 8 Feb 2002 13:04:45 -0000 1.5
+++ ExecutionContext.java 11 Feb 2002 15:42:18 -0000 1.6
@@ -137,9 +137,12 @@
* @param level the priority level of the message
*/
public void log(String message, int level) {
- ModelElement source = modelElement;
- if (modelElement == null) {
+ Object source = modelElement;
+ if (source == null) {
source = frame.getProject();
+ if (source == null) {
+ source = frame;
+ }
}
eventSupport.fireMessageLogged(source, message, level);
}
1.7 +31 -42
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionManager.java
Index: ExecutionManager.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ExecutionManager.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -u -r1.6 -r1.7
--- ExecutionManager.java 8 Feb 2002 13:04:45 -0000 1.6
+++ ExecutionManager.java 11 Feb 2002 15:42:18 -0000 1.7
@@ -59,7 +59,6 @@
import java.util.List;
import java.util.Map;
import org.apache.ant.antcore.antlib.AntLibManager;
-import org.apache.ant.antcore.antlib.AntLibrary;
import org.apache.ant.antcore.config.AntConfig;
import org.apache.ant.common.event.BuildListener;
import org.apache.ant.common.model.Project;
@@ -70,8 +69,8 @@
/**
* The ExecutionManager is used to manage the execution of a build. The
* Execution manager is responsible for loading the Ant task libraries,
- * creating Frames for each project that is part of the build and
- * then executing the tasks within those Execution Frames.
+ * creating Frames for each project that is part of the build and then
+ * executing the tasks within those Execution Frames.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 12 January 2002
@@ -112,7 +111,15 @@
throws ExecutionException {
this.config = config;
this.initConfig = initConfig;
+ }
+ /**
+ * Initialise the execution manager
+ *
+ * @exception ExecutionException if the standard ant libraries cannot be
+ * loaded
+ */
+ public void init() throws ExecutionException {
Map librarySpecs = new HashMap(10);
try {
// start by loading the task libraries
@@ -123,20 +130,19 @@
= new AntLibManager(config.isRemoteLibAllowed());
libManager.addAntLibraries(librarySpecs, standardLibsURL);
- libManager.configLibraries(initConfig, librarySpecs,
antLibraries);
+ libManager.configLibraries(initConfig, librarySpecs,
antLibraries,
+ config.getLibraryPathsMap());
librarySpecs.clear();
// add any additional libraries.
for (Iterator i = config.getLibraryLocations(); i.hasNext();
) {
// try file first
String libLocation = (String)i.next();
- libManager.loadLib(librarySpecs, libLocation);
+ libManager.loadLibs(librarySpecs, libLocation);
}
- libManager.configLibraries(initConfig, librarySpecs,
antLibraries);
-
- addConfigLibPaths();
+ libManager.configLibraries(initConfig, librarySpecs,
antLibraries,
+ config.getLibraryPathsMap());
- mainFrame = new Frame(antLibraries, initConfig, config);
} catch (MalformedURLException e) {
throw new ExecutionException("Unable to load Ant libraries", e);
}
@@ -156,6 +162,12 @@
// start by validating the project we have been given.
project.validate();
+ mainFrame = new Frame(antLibraries, initConfig, config);
+ for (Iterator j = eventSupport.getListeners(); j.hasNext(); ) {
+ BuildListener listener = (BuildListener)j.next();
+ mainFrame.addBuildListener(listener);
+ }
+
mainFrame.setProject(project);
mainFrame.setInitialProperties(commandProperties);
@@ -178,8 +190,10 @@
*/
public void addBuildListener(BuildListener listener) {
eventSupport.addBuildListener(listener);
+ if (mainFrame != null) {
mainFrame.addBuildListener(listener);
}
+ }
/**
* Remove a build listener from the execution
@@ -188,35 +202,10 @@
*/
public void removeBuildListener(BuildListener listener) {
eventSupport.removeBuildListener(listener);
+ if (mainFrame != null) {
mainFrame.removeBuildListener(listener);
}
-
- /**
- * Add the library paths from the AntConfig instance to the Ant
- * Libraries.
- *
- * @exception ExecutionException if remote libraries are not allowed.
- */
- private void addConfigLibPaths()
- throws ExecutionException {
- // now add any additional library Paths specified by the config
- for (Iterator i = config.getLibraryIds(); i.hasNext(); ) {
- String libraryId = (String)i.next();
- if (antLibraries.containsKey(libraryId)) {
- AntLibrary antLib
- = (AntLibrary)antLibraries.get(libraryId);
- List pathList = config.getLibraryPathList(libraryId);
- for (Iterator j = pathList.iterator(); j.hasNext(); ) {
- URL pathElementURL = (URL)j.next();
- if (!pathElementURL.getProtocol().equals("file")
- && !config.isRemoteLibAllowed()) {
- throw new ExecutionException("Remote libpaths are
not"
- + " allowed: " + pathElementURL);
- }
- antLib.addLibraryURL(pathElementURL);
- }
- }
- }
}
+
}
1.2 +61 -50
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
Index: Frame.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -u -r1.1 -r1.2
--- Frame.java 8 Feb 2002 13:04:45 -0000 1.1
+++ Frame.java 11 Feb 2002 15:42:18 -0000 1.2
@@ -63,30 +63,31 @@
import org.apache.ant.antcore.antlib.ComponentLibrary;
import org.apache.ant.antcore.config.AntConfig;
import org.apache.ant.common.antlib.AntLibFactory;
+import org.apache.ant.common.antlib.DeferredTask;
import org.apache.ant.common.antlib.ExecutionComponent;
import org.apache.ant.common.antlib.Task;
import org.apache.ant.common.antlib.TaskContainer;
import org.apache.ant.common.event.BuildListener;
+import org.apache.ant.common.event.MessageLevel;
import org.apache.ant.common.model.BuildElement;
import org.apache.ant.common.model.Project;
import org.apache.ant.common.model.Target;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.service.DataService;
-import org.apache.ant.common.service.FileService;
import org.apache.ant.common.service.EventService;
+import org.apache.ant.common.service.ExecService;
+import org.apache.ant.common.service.FileService;
import org.apache.ant.common.service.MagicProperties;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.ConfigException;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.common.util.FileUtils;
-import org.apache.ant.common.util.MessageLevel;
import org.apache.ant.init.InitConfig;
-import org.apache.ant.common.service.ExecService;
/**
- * An Frame maintains the state of a project during an execution.
- * The Frame contains the data values set by Ant tasks as they are
- * executed, including task definitions, property values, etc.
+ * An Frame maintains the state of a project during an execution. The Frame
+ * contains the data values set by Ant tasks as they are executed, including
+ * task definitions, property values, etc.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 14 January 2002
@@ -105,7 +106,7 @@
private Map referencedFrames = new HashMap();
/** Reflector objects used to configure Tasks from the Task models. */
- private Map reflectors = new HashMap();
+ private Map setters = new HashMap();
/**
* The context of this execution. This contains all data object's
@@ -202,7 +203,6 @@
= project.getReferencedProject(referenceName);
Frame referencedFrame = createFrame(referencedProject);
referencedFrames.put(referenceName, referencedFrame);
-
}
configureServices();
@@ -359,8 +359,8 @@
* Get a referenced frame by its reference name
*
* @param referenceName the name under which the frame was imported.
- * @return the Frame asscociated with the given reference name
- * or null if there is no such project.
+ * @return the Frame asscociated with the given reference name or null
+ * if there is no such project.
*/
protected Frame getReferencedFrame(String referenceName) {
return (Frame)referencedFrames.get(referenceName);
@@ -672,20 +672,26 @@
/**
- * Gets the reflector for the given class
+ * Gets the setter for the given class
*
* @param c the class for which the reflector is desired
* @return the reflector
*/
- private Reflector getReflector(Class c) {
- if (reflectors.containsKey(c)) {
- return (Reflector)reflectors.get(c);
- }
+ private Setter getSetter(Class c) {
+ if (setters.containsKey(c)) {
+ return (Setter)setters.get(c);
+ }
+ Setter setter = null;
+ if (DeferredTask.class.isAssignableFrom(c)) {
+ setter = new DeferredSetter();
+ } else {
ClassIntrospector introspector
= new ClassIntrospector(c, componentManager.getConverters());
- Reflector reflector = introspector.getReflector();
- reflectors.put(c, reflector);
- return reflector;
+ setter = introspector.getReflector();
+ }
+
+ setters.put(c, setter);
+ return setter;
}
@@ -759,8 +765,8 @@
private void configureServices() {
// create services and make them available in our services map
fileService = new CoreFileService(this);
- componentManager
- = new ComponentManager(this, config.isRemoteLibAllowed());
+ componentManager = new ComponentManager(this,
+ config.isRemoteLibAllowed(), config.getLibraryPathsMap());
dataService = new CoreDataService(this,
config.isUnsetPropertiesAllowed());
@@ -784,27 +790,27 @@
BuildElement model)
throws ExecutionException {
- Reflector reflector = getReflector(element.getClass());
+ Setter setter = getSetter(element.getClass());
// start by setting the attributes of this element
for (Iterator i = model.getAttributeNames(); i.hasNext(); ) {
String attributeName = (String)i.next();
String attributeValue = model.getAttributeValue(attributeName);
- if (!reflector.supportsAttribute(attributeName)) {
+ if (!setter.supportsAttribute(attributeName)) {
throw new ExecutionException(model.getType()
+ " does not support the \"" + attributeName
+ "\" attribute", model.getLocation());
}
- reflector.setAttribute(element, attributeName,
+ setter.setAttribute(element, attributeName,
dataService.replacePropertyRefs(attributeValue));
}
String modelText = model.getText().trim();
if (modelText.length() != 0) {
- if (!reflector.supportsText()) {
+ if (!setter.supportsText()) {
throw new ExecutionException(model.getType()
+ " does not support content", model.getLocation());
}
- reflector.addText(element,
+ setter.addText(element,
dataService.replacePropertyRefs(modelText));
}
@@ -817,7 +823,7 @@
if (element instanceof TaskContainer
&& info != null
&& info.getDefinitionType() == AntLibrary.TASKDEF
- && !reflector.supportsNestedElement(nestedElementName)) {
+ && !setter.supportsNestedElement(nestedElementName)) {
// it is a nested task
TaskContext nestedContext
= configureTask(nestedElementModel);
@@ -826,11 +832,11 @@
// method of executing tasks
container.addTask(nestedContext.getTask());
} else {
- if (reflector.supportsNestedAdder(nestedElementName)) {
- addNestedElement(factory, reflector, element,
+ if (setter.supportsNestedAdder(nestedElementName)) {
+ addNestedElement(factory, setter, element,
nestedElementModel);
- } else if
(reflector.supportsNestedCreator(nestedElementName)) {
- createNestedElement(factory, reflector, element,
+ } else if (setter.supportsNestedCreator(nestedElementName)) {
+ createNestedElement(factory, setter, element,
nestedElementModel);
} else {
throw new ExecutionException(model.getType()
@@ -846,7 +852,7 @@
/**
* Create a nested element for the given object according to the model.
*
- * @param reflector the reflector instance of the container object
+ * @param setter the Setter instance of the container object
* @param element the container object for which a nested element is
* required.
* @param model the build model for the nestd element
@@ -855,7 +861,7 @@
* @exception ExecutionException if the nested element cannot be
* created.
*/
- private void createNestedElement(AntLibFactory factory, Reflector
reflector,
+ private void createNestedElement(AntLibFactory factory, Setter setter,
Object element, BuildElement model)
throws ExecutionException {
log("The use of create methods is deprecated - class: "
@@ -864,7 +870,7 @@
String nestedElementName = model.getType();
try {
Object nestedElement
- = reflector.createElement(element, nestedElementName);
+ = setter.createElement(element, nestedElementName);
factory.registerCreatedElement(nestedElement);
if (nestedElement instanceof ExecutionComponent) {
ExecutionComponent component
@@ -891,7 +897,7 @@
/**
* Create and add a nested element
*
- * @param reflector The reflector instance for the container element
+ * @param setter The Setter instance for the container element
* @param element the container element in which the nested element will
* be created
* @param model the model of the nested element
@@ -899,12 +905,12 @@
* which the attribute is to be added.
* @exception ExecutionException if the nested element cannot be created
*/
- private void addNestedElement(AntLibFactory factory, Reflector reflector,
+ private void addNestedElement(AntLibFactory factory, Setter setter,
Object element, BuildElement model)
throws ExecutionException {
String nestedElementName = model.getType();
- Class nestedType = reflector.getType(nestedElementName);
+ Class nestedType = setter.getType(nestedElementName);
// is there a polymorph indicator - look in Ant aspects
String typeName = model.getAspectValue(ANT_ASPECT, "type");
@@ -947,7 +953,7 @@
model.getLocation());
}
- typeInstance = createTypeInstance(nestedType, factory, model);
+ typeInstance = createTypeInstance(nestedType, factory, model,
null);
}
// is the typeInstance compatible with the type expected
@@ -965,7 +971,7 @@
model.getLocation());
}
}
- reflector.addElement(element, nestedElementName, typeInstance);
+ setter.addElement(element, nestedElementName, typeInstance);
}
@@ -991,6 +997,7 @@
String className = taskDefInfo.getClassName();
ComponentLibrary componentLibrary
= taskDefInfo.getComponentLibrary();
+ String localName = taskDefInfo.getLocalName();
try {
ClassLoader taskClassLoader = componentLibrary.getClassLoader();
@@ -998,7 +1005,8 @@
= Class.forName(className, true, taskClassLoader);
AntLibFactory libFactory
= componentManager.getLibFactory(componentLibrary);
- Object element = libFactory.createTaskInstance(elementClass);
+ Object element
+ = libFactory.createTaskInstance(elementClass, localName);
Task task = null;
if (element instanceof Task) {
@@ -1064,6 +1072,7 @@
String className = typeDefInfo.getClassName();
ComponentLibrary componentLibrary
= typeDefInfo.getComponentLibrary();
+ String localName = typeDefInfo.getLocalName();
try {
ClassLoader typeClassLoader = componentLibrary.getClassLoader();
@@ -1074,7 +1083,7 @@
AntLibFactory libFactory
= componentManager.getLibFactory(componentLibrary);
Object typeInstance
- = createTypeInstance(typeClass, libFactory, model);
+ = createTypeInstance(typeClass, libFactory, model,
localName);
setContextLoader(currentLoader);
return typeInstance;
@@ -1095,15 +1104,17 @@
* @param model the model describing the required configuration of the
* instance
* @param libFactory the factory object of the typeClass's Ant library
+ * @param localName the name of the type within its Ant library
* @return an instance of the given class appropriately configured
* @exception ExecutionException if there is a problem creating the type
* instance
*/
private Object createTypeInstance(Class typeClass, AntLibFactory
libFactory,
- BuildElement model)
+ BuildElement model, String localName)
throws ExecutionException {
try {
- Object typeInstance = libFactory.createTypeInstance(typeClass);
+ Object typeInstance
+ = libFactory.createTypeInstance(typeClass, localName);
if (typeInstance instanceof ExecutionComponent) {
ExecutionComponent component =
(ExecutionComponent)typeInstance;
1.3 +9 -0
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ImportInfo.java
Index: ImportInfo.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ImportInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -u -r1.2 -r1.3
--- ImportInfo.java 8 Feb 2002 13:04:45 -0000 1.2
+++ ImportInfo.java 11 Feb 2002 15:42:18 -0000 1.3
@@ -107,5 +107,14 @@
return libDefinition.getDefinitionType();
}
+ /**
+ * Get the name of the component within its library.
+ *
+ * @return the name of the component within its library
+ */
+ public String getLocalName() {
+ return libDefinition.getDefinitionName();
+ }
+
}
1.4 +1 -1
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Reflector.java
Index: Reflector.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Reflector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -u -r1.3 -r1.4
--- Reflector.java 2 Feb 2002 14:50:31 -0000 1.3
+++ Reflector.java 11 Feb 2002 15:42:18 -0000 1.4
@@ -69,7 +69,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 19 January 2002
*/
-public class Reflector {
+public class Reflector implements Setter {
/**
* AttributeSetter classes are created at introspection time for each
1.1
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/DeferredSetter.java
Index: DeferredSetter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antcore.execution;
import org.apache.ant.common.antlib.DeferredTask;
import org.apache.ant.common.util.ExecutionException;
/**
* An implementation of the Setter interface for configuring instances of
* the DeferredTask interface
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 11 February 2002
*/
public class DeferredSetter implements Setter {
/**
* Set an attribute value on an object
*
* @param obj the object on which the value is being set
* @param attributeName the name of the attribute
* @param value the string represenation of the attribute's value
* @exception ExecutionException if the object does not support the
* attribute or the object has a problem setting the value
*/
public void setAttribute(Object obj, String attributeName,
String value) throws ExecutionException {
DeferredTask task = (DeferredTask)obj;
task.setAttribute(attributeName, value);
}
/**
* Get the type of the given nested element
*
* @param elementName the nested element whose type is desired
* @return the class instance representing the type of the element adder
*/
public Class getType(String elementName) {
return null;
}
/**
* Adds PCDATA to the element
*
* @param obj the instance whose content is being provided
* @param text the required content
* @exception ExecutionException if the object does not support
* contentor the object has a problem setting the content
*/
public void addText(Object obj, String text)
throws ExecutionException {
DeferredTask task = (DeferredTask)obj;
task.addText(text);
}
/**
* Add an element to the given object
*
* @param obj The object to which the element is being added
* @param elementName the name of the element
* @param value the object to be added - the nested element
* @exception ExecutionException if the object does not support content
* or the object has a problem setting the content
*/
public void addElement(Object obj, String elementName, Object value)
throws ExecutionException {
DeferredTask task = (DeferredTask)obj;
task.addElement(elementName, value);
}
/**
* Create a nested element using the object's element factory method.
*
* @param container the object in which the nested element is required.
* @param elementName the name of the nested element
* @return the new instance of the nested element
* @exception ExecutionException if the nested element cannot be
* created.
*/
public Object createElement(Object container, String elementName)
throws ExecutionException {
throw new ExecutionException("Deferred Tasks do not support "
+ "creation of nested elements");
}
/**
* Indicate if the class assocated with this reflector supports the
* addition of text content.
*
* @return true if the class supports an addText method
*/
public boolean supportsText() {
return true;
}
/**
* Indicate if the class assocated with this reflector supports the
* given attribute
*
* @param attributeName the name of the attribute
* @return true if the given attribute is supported
*/
public boolean supportsAttribute(String attributeName) {
return true;
}
/**
* Determine if the class associated with this reflector supports a
* particular nested element via a create factory method
*
* @param elementName the name of the element
* @return true if the class supports creation of that element
*/
public boolean supportsNestedCreator(String elementName) {
return false;
}
/**
* Determine if the class associated with this reflector supports a
* particular nested element via an add method
*
* @param elementName the name of the element
* @return true if the class supports addition of that element
*/
public boolean supportsNestedAdder(String elementName) {
return true;
}
/**
* Determine if the class associated with this reflector supports a
* particular nested element
*
* @param elementName the name of the element
* @return true if the class supports the given type of nested element
*/
public boolean supportsNestedElement(String elementName) {
return true;
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Setter.java
Index: Setter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antcore.execution;
import org.apache.ant.common.util.ExecutionException;
/**
* The Setter interface is used by the Ant core to set values and nested
* elements in objects being configured.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 11 February 2002
*/
public interface Setter {
/**
* Set an attribute value on an object
*
* @param obj the object on which the value is being set
* @param attributeName the name of the attribute
* @param value the string represenation of the attribute's value
* @exception ExecutionException if the object does not support the
* attribute or the object has a problem setting the value
*/
void setAttribute(Object obj, String attributeName,
String value)
throws ExecutionException;
/**
* Get the type of the given nested element
*
* @param elementName the nested element whose type is desired
* @return the class instance representing the type of the element adder
*/
Class getType(String elementName);
/**
* Adds PCDATA to the element
*
* @param obj the instance whose content is being provided
* @param text the required content
* @exception ExecutionException if the object does not support
* contentor the object has a problem setting the content
*/
void addText(Object obj, String text)
throws ExecutionException;
/**
* Add an element to the given object
*
* @param obj The object to which the element is being added
* @param elementName the name of the element
* @param value the object to be added - the nested element
* @exception ExecutionException if the object does not support content
* or the object has a problem setting the content
*/
void addElement(Object obj, String elementName, Object value)
throws ExecutionException;
/**
* Create a nested element using the object's element factory method.
*
* @param container the object in which the nested element is required.
* @param elementName the name of the nested element
* @return the new instance of the nested element
* @exception ExecutionException if the nested element cannot be
* created.
*/
Object createElement(Object container, String elementName)
throws ExecutionException;
/**
* Indicate if the class assocated with this reflector supports the
* addition of text content.
*
* @return true if the class supports an addText method
*/
boolean supportsText();
/**
* Indicate if the class assocated with this reflector supports the
* given attribute
*
* @param attributeName the name of the attribute
* @return true if the given attribute is supported
*/
boolean supportsAttribute(String attributeName);
/**
* Determine if the class associated with this reflector supports a
* particular nested element via a create factory method
*
* @param elementName the name of the element
* @return true if the class supports creation of that element
*/
boolean supportsNestedCreator(String elementName);
/**
* Determine if the class associated with this reflector supports a
* particular nested element via an add method
*
* @param elementName the name of the element
* @return true if the class supports addition of that element
*/
boolean supportsNestedAdder(String elementName);
/**
* Determine if the class associated with this reflector supports a
* particular nested element
*
* @param elementName the name of the element
* @return true if the class supports the given type of nested element
*/
boolean supportsNestedElement(String elementName);
}
1.7 +9 -1
jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java
Index: Project.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -u -r1.6 -r1.7
--- Project.java 8 Feb 2002 13:04:46 -0000 1.6
+++ Project.java 11 Feb 2002 15:42:18 -0000 1.7
@@ -68,7 +68,7 @@
import org.apache.ant.common.service.DataService;
import org.apache.ant.common.service.FileService;
import org.apache.ant.common.util.ExecutionException;
-import org.apache.ant.common.util.MessageLevel;
+import org.apache.ant.common.event.MessageLevel;
import org.apache.ant.common.util.PropertyUtils;
import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;
@@ -197,6 +197,14 @@
*/
public static String getJavaVersion() {
return javaVersion;
+ }
+
+ /**
+ * get the target hashtable
+ * @return hashtable, the contents of which can be cast to Target
+ */
+ public Hashtable getTargets() {
+ return new Hashtable(); // XXX can't get targets
}
/**
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/script/antlib.xml
Index: antlib.xml
===================================================================
<antlib libid="antopt.script"
home="http://jakarta.apache.org/ant">
<factory classname="org.apache.ant.antlib.script.ScriptFactory"/>
<taskdef name="scriptdef"
classname="org.apache.ant.antlib.script.ScriptDef"/>
</antlib>
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptBase.java
Index: ScriptBase.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.script;
import com.ibm.bsf.BSFEngine;
import com.ibm.bsf.BSFException;
import com.ibm.bsf.BSFManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.DeferredTask;
import org.apache.ant.common.util.ExecutionException;
/**
* Task to import a component or components from a library
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 27 January 2002
*/
public class ScriptBase extends AbstractTask implements DeferredTask {
/** The script factory instance to be used by this script */
private ScriptFactory factory;
/** the name to which this script has been defined */
private String scriptName;
/** the attribute values set by the core */
private Map attributes = new HashMap();
/** Any embedded set by the core */
private String text = "";
/** A list of the nested element names which have been configured */
private List nestedElementNames = new ArrayList();
/** A list of the nested elements objects which have been configured */
private List nestedElements = new ArrayList();
/**
* Set the given attribute
*
* @param name the name of the attribute
* @param attributeValue the new attribute value
*/
public void setAttribute(String name, String attributeValue) {
attributes.put(name, attributeValue);
}
/**
* Add a nested element
*
* @param nestedElementName the nested element's name
* @param value the object being added
*/
public void addElement(String nestedElementName, Object value) {
nestedElementNames.add(nestedElementName);
nestedElements.add(value);
}
/**
* Execute the script
*
* @exception ExecutionException if tghe script execution fails
*/
public void execute() throws ExecutionException {
String language = factory.getScriptLanguage(scriptName);
String script = factory.getScript(scriptName);
try {
BSFManager manager = new BSFManager();
// execute the script
BSFEngine engine = manager.loadScriptingEngine(language);
engine.exec(scriptName, 0, 0, script);
for (Iterator i = attributes.keySet().iterator(); i.hasNext(); ) {
String attributeName = (String)i.next();
String value = (String)attributes.get(attributeName);
StringBuffer setter = new StringBuffer(attributeName);
setter.setCharAt(0, Character.toUpperCase(setter.charAt(0)));
engine.call(null, "set" + setter, new Object[]{value});
}
engine.call(null, "execute", new Object[]{});
} catch (BSFException e) {
Throwable t = e;
Throwable te = e.getTargetException();
if (te != null) {
if (te instanceof ExecutionException) {
throw (ExecutionException)te;
} else {
t = te;
}
}
throw new ExecutionException(t);
}
}
/**
* Defines the script.
*
* @param text Sets the value for the script variable.
*/
public void addText(String text) {
this.text += text;
}
/**
* Sets the factory of the ScriptBase
*
* @param factory the script factory this script instance will use
*/
protected void setFactory(ScriptFactory factory) {
this.factory = factory;
}
/**
* set the name of the script
*
* @param scriptName the script's defined name
*/
protected void setScriptName(String scriptName) {
this.scriptName = scriptName;
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptDef.java
Index: ScriptDef.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.script;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.util.ExecutionException;
/**
* Define a task using a script
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 11 February 2002
*/
public class ScriptDef extends AbstractTask {
/** The script factor to use */
private ScriptFactory factory;
/** the name by which this script will be activated */
private String name;
/** the scripting language used by the script */
private String language;
/** the script itself */
private String script = "";
/**
* set the name under which this script will be activated in a build
* file
*
* @param name the name of the script
*/
public void setName(String name) {
this.name = name;
}
/**
* Set the scripting language used by this script
*
* @param language the scripting language used by this script.
*/
public void setLanguage(String language) {
this.language = language;
}
/**
* Define the script. The script itself is stored in the factory where
* it is retried by the ScriptBase instance
*
* @exception ExecutionException if the script cannot be defined
*/
public void execute() throws ExecutionException {
// tell the factory about this script, under this name.
factory.defineScript(name, language, script);
}
/**
* Defines the script.
*
* @param text Sets the value for the script variable.
*/
public void addText(String text) {
this.script += text;
}
/**
* Set the script factory that will be used to store the script for
* later execution
*
* @param factory the script factory used to store script information.
*/
protected void setFactory(ScriptFactory factory) {
this.factory = factory;
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/script/org/apache/ant/antlib/script/ScriptFactory.java
Index: ScriptFactory.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.script;
import java.util.HashMap;
import java.util.Map;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.StandardLibFactory;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.ExecutionException;
/**
* The ScriptFactory class is a factory for the Scripting tasks. It stores
* the scripts as they are defined
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 11 February 2002
*/
public class ScriptFactory extends StandardLibFactory {
/**
* An inner class used to record information about defined scripts.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 11 February 2002
*/
private static class ScriptInfo {
/** the scripting langauge to use */
private String language;
/** the script itself */
private String script;
/**
* Constructor for the ScriptInfo object
*
* @param language the language the script is written in
* @param script the script
*/
public ScriptInfo(String language, String script) {
this.language = language;
this.script = script;
}
/**
* Gets the language of the Script
*
* @return the language value
*/
public String getLanguage() {
return language;
}
/**
* Gets the script.
*
* @return the script text
*/
public String getScript() {
return script;
}
}
/** The core's Component Service instance */
private ComponentService componentService;
/** the scripts that have been defined */
private Map scripts = new HashMap();
/**
* Initialise the factory
*
* @param context the factory's context
* @exception ExecutionException if the factory cannot be initialized
*/
public void init(AntContext context) throws ExecutionException {
super.init(context);
componentService
=
(ComponentService)context.getCoreService(ComponentService.class);
try {
Class.forName("com.ibm.bsf.BSFManager");
} catch (ClassNotFoundException e) {
throw new ExecutionException("The script Ant library requires "
+ "bsf.jar to be available");
} catch (NoClassDefFoundError e) {
throw new ExecutionException("The script Ant library requires "
+ "bsf.jar to be available. The class " + e.getMessage()
+ "appears to be missing");
}
}
/**
* Create an instance of the given task class
*
* @param taskClass the class for which an instance is required
* @param localName the name within the library undeer which the task is
* defined
* @return an instance of the required class
* @exception InstantiationException if the class cannot be instantiated
* @exception IllegalAccessException if the instance cannot be accessed
* @exception ExecutionException if there is a problem creating the task
*/
public Object createTaskInstance(Class taskClass, String localName)
throws InstantiationException, IllegalAccessException,
ExecutionException {
Object task = super.createTaskInstance(taskClass, localName);
if (task instanceof ScriptDef) {
ScriptDef scriptDef = (ScriptDef)task;
scriptDef.setFactory(this);
} else if (task instanceof ScriptBase) {
ScriptBase scriptBase = (ScriptBase)task;
scriptBase.setFactory(this);
scriptBase.setScriptName(localName);
}
return task;
}
/**
* Get the script language of a script
*
* @param scriptName the name the script is defined under
* @return the script language name
*/
protected String getScriptLanguage(String scriptName) {
ScriptInfo scriptInfo = (ScriptInfo)scripts.get(scriptName);
return scriptInfo.getLanguage();
}
/**
* Get a script.
*
* @param scriptName the name the script is defined under
* @return the script text
*/
protected String getScript(String scriptName) {
ScriptInfo scriptInfo = (ScriptInfo)scripts.get(scriptName);
return scriptInfo.getScript();
}
/**
* Define a script
*
* @param name the name the script is to be defined under
* @param language the language of the scripr
* @param script the script text
* @exception ExecutionException if the script cannot be defined
*/
protected void defineScript(String name, String language, String script)
throws ExecutionException {
ScriptInfo scriptDefinition = new ScriptInfo(language, script);
scripts.put(name, scriptDefinition);
componentService.taskdef(this, ScriptBase.class.getClassLoader(),
name, ScriptBase.class.getName());
}
}
1.4 +1 -1
jakarta-ant/proposal/mutant/src/java/antlibs/system/antlib.xml
Index: antlib.xml
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/system/antlib.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -u -r1.3 -r1.4
--- antlib.xml 7 Feb 2002 14:42:37 -0000 1.3
+++ antlib.xml 11 Feb 2002 15:42:18 -0000 1.4
@@ -1,9 +1,9 @@
<antlib libid="ant.system"
home="http://jakarta.apache.org/ant">
- <taskdef name="import" classname="org.apache.ant.antlib.system.Import"/>
<taskdef name="libpath" classname="org.apache.ant.antlib.system.LibPath"/>
<taskdef name="loadlib" classname="org.apache.ant.antlib.system.LoadLib"/>
+ <taskdef name="import" classname="org.apache.ant.antlib.system.Import"/>
<taskdef name="ant" classname="org.apache.ant.antlib.system.Ant"/>
<taskdef name="antcall" classname="org.apache.ant.antlib.system.AntCall"/>
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Ant.java
Index: Ant.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import java.io.File;
import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.common.service.MagicProperties;
/**
* The Ant task - used to execute a different build file
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 4 February 2002
*/
public class Ant extends AntBase {
/** The ant file to be run */
private File antFile;
/** the base directory to use for the run */
private File baseDir;
/** File to capture any output */
private File outputFile;
/**
* sets the file containing the XML representation model to build
*
* @param antFile the file to build
*/
public void setAntFile(File antFile) {
this.antFile = antFile;
}
/**
* Set the base directory for the execution of the build
*
* @param baseDir the base directory for the build
*/
public void setDir(File baseDir) {
this.baseDir = baseDir;
}
/**
* The output file for capturing the build output
*
* @param outputFile the output file for capturing the build output
*/
public void setOutput(File outputFile) {
this.outputFile = outputFile;
}
/**
* Run the sub-build
*
* @exception ExecutionException if the build can't be run
*/
public void execute() throws ExecutionException {
if (baseDir == null) {
baseDir = getContext().getBaseDir();
}
if (antFile == null) {
antFile = new File(baseDir, "build.ant");
if (!antFile.exists()) {
antFile = new File(baseDir, "build.xml");
}
}
setProperty(MagicProperties.BASEDIR, baseDir.getAbsolutePath());
ExecService execService
= (ExecService)getCoreService(ExecService.class);
execService.runBuild(antFile, getProperties(), getTargets());
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntBase.java
Index: AntBase.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.ant.common.antlib.AbstractComponent;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.service.DataService;
import org.apache.ant.common.util.ExecutionException;
/**
* Common Base class for the Ant and AntCall tasks
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 4 February 2002
*/
public abstract class AntBase extends AbstractTask {
/**
* Simple Property value storing class
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 5 February 2002
*/
public static class Property extends AbstractComponent {
/** The property name */
private String name;
/** The property value */
private String value;
/**
* Sets the name of the Property
*
* @param name the new name value
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets the value of the Property
*
* @param value the new value value
*/
public void setValue(String value) {
this.value = value;
}
/**
* Gets the name of the Property
*
* @return the name value
*/
public String getName() {
return name;
}
/**
* Gets the value of the Property
*
* @return the value value
*/
public String getValue() {
return value;
}
/**
* Validate this data type instance
*
* @exception ExecutionException if either attribute has not been
* set
*/
public void validateComponent() throws ExecutionException {
if (name == null) {
throw new ExecutionException("\"name\" attribute of "
+ "<property> must be supplied");
}
if (value == null) {
throw new ExecutionException("\"value\" attribute of "
+ "<property> must be supplied");
}
}
}
/**
* A simple class to store information about references being passed
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 5 February 2002
*/
public static class Reference extends AbstractComponent {
/** The id of the reference to be passed */
private String refId;
/** The id to be used in the sub-build for this reference */
private String toId;
/**
* Sets the refId of the Reference
*
* @param refId the new refId value
*/
public void setRefId(String refId) {
this.refId = refId;
}
/**
* Sets the toId of the Reference
*
* @param toId the new toId value
*/
public void setToId(String toId) {
this.toId = toId;
}
/**
* Gets the refId of the Reference
*
* @return the refId value
*/
public String getRefId() {
return refId;
}
/**
* Gets the toId of the Reference
*
* @return the toId value
*/
public String getToId() {
return toId;
}
/**
* Validate this data type instance
*
* @exception ExecutionException if the refid attribute has not been
* set
*/
public void validateComponent() throws ExecutionException {
if (refId == null) {
throw new ExecutionException("\"refid\" attribute of "
+ "<reference> must be supplied");
}
}
}
/** The name of the target to be evaluated in the sub-build */
private String targetName;
/**
* flag which indicates if all current properties should be passed to
* the subbuild
*/
private boolean inheritAll = true;
/**
* flag which indicates if all current references should be passed to
* the subbuild
*/
private boolean inheritRefs = false;
/** The properties which will be passed to the sub-build */
private Map properties = new HashMap();
/** The core's data service for manipulating the properties */
private DataService dataService;
/**
* Sets the target to be executed in the subbuild
*
* @param targetName the name of the target to build
*/
public void setTarget(String targetName) {
this.targetName = targetName;
}
/**
* Indicate if all properties should be passed
*
* @param inheritAll true if all properties should be passed
*/
public void setInheritAll(boolean inheritAll) {
this.inheritAll = inheritAll;
}
/**
* Indicate if all references are to be passed to the subbuild
*
* @param inheritRefs true if the sub-build should be given all the
* current references
*/
public void setInheritRefs(boolean inheritRefs) {
this.inheritRefs = inheritRefs;
}
/**
* Initialise this task
*
* @param context core's context
* @exception ExecutionException if we can't access the data service
*/
public void init(AntContext context) throws ExecutionException {
super.init(context);
dataService = (DataService)getCoreService(DataService.class);
}
/**
* Add a property to be passed to the subbuild
*
* @param property descriptor for the property to be passed
*/
public void addProperty(Property property) {
properties.put(property.getName(), property.getValue());
}
/**
* Add a reference to be passed
*
* @param reference the descriptor of the reference to be passed
* @exception ExecutionException if the reference does not reference a
* valid object
*/
public void addReference(Reference reference) throws ExecutionException {
String refId = reference.getRefId();
if (!dataService.isDataValueSet(refId)) {
throw new ExecutionException("RefId \"" + refId + "\" is not
set");
}
Object value = dataService.getDataValue(refId);
String toId = reference.getToId();
if (toId == null) {
toId = refId;
}
properties.put(toId, value);
}
/**
* Set a property for the subbuild
*
* @param propertyName the property name
* @param propertyValue the value of the property
*/
protected void setProperty(String propertyName, Object propertyValue) {
properties.put(propertyName, propertyValue);
}
/**
* Get the list of targets to be executed
*
* @return A List of string target names.
*/
protected List getTargets() {
List targets = new ArrayList();
if (targetName != null) {
targets.add(targetName);
}
return targets;
}
/**
* Get the properties to be used with the sub-build
*
* @return the properties the sub-build will start with
*/
protected Map getProperties() {
if (!inheritAll) {
return properties;
}
// need to combine existing properties with new ones
Map subBuildProperties = dataService.getAllProperties();
subBuildProperties.putAll(properties);
return subBuildProperties;
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/AntCall.java
Index: AntCall.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.common.service.MagicProperties;
/**
* The Ant task - used to execute a different build file
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 4 February 2002
*/
public class AntCall extends AntBase {
/**
* Execute the sub-build
*
* @exception ExecutionException if the build fails
*/
public void execute() throws ExecutionException {
setProperty(MagicProperties.BASEDIR,
getContext().getBaseDir().getAbsolutePath());
ExecService execService
= (ExecService)getCoreService(ExecService.class);
execService.callTarget(getProperties(), getTargets());
}
/**
* Alias to add a property to the sub-build
*
* @param param descriptor for the property to be passed
*/
public void addParam(Property param) {
super.addProperty(param);
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/FileConverter.java
Index: FileConverter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import java.io.File;
import org.apache.ant.common.antlib.AbstractConverter;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.service.FileService;
/**
* A converter to convert to File objects, resolving against the
* project's basedir
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 21 January 2002
*/
public class FileConverter extends AbstractConverter {
/**
* Get the list of classes this converter is able to convert to.
*
* @return an array of Class objects representing the classes this
* converter handles.
*/
public Class[] getTypes() {
return new Class[]{File.class};
}
/**
* Convert a string from the value given to an instance of the given
* type.
*
* @param value The value to be converted
* @param type the desired type of the converted object
* @return the value of the converted object
* @exception ExecutionException if the conversion cannot be made
*/
public Object convert(String value, Class type) throws ExecutionException
{
try {
FileService fileService
= (FileService)getContext().getCoreService(FileService.class);
return fileService.resolveFile(value);
}
catch (AntException e) {
throw new ExecutionException("Unable to resolve file: "
+ value, e);
}
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Import.java
Index: Import.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.ExecutionException;
/**
* Task to import a component or components from a library
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 27 January 2002
*/
public class Import extends AbstractTask {
/** The Ant LIbrary Id from which the component must be imported */
private String libraryId = null;
/** The name of the component to be imported */
private String name = null;
/** The alias that is to be used for the name */
private String alias = null;
/**
* Sets the libraryId of the Import
*
* @param libraryId the new libraryId value
*/
public void setLibraryId(String libraryId) {
this.libraryId = libraryId;
}
/**
* Sets the name of the Import
*
* @param name the new name value
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets the alias of the Import
*
* @param alias the new alias value
*/
public void setAlias(String alias) {
this.alias = alias;
}
/**
* Validate this task is properly configured
*
* @exception ExecutionException if the task is not configured correctly
*/
public void validateComponent() throws ExecutionException {
if (libraryId == null) {
throw new ExecutionException("You must specify a library
identifier"
+ " with the \"libraryid\" attribute");
}
if (alias != null && name == null) {
throw new ExecutionException("You may only specify an alias"
+ " when you specify the component name");
}
}
/**
* Do the work and import the component or components
*
* @exception ExecutionException if the components cannot be imported
*/
public void execute() throws ExecutionException {
AntContext context = getContext();
ComponentService componentService = (ComponentService)
context.getCoreService(ComponentService.class);
if (name == null) {
componentService.importLibrary(libraryId);
} else {
componentService.importComponent(libraryId, name, alias);
}
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/LibPath.java
Index: LibPath.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.init.InitUtils;
/**
* Task to add an additional classpath to the given library
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 27 January 2002
*/
public class LibPath extends AbstractTask {
/** The id of the library for which this additional path is being set */
private String libraryId;
/**
* This is the location, either file or URL of the library or libraries
* to be loaded
*/
private URL url;
/**
* Sets the libraryId of the LibPath
*
* @param libraryId the new libraryId value
*/
public void setLibraryId(String libraryId) {
this.libraryId = libraryId;
}
/**
* Sets the URL of the library to be loaded
*
* @param url the URL from which the library is to be loaded
* @exception ExecutionException if the URL cannot be set
*/
public void setURL(URL url) throws ExecutionException {
checkNullURL();
this.url = url;
}
/**
* Set the file from which the library should be loaded.
*
* @param file the file from which the library should be loaded
* @exception ExecutionException if the file attribute cannot be set
*/
public void setFile(File file) throws ExecutionException {
checkNullURL();
try {
this.url = InitUtils.getFileURL(file);
} catch (MalformedURLException e) {
throw new ExecutionException(e);
}
}
/**
* Set the dir in which to search for AntLibraries.
*
* @param dir the dir from which all Ant Libraries found will be loaded.
* @exception ExecutionException if the dir attribute cannot be set
*/
public void setDir(File dir) throws ExecutionException {
checkNullURL();
try {
this.url = InitUtils.getFileURL(dir);
} catch (MalformedURLException e) {
throw new ExecutionException(e);
}
}
/**
* Validate this task is configured correctly
*
* @exception ExecutionException if the task is not configured correctly
*/
public void validateComponent() throws ExecutionException {
if (libraryId == null) {
throw new ExecutionException("You must specify the id of the"
+ "library for which you are providing additional
classpaths");
}
if (url == null) {
throw new ExecutionException("You must provide an additional "
+ "classpath using one of the file, dir or url attributes");
}
}
/**
* Add the libpath to the set of paths associated with the library
*
* @exception ExecutionException if the library path cannot be addded to
* the library
*/
public void execute() throws ExecutionException {
AntContext context = getContext();
ComponentService componentService = (ComponentService)
context.getCoreService(ComponentService.class);
componentService.addLibPath(libraryId, url);
}
/**
* Check if any of the location specifying attributes have already been
* set.
*
* @exception ExecutionException if the search URL has already been set
*/
private void checkNullURL() throws ExecutionException {
if (url != null) {
throw new ExecutionException("Location of library has already
been "
+ "set. Please use only one of file, dir or url attributes");
}
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/LoadLib.java
Index: LoadLib.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.init.InitUtils;
/**
* Load an AntLibrary and optionally import all its components
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 29 January 2002
*/
public class LoadLib extends AbstractTask {
/** Flag which indicates if all components should be imported */
private boolean importAll;
/**
* This is the location, either file or URL of the library or libraries
* to be loaded
*/
private URL url;
/**
* Sets the URL of the library to be loaded
*
* @param url the URL from which the library is to be loaded
* @exception ExecutionException if the URL cannot be set
*/
public void setURL(URL url) throws ExecutionException {
checkNullURL();
this.url = url;
}
/**
* Set the file from which the library should be loaded.
*
* @param file the file from which the library should be loaded
* @exception ExecutionException if the file attribute cannot be set
*/
public void setFile(File file) throws ExecutionException {
checkNullURL();
try {
this.url = InitUtils.getFileURL(file);
} catch (MalformedURLException e) {
throw new ExecutionException(e);
}
}
/**
* Set the dir in which to search for AntLibraries.
*
* @param dir the dir from which all Ant Libraries found will be loaded.
* @exception ExecutionException if the dir attribute cannot be set
*/
public void setDir(File dir) throws ExecutionException {
checkNullURL();
try {
this.url = InitUtils.getFileURL(dir);
} catch (MalformedURLException e) {
throw new ExecutionException(e);
}
}
/**
* Indicate whether all components from the library should be imported
*
* @param importAll true if all components in the library should be
* imported.
*/
public void setImportAll(boolean importAll) {
this.importAll = importAll;
}
/**
* Validate this task is configured correctly
*
* @exception ExecutionException if the task is not configured correctly
*/
public void validateComponent() throws ExecutionException {
if (url == null) {
throw new ExecutionException("A location from which to load "
+ "libraries must be provided");
}
}
/**
* Load the library or libraries and optiinally import their components
*
* @exception ExecutionException if the library or libraries cannot be
* loaded.
*/
public void execute() throws ExecutionException {
AntContext context = getContext();
ComponentService componentService = (ComponentService)
context.getCoreService(ComponentService.class);
componentService.loadLib(url.toString(), importAll);
}
/**
* Check if any of the location specifying attributes have already been
* set.
*
* @exception ExecutionException if the search URL has already been set
*/
private void checkNullURL() throws ExecutionException {
if (url != null) {
throw new ExecutionException("Location of library has already
been "
+ "set. Please use only one of file, dir or url attributes");
}
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/PrimitiveConverter.java
Index: PrimitiveConverter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import org.apache.ant.common.antlib.AbstractConverter;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.common.util.PropertyUtils;
/**
* A converter to convert to Java's primitie types
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
*/
public class PrimitiveConverter extends AbstractConverter {
/**
* Get the list of classes this converter is able to convert to.
*
* @return an array of Class objects representing the classes this
* converter handles.
*/
public Class[] getTypes() {
return new Class[] {
Character.class, Character.TYPE, Byte.TYPE, Short.TYPE,
Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE,
Boolean.class, Boolean.TYPE};
}
/**
* Convert a string from the value given to an instance of the given
* type.
*
* @param value The value to be converted
* @param type the desired type of the converted object
* @return the value of the converted object
* @exception ExecutionException if the conversion cannot be made
*/
public Object convert(String value, Class type) throws ExecutionException
{
if (type.equals(Character.class)
|| type.equals(Character.TYPE)) {
return new Character(value.charAt(0));
} else if (type.equals(Byte.TYPE)) {
return new Byte(value);
} else if (type.equals(Short.TYPE)) {
return new Short(value);
} else if (type.equals(Integer.TYPE)) {
return new Integer(value);
} else if (type.equals(Long.TYPE)) {
return new Long(value);
} else if (type.equals(Float.TYPE)) {
return new Float(value);
} else if (type.equals(Double.TYPE)) {
return new Double(value);
} else if (type.equals(Boolean.class)
|| type.equals(Boolean.TYPE)) {
return new Boolean(PropertyUtils.toBoolean(value));
}
throw new ExecutionException("This converter does not handle "
+ type.getName());
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Taskdef.java
Index: Taskdef.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import org.apache.ant.common.antlib.AbstractTask;
/**
* Define a new task for use in the build file
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 27 January 2002
*/
public class Taskdef extends AbstractTask {
/** Define the new task */
public void execute() {
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Typedef.java
Index: Typedef.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import org.apache.ant.common.antlib.AbstractTask;
/**
* Define a new type to be used in the build
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 27 January 2002
*/
public class Typedef extends AbstractTask {
/** define the type */
public void execute() {
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/URLConverter.java
Index: URLConverter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import java.net.URL;
import java.net.MalformedURLException;
import org.apache.ant.common.antlib.AbstractConverter;
import org.apache.ant.common.util.ExecutionException;
/**
* A converter to convert to URLs relative to the project base dir
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
*/
public class URLConverter extends AbstractConverter {
/**
* Get the list of classes this converter is able to convert to.
*
* @return an array of Class objects representing the classes this
* converter handles.
*/
public Class[] getTypes() {
return new Class[]{URL.class};
}
/**
* Convert a string from the value given to an instance of the given
* type.
*
* @param value The value to be converted
* @param type the desired type of the converted object
* @return the value of the converted object
* @exception ExecutionException if the conversion cannot be made
*/
public Object convert(String value, Class type) throws ExecutionException
{
try {
return new URL(value);
}
catch (MalformedURLException e) {
throw new ExecutionException(e);
}
}
}
1.7 +81 -46
jakarta-ant/proposal/mutant/src/java/cli/org/apache/ant/cli/Commandline.java
Index: Commandline.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/cli/org/apache/ant/cli/Commandline.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -u -r1.6 -r1.7
--- Commandline.java 6 Feb 2002 12:52:58 -0000 1.6
+++ Commandline.java 11 Feb 2002 15:42:19 -0000 1.7
@@ -75,7 +75,7 @@
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.ConfigException;
import org.apache.ant.common.util.Location;
-import org.apache.ant.common.util.MessageLevel;
+import org.apache.ant.common.event.MessageLevel;
import org.apache.ant.init.InitConfig;
import org.apache.ant.init.InitUtils;
@@ -234,7 +234,8 @@
* Get an option value
*
* @param args the full list of command line arguments
- * @param position the position in the args array where the value shoudl
be
+ * @param position the position in the args array where the value shoudl
+ * be
* @param argType the option type
* @return the value of the option
* @exception ConfigException if the option cannot be read
@@ -262,6 +263,7 @@
this.initConfig = initConfig;
try {
parseArguments(args);
+ determineBuildFile();
AntConfig config = new AntConfig();
AntConfig userConfig =
getAntConfig(initConfig.getUserConfigArea());
@@ -293,6 +295,7 @@
ExecutionManager executionManager
= new ExecutionManager(initConfig, config);
addBuildListeners(executionManager);
+ executionManager.init();
executionManager.runBuild(project, targets, definedProperties);
} catch (Throwable t) {
if (t instanceof AntException) {
@@ -332,25 +335,14 @@
return project;
}
-
/**
- * Parse the command line arguments.
+ * Handle build file argument
*
- * @param args the command line arguments
- * @exception ConfigException thrown when the command line contains some
- * sort of error.
+ * @param url the build file's URL
+ * @exception ConfigException if the build file location is not valid
*/
- private void parseArguments(String[] args)
- throws ConfigException {
-
- int i = 0;
- while (i < args.length) {
- String arg = args[i++];
-
- if (arg.equals("-buildfile") || arg.equals("-file")
- || arg.equals("-f")) {
+ private void argBuildFile(String url) throws ConfigException {
try {
- String url = getOption(args, i++, arg);
if (url.indexOf(":") == -1) {
// We convert any hash characters to their URL
escape.
buildFileURL = InitUtils.getFileURL(new File(url));
@@ -358,21 +350,84 @@
buildFileURL = new URL(url);
}
} catch (MalformedURLException e) {
- System.err.println("Buildfile is not valid: " +
- e.getMessage());
throw new ConfigException("Build file is not valid", e);
}
- } else if (arg.equals("-logfile") || arg.equals("-l")) {
+ }
+
+ /**
+ * Handle the log file option
+ *
+ * @param arg the value of the log file option
+ * @exception ConfigException if the log file is not writeable
+ */
+ private void argLogFile(String arg) throws ConfigException {
try {
- File logFile = new File(getOption(args, i++, arg));
+ File logFile = new File(arg);
out = new PrintStream(new FileOutputStream(logFile));
err = out;
} catch (IOException ioe) {
- System.err.println("Cannot write on the specified log " +
+ throw new ConfigException("Cannot write on the specified log " +
"file. Make sure the path exists and " +
- "you have write permissions.");
- return;
+ "you have write permissions.", ioe);
+ }
+ }
+
+ /**
+ * Handle the logger attribute
+ *
+ * @param arg the logger classname
+ * @exception ConfigException if a logger has already been defined
+ */
+ private void argLogger(String arg) throws ConfigException {
+ if (loggerClassname != null) {
+ throw new ConfigException("Only one logger class may be " +
+ "specified.");
+ }
+ loggerClassname = arg;
+ }
+
+
+ /**
+ * Determine the build file to use
+ *
+ * @exception ConfigException if the build file cannot be found
+ */
+ private void determineBuildFile() throws ConfigException {
+ if (buildFileURL == null) {
+ File defaultBuildFile = new File(DEFAULT_BUILD_FILENAME);
+ if (!defaultBuildFile.exists()) {
+ File ant1BuildFile = new File(DEFAULT_ANT1_FILENAME);
+ if (ant1BuildFile.exists()) {
+ defaultBuildFile = ant1BuildFile;
+ }
}
+ try {
+ buildFileURL = InitUtils.getFileURL(defaultBuildFile);
+ } catch (MalformedURLException e) {
+ throw new ConfigException("Build file is not valid", e);
+ }
+ }
+ }
+
+ /**
+ * Parse the command line arguments.
+ *
+ * @param args the command line arguments
+ * @exception ConfigException thrown when the command line contains some
+ * sort of error.
+ */
+ private void parseArguments(String[] args)
+ throws ConfigException {
+
+ int i = 0;
+ while (i < args.length) {
+ String arg = args[i++];
+
+ if (arg.equals("-buildfile") || arg.equals("-file")
+ || arg.equals("-f")) {
+ argBuildFile(getOption(args, i++, arg));
+ } else if (arg.equals("-logfile") || arg.equals("-l")) {
+ argLogFile(getOption(args, i++, arg));
} else if (arg.equals("-quiet") || arg.equals("-q")) {
messageOutputLevel = MessageLevel.MSG_WARN;
} else if (arg.equals("-verbose") || arg.equals("-v")) {
@@ -386,12 +441,7 @@
} else if (arg.equals("-listener")) {
listeners.add(getOption(args, i++, arg));
} else if (arg.equals("-logger")) {
- if (loggerClassname != null) {
- System.err.println("Only one logger class may be " +
- "specified.");
- return;
- }
- loggerClassname = getOption(args, i++, arg);
+ argLogger(getOption(args, i++, arg));
} else if (arg.startsWith("-D")) {
String name = arg.substring(2, arg.length());
String value = null;
@@ -413,21 +463,6 @@
}
}
- if (buildFileURL == null) {
- File defaultBuildFile = new File(DEFAULT_BUILD_FILENAME);
- if (!defaultBuildFile.exists()) {
- File ant1BuildFile = new File(DEFAULT_ANT1_FILENAME);
- if (ant1BuildFile.exists()) {
- defaultBuildFile = ant1BuildFile;
- }
- }
- try {
- buildFileURL = InitUtils.getFileURL(defaultBuildFile);
- } catch (MalformedURLException e) {
- System.err.println("Buildfile is not valid: " +
e.getMessage());
- throw new ConfigException("Build file is not valid", e);
- }
- }
}
/**
1.5 +16 -14
jakarta-ant/proposal/mutant/src/java/cli/org/apache/ant/cli/DefaultLogger.java
Index: DefaultLogger.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/cli/org/apache/ant/cli/DefaultLogger.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -u -r1.4 -r1.5
--- DefaultLogger.java 5 Feb 2002 11:49:06 -0000 1.4
+++ DefaultLogger.java 11 Feb 2002 15:42:19 -0000 1.5
@@ -59,7 +59,7 @@
import org.apache.ant.common.event.BuildEvent;
import org.apache.ant.common.util.AntException;
import org.apache.ant.common.util.Location;
-import org.apache.ant.common.util.MessageLevel;
+import org.apache.ant.common.event.MessageLevel;
/**
* Writes build event to a PrintStream. Currently, it only writes which
@@ -235,8 +235,9 @@
= event.getPriority() == MessageLevel.MSG_ERR ? err : out;
// Filter out messages based on priority
- if (event.getPriority() <= messageOutputLevel
- && event.getModelElement() instanceof BuildElement) {
+ if (event.getPriority() <= messageOutputLevel) {
+
+ if (event.getModelElement() instanceof BuildElement) {
// Print out the name of the task if we're in one
BuildElement buildElement
= (BuildElement)event.getModelElement();
@@ -249,6 +250,7 @@
logTo.print(" ");
}
logTo.print(msg);
+ }
}
// Print the message
1.3 +6 -2
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/AntLibFactory.java
Index: AntLibFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/AntLibFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -u -r1.2 -r1.3
--- AntLibFactory.java 5 Feb 2002 14:13:57 -0000 1.2
+++ AntLibFactory.java 11 Feb 2002 15:42:19 -0000 1.3
@@ -68,12 +68,14 @@
* Create an instance of the given type class
*
* @param typeClass the class for which an instance is required
+ * @param localName the name within the library under which the type is
+ * defined
* @return an instance of the required class
* @exception InstantiationException if the class cannot be instantiated
* @exception IllegalAccessException if the instance cannot be accessed
* @exception ExecutionException if there is a problem creating the type
*/
- Object createTypeInstance(Class typeClass)
+ Object createTypeInstance(Class typeClass, String localName)
throws InstantiationException, IllegalAccessException,
ExecutionException;
@@ -89,12 +91,14 @@
* Create an instance of the given task class
*
* @param taskClass the class for which an instance is required
+ * @param localName the name within the library under which the task is
+ * defined
* @return an instance of the required class
* @exception InstantiationException if the class cannot be instantiated
* @exception IllegalAccessException if the instance cannot be accessed
* @exception ExecutionException if there is a problem creating the task
*/
- Object createTaskInstance(Class taskClass)
+ Object createTaskInstance(Class taskClass, String localName)
throws InstantiationException, IllegalAccessException,
ExecutionException;
1.3 +19 -3
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/StandardLibFactory.java
Index: StandardLibFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/StandardLibFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -u -r1.2 -r1.3
--- StandardLibFactory.java 5 Feb 2002 14:13:57 -0000 1.2
+++ StandardLibFactory.java 11 Feb 2002 15:42:19 -0000 1.3
@@ -62,16 +62,21 @@
* @see AntLibFactory
*/
public class StandardLibFactory implements AntLibFactory {
+ /** The context the factory can use to interact with the core */
+ private AntContext context;
+
/**
* Create an instance of the given task class
*
* @param taskClass the class for which an instance is required
+ * @param localName the name within the library under which the task is
+ * defined
* @return an instance of the required class
* @exception InstantiationException if the class cannot be instantiated
* @exception IllegalAccessException if the instance cannot be accessed
* @exception ExecutionException if there is a problem creating the task
*/
- public Object createTaskInstance(Class taskClass)
+ public Object createTaskInstance(Class taskClass, String localName)
throws InstantiationException, IllegalAccessException,
ExecutionException {
return taskClass.newInstance();
@@ -81,12 +86,14 @@
* Create an instance of the given type class
*
* @param typeClass the class for which an instance is required
+ * @param localName the name within the library under which the type is
+ * defined, if any.
* @return an instance of the required class
* @exception InstantiationException if the class cannot be instantiated
* @exception IllegalAccessException if the instance cannot be accessed
* @exception ExecutionException if there is a problem creating the type
*/
- public Object createTypeInstance(Class typeClass)
+ public Object createTypeInstance(Class typeClass, String localName)
throws InstantiationException, IllegalAccessException,
ExecutionException {
return typeClass.newInstance();
@@ -99,7 +106,7 @@
* @exception ExecutionException if the factory cannot be initialized
*/
public void init(AntContext context) throws ExecutionException {
- // do nothing
+ this.context = context;
}
/**
@@ -130,6 +137,15 @@
public void registerCreatedElement(Object createdElement)
throws ExecutionException {
// do nothing
+ }
+
+ /**
+ * Gets the context of the factory
+ *
+ * @return the context object
+ */
+ protected AntContext getContext() {
+ return context;
}
}
1.1
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/DeferredTask.java
Index: DeferredTask.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.common.antlib;
/**
* A deferred task is one where the task task responsibility for configuring
* itself at execution time. The attributes and nested elements are stored
* by the task for later use
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 11 February 2002
*/
public interface DeferredTask extends Task {
/**
* Sets the attribute of the DeferredTask
*
* @param name the attribute name
* @param attributeValue the new attribute value
*/
void setAttribute(String name, String attributeValue);
/**
* Add a nested element
*
* @param nestedElementName the name of the nested element
* @param value the object which is the nested element
*/
void addElement(String nestedElementName, Object value);
/**
* Add any text content
*
* @param text the value of the content
*/
void addText(String text);
}
1.4 +9 -3
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/event/BuildEvent.java
Index: BuildEvent.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/event/BuildEvent.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -u -r1.3 -r1.4
--- BuildEvent.java 8 Feb 2002 13:04:46 -0000 1.3
+++ BuildEvent.java 11 Feb 2002 15:42:19 -0000 1.4
@@ -122,9 +122,10 @@
* @param message the message associated with this event
* @param priority the message priority
*/
- public BuildEvent(ModelElement source, String message,
+ public BuildEvent(Object source, String message,
int priority) {
- this(source, MESSAGE);
+ super(source);
+ this.eventType = MESSAGE;
this.message = message;
this.messagePriority = priority;
}
@@ -175,7 +176,12 @@
* @return the model element this event is associated with
*/
public ModelElement getModelElement() {
+ Object source = getSource();
+ if (source instanceof ModelElement) {
return (ModelElement)getSource();
+ }
+
+ return null;
}
}
1.1
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/event/MessageLevel.java
Index: MessageLevel.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.common.event;
/**
* The levels at which a log message may be sent.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 16 January 2002
*/
public class MessageLevel {
/** Error message level */
public final static int MSG_ERR = 0;
/** Warnign message level */
public final static int MSG_WARN = 1;
/** Informational message level */
public final static int MSG_INFO = 2;
/** Verbose message level */
public final static int MSG_VERBOSE = 3;
/** Debug Message level */
public final static int MSG_DEBUG = 4;
}
1.5 +39 -2
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java
Index: ComponentService.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/service/ComponentService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -u -r1.4 -r1.5
--- ComponentService.java 8 Feb 2002 13:04:46 -0000 1.4
+++ ComponentService.java 11 Feb 2002 15:42:19 -0000 1.5
@@ -52,6 +52,7 @@
* <http://www.apache.org/>.
*/
package org.apache.ant.common.service;
+import java.net.URL;
import org.apache.ant.common.antlib.AntLibFactory;
import org.apache.ant.common.util.ExecutionException;
@@ -83,10 +84,22 @@
throws ExecutionException;
/**
+ * Add a library path to the given library. The library path is used in
+ * the construction of the library's classloader
+ *
+ * @param libraryId the library's unique identifier
+ * @param libPath the path to be added to the list of paths used by the
+ * library.
+ * @exception ExecutionException if the path cannot be used.
+ */
+ void addLibPath(String libraryId, URL libPath) throws ExecutionException;
+
+ /**
* Experimental - define a new type
*
* @param typeName the name by which this type will be referred
- * @param factory the library factory object to create the type instances
+ * @param factory the library factory object to create the type
+ * instances
* @param loader the class loader to use to create the particular types
* @param className the name of the class implementing the type
* @exception ExecutionException if the type cannot be defined
@@ -99,7 +112,8 @@
* Experimental - define a new task
*
* @param taskName the name by which this task will be referred
- * @param factory the library factory object to create the task instances
+ * @param factory the library factory object to create the task
+ * instances
* @param loader the class loader to use to create the particular tasks
* @param className the name of the class implementing the task
* @exception ExecutionException if the task cannot be defined
@@ -108,5 +122,28 @@
String taskName, String className)
throws ExecutionException;
+
+ /**
+ * Import a single component from a library, optionally aliasing it to a
+ * new name
+ *
+ * @param libraryId the unique id of the library from which the
+ * component is being imported
+ * @param defName the name of the component within its library
+ * @param alias the name under which this component will be used in the
+ * build scripts. If this is null, the components default name is
+ * used.
+ * @exception ExecutionException if the component cannot be imported
+ */
+ void importComponent(String libraryId, String defName,
+ String alias) throws ExecutionException;
+
+ /**
+ * Import a complete library into the current execution frame
+ *
+ * @param libraryId The id of the library to be imported
+ * @exception ExecutionException if the library cannot be imported
+ */
+ void importLibrary(String libraryId) throws ExecutionException;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>