Erik Hatcher wrote:
So this would allow creating a filter, mapper, or other type dynamically?
Yes (well mapper's when the mapper type patch is applied).
Nice! Just a sanity check - there is no way to do this with scripting stuff in 1.6.1 is there?
I was about to say that one could not but this is not true:
<script language="beanshell"> import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildException; import java.io.File; public class DeleteOnExit extends Task { private File file; public void setFile(File file) { this.file = file; } public void execute() { if (file == null) { throw new BuildException("Missing attribute file"); } file.deleteOnExit(); } } project.addDataTypeDefinition("deleteonexit", DeleteOnExit.class); </script> <deleteonexit file="tobedeleted"/>
works fine!
<scripttypedef> does however handle namespace, antlib and <antcall> use.
package org.apache.tools.ant.taskdefs.optional;
/** * Class to define an ant definition using a script that * can return a class that is a normal ant task/datatype. * If the language is beanshell it must be 2.0 or higher. * The other scripting currently known to work is * groovy (1.0beta3). * <p> * Note that if there is anything incorrect with the script * the warning message is quite cryptic. * </p> * This class is based in part on o.a.t.ant.util.ScriptRunner. * The main difference is that it does not define * beans. This is for three reasons: * <ol> * <li>The definition may be used in another project.</li> * <li>It should be possible to convert to java later.</li>
And the third reason is? :)
removed..... (I had problems with groovy and assumed it was due to the references being defined).
Peter Also the orignal posted code had a error:
ClassLoader cl = createLoader(); Thread.currentThread().setContextClassLoader(cl); manager.setClassLoader(cl); should be: ClassLoader classloader = createLoader(); Thread.currentThread().setContextClassLoader(classloader); manager.setClassLoader(classloader);
Peter
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]