ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conor MacNeill <co...@cortexebusiness.com.au>
Subject ScriptDef
Date Wed, 13 Feb 2002 04:22:42 GMT
I have prototyped a new task in mutant which I'd like to get feedback 
from anyone interested. It is called scriptdef and allows you to define 
a task as a script. Here is an example

<project name="scripttest" default="test">
   <libpath libraryid="antopt.script" 
file="/home/conor/dev/antdev/jakarta-ant/lib/optional/bsf.jar"/>
   <libpath libraryid="antopt.script" 
file="/home/conor/dev/antdev/jakarta-ant/lib/optional/js.jar"/>
   <import libraryid="antopt.script" name="scriptdef"/>
   <scriptdef name="scripttest" language="javascript"> <![CDATA[

   var test = "hello";

   function setTest(x) {
      test = x;
   }

   function execute()
   {
     java.lang.System.out.println("test is " + test);
     modelElementClass = context.getModelElement().getClass().getName();
     java.lang.System.out.println("model element class is " + 
modelElementClass);
   }
     ]]> </scriptdef>

   <target name = "test">
     <scripttest test="goodbye"/>
   </target>
</project>

The first two lines just provide additional classpath info for the 
script Ant library. Normally these would be in a config file rather than 
the build file but I wanted to test them out.

The result of running this is

test:
test is goodbye
model element class is org.apache.ant.common.model.BuildElement

BUILD SUCCESSFUL

Total time: 2 seconds


This is built on BSF and works with javascript (Rhino) although I have 
not tried any other scripting language.

Thoughts?

Conor



--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message