TFS 2012 + Ant: Unable to access ant-launcher.jar

Today, I was was trying to create a build definition to run an Ant build from a Java project in Eclipse. First of all, I installed the brand new Team Explorer Everywhere for TFS 2012 RC (which looks really good!). Next step was to install the Build Extensions (to support Ant and Maven 2/3 builds). The installation went perfect, no problems at all.

Next step is to install Winant to support Ant builds on a Windows operating system. I also installed the Java SDK (including the JRE, otherwise you cannot run Eclipse). When all this was finished, I created my build definition like I normally do (I made a blog post about this a while ago).

Only.. there was a quite strange behavior when I queued my build. It only took 2 seconds. According to the build output, the Java project was successfully built, but the build was red. When I looked at the logs, I found this error:

Error: Unable to access jarfile C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\BuildExtensions\apache-ant\lib\ant-launcher.jar

This is strange, but on the other hand correct because ant-launcher.jar doesn’t exist on that location.

Solution: When you install the Java SDK and Winant, it creates 2 environment variables. The thing is that it creates ‘User’ variables, and not ‘System’ variables. So what you have to do is create 2 system variables and append the bin paths to the ‘path’ system variable. In my case:

“ANT_HOME = C:\Program Files (x86)\WinAnt”

“JAVA_HOME = C:\Program Files\Java\jdk1.7.0_04”

“Path = …………………;JAVA_HOME%bin;ANT_HOME%bin;”

Next, restart you build service (to catch the new added system variables) and queue your build. As you can see: Issue solved 🙂

Written by
Alexander Vanwynsberghe
Join the discussion

2 comments
  • Great tip. FWIW JAVA_HOME might not be required if you installed Java via the Oracle installation method as the build extensions will also go looking in the Registry to find a JAVA_HOME is there is not one set in the TFSBuild.proj or in the build services environment variables.

    However, ANT_HOME is required. You can always manually specify ANT_HOME in your TFSBuild.proj if you wanted but you are better off doing what you did and set it as a system wide environment variable.

    Glad TEE 2012 RC is working well for you though – let me know how you get on.

    Martin.

Menu

Alexander Vanwynsberghe

Belgium-based entrepreneur. Into technology, innovation and a bit of cycling and running too. Evangelist for everything related to smart-tech.