LTntPnuts

A task of Ant for Pnuts.

Example

<?xml version="1.0"?>

<project default="test">
  <taskdef name="pnuts" classname="jp.gr.java_conf.koto.ltntpnuts.LTntPnuts" />
  
  <target name="test1">
    <echo message="--test1--" />
    <pnuts> <![CDATA[
      use("pnuts.lib");
      println("Hello World!");
      for (i = 0; i < 10; i++) {
        println(i);
      }
    ]]> </pnuts>
  </target>
  
  <target name="test2">
    <echo message="--test2--" />
    <property name="test" value="5" />
    <pnuts> <![CDATA[
      max = Integer(test);
      test = 0;
      for (i = 1; i <= max; i++)
        test += i;
    ]]> </pnuts>
    <echo message="${test}" />   <!-- echo "15"     -->
    <echo message="${max}" />    <!-- echo "${max}" -->
    <echo message="${i}" />      <!-- echo "${i}"   -->
  </target>
  
  <target name="test3">
    <echo message="--test3--" />
    <property name="hello" value="ThisIsTest" />
    <pnuts> <![CDATA[
      p = package();
      c = getContext();
      System::out.println(p.get("ant.file".intern(), c));
      System::out.println(p.get("ant.version".intern(), c));
      System::out.println(p.get("ant.java.version".intern(), c));
    ]]> </pnuts>
  </target>
  
  <target name="test" depends="test1,test2,test3">
  </target>
</project>

How To Use

Add ltntpnuts.jar and pnuts.jar to your CLASSPATH, and use like

<taskdef name="pnuts" classname="jp.gr.java_conf.koto.ltntpnuts.LTntPnuts" />

<pnuts> <![CDATA[
    your script
]]> </pnuts>

In the script, a variable whose name is used in Ant as a name of a property is a proxy for the property. The initial value of the variable is the string value of the property. An assignment to the variable makes the property's value be the string returned by toString() of the assigned value. Also, using package().get(...) and package().set(...), you can access a property whose name is not in the identifier form.

The variable task has this task object (org.apache.tools.ant.Task), if the property task is not defined. Similarly, package().get("ltntpnuts.task".intern(), getContext()) is also provide the task object.

License

is GPL.