--- Begin Message --- Hi,
I would like to add a new optional task for ant 1.7 - <scripttypedef>. (This task
was called beanshelldef, reflectdef previously). It behaves
a bit like <scriptdef> except that it expects the script to generate
a valid java class that can used by ant's reflection mechism to detect
the attributes and nested elements.
Only two languages can be used with it at the moment - beanshell 2.0beta and
groovy 1.0beta.


I have found it usefull for testing/writing small tasks.
For example a small task to check "deletonexit":

   <scripttypedef name="deleteonexit" language="groovy">
     import org.apache.tools.ant.Task
     import org.apache.tools.ant.BuildException
     import java.io.File
     public class DeleteOnExit extends Task {
        File file;
        public void execute() {
            if (file == null) {
               throw new BuildException("Missing attribute file");
            }
            file.deleteOnExit();
        }
     }
     DeleteOnExit;
   </scripttypedef>
or beanshell:
   <scripttypedef name="deleteonexit" 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();
        }
     }
   </scripttypedef>
   <deleteonexit file="tobedeleted"/>

Peter




--- End Message ---
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to