Saturday, December 8, 2007

Dot Directories with Groovy

Netbeans, Eclipse and Maven, to name a few, create folders that have a period (a "dot") as the first character in the folder name during their install processes. Windows does not allow its users to create a similarly named folder in Windows Explorer. The Getting Started tutorial for Groovy states that an alternative to placing jar files in the Groovy installation's lib folder is to place them in
${user.home}/.groovy/lib
I decided that I'd use Groovy to create the necessary .groovy folder and I found it to be very simple:
props = System.getProperties();
userHome = new File(props.getProperty("user.home"));
groovHome = new File(userHome, ".groovy");
groovHome.mkdir();
Running the script created the necessary folder C:\Documents and Settings\Greg\.groovy