user3762977 user3762977 - 2 months ago 17
Javascript Question

Ant scriptfilter use external script?

I have an Ant task that contains a scriptfilter and runs Javascript as part of the Ant build. How can I load this script from an external file instead of having it included in the Ant task?

How it works now:

<target name="x" description="x">
<copy todir=".">
<fileset dir=".\x" includes="**/*.txt"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<scriptfilter language="javascript"><![CDATA[

//Javascript goes here

]]></scriptfilter>
</tokenfilter>
</filterchain>
</copy>
</target>


Can I load the external script and assign it to a property, then insert the property between the CDATA tags? Or copy all of the Javascript including the CDATA tags and put that in the external file? Nothing I've tried along these lines works so far.

Updating with what worked based on answer below:

<target name="x" description="x">
<copy todir=".">
<fileset dir=".\x" includes="**/*.txt"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<scriptfilter language="javascript" src="myScript.js"></scriptfilter>
</tokenfilter>
</filterchain>
</copy>
</target>

Answer

The docs of scriptfilter indicate that it accepts a src attribute to pass the file path instead of inlining the script code.

Comments