I am having issues using the <script>
tag in Ant and I am hoping someone can help. I want to use JavaScript in my Ant build.xml
. Something like the following:
<?xml version="1.0" encoding="UTF-8"?>
<project name="java" default="main" basedir=".">
<target name="main">
<script language="javascript"> <![CDATA[
println("hello, world")
]]> </script>
</target>
</project>*
Unfortunately this only displays and error:
build.xml:4: Could not create task or type of type: script.
I have located the required jar file (js.jar
) for this to work and moved it to ANT_HOME/lib
, but I am still stuck as of how to get this to work.
In addition to js.jar
, you need to add bsf.jar
and commons-logging-*.jar
to ANT_HOME/lib. In your Ant distribution, there is a file named docs/manual/install.html
. The Library Dependencies section of this HTML file documents where you can download these files.
println
isn't supported in JavaScript. Instead, use the following:
<project name="jsTest" default="main">
<target name="main">
<script language="javascript"> <![CDATA[
var echo = jsTest.createTask("echo");
echo.setMessage("hello, world");
echo.perform();
]]> </script>
</target>
</project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With