Tuesday, 14 April 2009

Ant script for renaming Java files to Groovy

At the moment I am starting to study Groovy, which is an alternative language (to Java itself) that can be used on the Java Platform.

It's main advantage (over Java) is its "expressiveness", meaning that the same program can be written using less instructions, hence theoretically increasing productivity. In that regard it is quite similar to Smalltalk.

Groovy is a superset of the Java language. This means that any Java program is by default also a Groovy program (the opposite not being necessarily true). I created a very simple Ant file that enables me to convert all my .java files to .groovy (and back again):

<project name="Groovy" basedir="." default="javaToGroovy">

<target description="Changes Java file names to Groovy" name="javaToGroovy">
<move todir="" file="src">
<mapper type="glob" to="*.groovy" from="*.java">

<target description="Changes Groovy file names to Java" name="groovyToJava">
<move todir="" file="src">
<mapper type="glob" to="*.java" from="*.groovy">


Please bookmark, your votes are noticed and appreciated:
Bookmark and Share

1 comment:

  1. So is this a file renamer? Remeber that not ALL Java is Groovy compatible, but I guess 99% is.