ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r.mer...@siep.shell.com
Subject Ant / Java scripting extension
Date Tue, 24 Oct 2000 09:41:56 GMT

 Hello,

 I am not an 'official' ant developer (nor subscribed to the developers
mailing list),
 but was experimenting with the Script.java code
 to be able to access the pnuts java scripting language from within Ant.

 All that was required is an extra function that allows registration of
a
 language engine to the BSFManager and a call to:

 'manager.loadScriptingEngine(language);'

 right after creating the manager as Toyokazu.Tomatsu@japan.sun.com
discovered.
 JavaScript scripting continues to work.

 I tested this on: pnuts-beta1.09a  available at:
http://javacenter.sun.co.jp/pnuts/

 If you do this then you get full java scripting from within an ANT
build file.
 The script task can now be used in two ways:

  1) registering a new language with BSF e.g.
    <script registerlanguage="pnuts"
            registerclass="pnuts.ext.PnutsBSFEngine"
            registerextra="pnut" />

 2) evaluating a script in a particular language e.g.
    <script language="pnuts"><![CDATA[
      System::out.println("Hello, world.");
      import("java.net.InetAddress");
      import("java.io.*");
      function getHostName() {
         hostname=null;
         ipstr="unknownhost";
         catch(Exception,function (e) { return(hostname=ipstr); })
         ia=InetAddress::getLocalHost();
         ipstr=ia.toString();
         return(hostname=ia.getHostName());
      System::out.println("hostname = " + getHostName());
    ]]></script>

 This may be an interesting extension to Ant.
 Attached is my version of Script.java

 Regards,
 Robert Merkle

  

Mime
View raw message