Wednesday, 24 July 2013

Getting Apache Ant Working in Cygwin

I've just had some fun setting up Ant under Cygwin.  It all came down to getting the PATHs working correctly when the installed directories had spaces in their names.  The solution was to use cygpath to first shorten into dos format then unix-ify the paths.  e.g.

LONG_PATH=/cygdrive/c/Program\ Files/Java/jdk1.7.0_25/

DOS_PATH=`cygpath -d "$LONG_PATH"`




echo $DOS_PATH
C:\PROGRA~1\Java\JDK17~1.0_2\

UNIX_PATH=`cygpath -u $DOS_PATH`

echo $UNIX_PATH
/cygdrive/c/PROGRA~1/Java/JDK17~1.0_2/

So a one-liner to do the whole lot

UNIX_PATH=`cygpath -u $(cygpath -d "$LONG_PATH")`

No comments: