* “running jruby scripts from ant – WWWOW”
I have lots of ant build files, many times i use ant even for tasks apart from building like portable scripting sort of tasks.
Now, if rather than sending those ant files into recycle bin, if i add ruby/jruby power into ant rather than replacing it, then i will be in the best of both worlds.
This straight forward task took me , sometime to figure out, as there was no clear directions nowhere on how to configure it.
2. Install ant 1.7.0 by following method
cp apache-ant-1.7.0-bin.zip /opt
cd /opt
unzip apache-ant-1.7.0-bin.zip
ln -s apache-ant-1.7.0 ant
export ANT_HOME=/opt/ant
export PATH=$ANT_HOME/bin
3. copy $JRUBY_HOME/lib/bsf.jar to $ANT_HOME/lib
4. type the following file hello-from-jruby.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<project name=”ashishPrj”>
<property environment=”env”/>
<script language=”ruby” manager=”bsf”>
<classpath>
<fileset dir=”${env.JRUBY_HOME}/lib” includes=”*.jar” />
</classpath>
print ‘hello world’
</script>
</project>
5. Now, run as
ant -f hello-from-jruby.xml
The output will be something like:
ashish@singularity:~/jrubyprg# ant -f hello-from-jruby.xml
Buildfile: hello-from-jruby.xml
hello world
BUILD SUCCESSFUL
Total time: 2 seconds
now, enjoy power of ant’s XML tags, java, jruby ALL IN ONE
We will take up some more complex scripts in next article.
happy jrubying
No comments yet.



