Wolfram Language BSF Scripting Engine
Integrating with Apache Ant
You can use the Wolfram Language BSF engine that ships with the GUIKit` framework in third-party applications that support BSF.
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.
Here is an optional setting for specifying the launch of the Wolfram Language kernel.
<property
name="bsf_engine_Mathematica_KernelLinkCommandLine"
value="-linkmode launch -linkname 'C:\\Program Files\\Wolfram Research\\Mathematica\\5.0\\MathKernel.exe'" />
Here is an example of a complete Ant build file project.
<project name="helloWorld" default="main" basedir=".">
<target name="setup">
<script language="mathematica"><![CDATA[
echo = Bean["helloWorld"] @ createTask["echo"];
Bean["main"] @ addTask[echo];
echo @ setMessage["Hello World! From Mathematica :" <>
ToString[$Version] <> " " <> ToString[10!]];
]]></script>
</target>
<target name="main" depends="setup"/>
</project>