The Most Useful Code I've Written in Weeks

Posted by Derek Wyatt on September 1, 2012
SBT's automatic recompile when a file changes made me realize that I wanted that functionality with everything I do, and so I scripted it.

I’d like to say that I write useful code all the time, but let’s face facts… useful code doesn’t come around all that often. In my new job I’m using Maven instead of SBT and I miss the cool tilde modifier in a big way. And now that I’m using the Artima book building strategy - which is based on Ant - I miss it even more.

So I finally wrote this little script that’s saving my ass.

touch -t197001010000 $sentinel
while :
  files=$(find . -newer $sentinel -a '(' $fileSpec ')')
  if [ $? != 0 ]; then
    exit 1;
  if [ "$files" != "" ]; then
    touch $sentinel
  sleep 0.1

I tend to use it in a number of different ways, but one of the simple ones is like this: "mvn test" -name \*.java

And that’s all she wrote.