Monday 26 September 2011

Installing ANT on Windows XP

I found the following quick instruction for installing ANT 1.7.0 on Windows XP.

  • Download ANT 1.7.0 from Apache ANT
  • Unzip the zip file and put it in some folder (for example c:\ant)
  • Set ANT_HOME environment variable to the Ant location
  • (MyComputer -> Properties -> Advanced -> Environment Variables -> User Variables for Administrator -> Set New Variable Name as "ANT_HOME" and set New Variable Value as C:\ant)
  • Now set Path variable to point to your ANT bin directory (User Variables for Administrator -> Click on Path variable -> Append the ANT bin directory location, say %ANT_HOME%\bin)
  • Open a command prompt and type "ant", you should see ANT is working now. In case of any problem try the command to print value of ANT_HOME - echo %ANT_HOME% and see the value for ANT_HOME

I see the big problem here. Let’s say next year a new version of ANT 1.7.1 will be released with great improvement or weird bug fixes. What is the owner of manual above is going to do? I think the manual’s writer will just upgrade content of c:/ant/ folder with a new version, but what if new ANT 1.7.1 version will be not compatible with already existing ANT script, but in the same time you want to try a new version and migrate your script from ANT 1.7.0 to let's say ANT 1.8.0. In my case I still use ANT 1.6.5 for a few scripts, but would like to use ANT 1.7.0 for new ones.

I posted my solution for installing ANT 1.7.0 on Windows XP below:

  • Download ANT 1.7.0 from Apache ANT
  • Unzip the zip file and put it in the version specific folder (for example F:\apps\apache-ant-1.7.0)
  • Create batch file setant170.bat with the following content in your usual working folder
@echo off
set ANT_HOME=F:\apps\apache-ant-1.7.0\
set PATH=%PATH%;%ANT_HOME%\bin
  • Open a command prompt, navigate to working folder and run setant170.bat
  • To verify installation run ANT in command promty and you should see Buildfile: build.xml does not exist!
    Build failed

Of course as soon as you close the command prompt window you will lose the ANT_HOME value, but is still very convenient, because now you can jump between different versions on ANT without problems. You just need to install a new ANT release and create one more batch file.

Any comments?

No comments:

Post a Comment

xslt padding with characters call template for left pad and right pad

  Could a call-template be written that took two parameters ?   a string, and a   number) return the string with empty spaces appended t...