Wolfram Language BSF Scripting Engine
The naming conventions to note are that BSF uses the Bean concept, so object lookups in the registry only support the Bean["id"] function and not the WidgetReference["id"] notation of GUIKit`. Also note that BSF will not make language="mathematica" the default scripting language in the <script> tag, so <script language="mathematica"> must be used explicitly.
You need to update the /lib/ directory of an Apache Ant distribution to support the Wolfram Language as a script language. Copy the following four resources from the GUIKit` AddOn's Java/ directory and J/Link's distribution.
Note: Depending upon which version of BSF the Ant or third-party tool requires, you may actually have to grab the bsf-ibm.jar and bsf-ibm-Wolfram.jar versions from the Java-Alternatives/BSF/lib/ directory. Starting with Apache Ant Version 1.6.x and later, the new bsf.jar and bsf-Wolfram.jar should be used, since these are based on the Apache BSF classes, while Apache Ant Versions 1.5.x and earlier require the older bsf-ibm-* jars.
With the above files in the Ant distribution's path, you should then be able to use the <script language="mathematica"> Ant task. Many of the Ant properties and objects will be accessible from the Wolfram Language as Bean["id"] instances, and you can also specify settings for the MathematicaBSFEngine using Ant <property> instances. The most useful one would be to specify an alternate Wolfram Symbolic Transfer Protocol (WSTP) command line to launch the kernel other than the one used by default.
<project name="helloWorld" default="main" basedir=".">
echo = Bean["helloWorld"] @ createTask["echo"];
Bean["main"] @ addTask[echo];
echo @ setMessage["Hello World! From Mathematica :" <>
ToString[$Version] <> " " <> ToString[10!]];
<target name="main" depends="setup"/>