views:

282

answers:

5

A very small portion of our codebase is some legacy Java code. I'm trying to add a new build that would invoke ant to build this project.

The first problem is that TFS doesn't allow you to create a build that doesn't build a .Net solution. I got around this by copying a previous build file and adding an EndToEndIteration task which is the entry point for the build.

The problem is that none of the usual build variables are populated - $(BuildDirectory), $(SolutionRoot) - all blank. This pretty much means I can't invoke my ant task without hardcoding the paths (which I definitely can't do).

Any ideas?

A: 

I think you are using the wrong tool for the job here - TFS will never be a good solution for building any other than .NET applications. I think you are better off just using ant in a standalone capacity.

Andrew Hare
I guess... but TFS is supposed to be language independent...
Jaco Pretorius
@Andrew: **Never** is a long, long time :) There are a couple of initiatives to provide TFS build services for other platforms such as Teamprise Build Extensions http://labs.teamprise.com/build/ (2008) http://sstjean.blogspot.com/2010/02/teamprise-build-extensions-for-tfs-2010.html (2010). More information about cross-platform initiatives in TFS 2010: http://blogs.msdn.com/bharry/archive/2010/03/04/microsoft-visual-studio-team-explorer-2010.aspx
Alfred Myers
+1  A: 
  1. If you don't already have one, create a task that will store and retrieve environment variables, you're definitely going to need them doing anything java related (I believe there is one in the MSBuild extension pack)
  2. Create a custom task to wrap Ant or use the Script task from the MSBuild Community Tasks collection
  3. Run it a million times and fix the problems as you go, it's usually easier and faster to do this from the command line, so make friends with msbuild.exe inside the terminal

You should be able to pass around any info you want between environment variables, making whatever you want to do possible. I'm not going to recommend hard-coding paths to you, but you have to put the config somewhere and it's all a trade off of what you want to change and how you want things organized. If you really need to, you can push all the config into a database and suck it down with one of the SQL tasks in the above links, but just remember you're adding a considerable amount of complexity that may be unnecessary.

Ask yourself:

  • how often is this value likely to change?
  • what is the full set of tasks that would need to be done if it changes?

Write the answers to that down somewhere and make sure everybody on the team understands it. When it comes to build systems in my opinion "less is more". Find the simplest way to do it, and do that until that becomes unacceptable and only then add complexity... TFS is complicated enough already.

slf
+1  A: 

You may want to take a look at Teamprise Build Extensions which allows building Ant or Maven tasks from TFS.

Alfred Myers
The Teamprise build extensions do exactly what the questioner is after. You can even use the Teamprise client to create the TFSBuild.proj file for you after you have pointed it to a Ant build.xml file or a Maven pom.
Martin Woodward
A: 

Thanks for all the answers.

In the end I resorted to including an empty solution next to the build file. This way all the variables are populated and I simply included a which did everything I wanted.

Jaco Pretorius
A: 

Can you pls illustrate how u created that empty solution ? was that a java one ? plsss explain

Amira
Amira, if you have a question, please search, then actually ask a question. Don't answer with another question. Thanks.
Robaticus
I agree with Robaticus, but if your question hasn't been answered, please ask it and link here...
Jaco Pretorius