Mathematica BSF Scripting Engine

Integrating with Apache Ant

You can use the Mathematica BSF engine that ships with the 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 function and not the WidgetReference["id"] notation of . 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 Mathematica as a script language. Copy the following four resources from the 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 Mathematica as instances, and you can also specify settings for the MathematicaBSFEngine using Ant <property> instances. The most useful one would be to specify an alternate MathLink command line to launch the kernel other than the one used by default.

Here is an optional setting for specifying the launch of the Mathematica kernel.

Here is an example of a complete Ant build file project.

New to Mathematica? Find your learning path »
Have a question? Ask support »