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