Tuesday, November 6, 2012

Auto complete ant targets on windows






I was having trouble remembering ant targets when building on windows so I thought it would be nice if I could just type the target names partially and press tab to auto complete them. A little bit of googling showed that its quite easy to do it on linux by modiyfing the .bashrc file.

I found that I could do this on windows by creating 0 byte files with the target names. So I wrote a small bat script  to do this for me. All you have to do is copy the follwing script into a file called antl.cmd into ANT_HOME\bin.


 @echo off  
 findstr "<target" build.xml > _o  
 echo targets in build.xml  
 echo.  
 FOR /F "eol=; tokens=1,2,3,4,5,* delims=,>,=, " %%i in (_o) do (  
      echo %%~k  
      REM. > %%~k  
 )  
 del _o  



After that if you do type antl into a shell where you are building your code the script creates the 0 byte files
for you. and voila!! you have auto complete