Using Team Foundation Server 2010 Build Service for Java Project using ANT

Posted by: Subodh Sohoni , on 11/22/2011, in Category Visual Studio, VSTS & TFS
Views: 101744
Abstract: In this article, we will explore how to use TFS 2010 for Build Management of Java Projects. We will use Eclipse based plug-in named Team Explorer Everywhere for creating a build definition that encapsulates an ant script and provides manageability to it.

In a previous article, I walked you through the process of using the various features related to Version Control of Team Foundation Server 2010. In this article now I will cover use of another service of TFS 2010 – Build Management for Java Projects. We will use Eclipse based plug-in named Team Explorer Everywhere for creating a build definition that encapsulates an ant script and provides manageability to it. Team Explorer Everywhere can be downloaded  over here.

Step 1: I assume that you have installed JDK, Eclipse and Apache Ant on your machine. If you have not configured environment variables, add the environment variable JAVA_HOME as JDK Path and add %JAVA_HOME%\bin; to the path. Also set the environment variable ANT_HOME to the ANT folder. In my case it was C:\Program Files\Java\Apache-Ant-1.8.1, so I added %ANT_HOME%\bin; to path.

Step 2: Install Microsoft Team Foundation Server 2010 Build Extensions that is downloadable from
http://visualstudiogallery.msdn.microsoft.com/2d7c8577-54b8-47ce-82a5-8649f579dcb6/ . It gives the ability to use Team Foundation Server 2010 Build service to do builds based upon Ant or Maven.

 



Step 3: To know how to create a Java Project in Eclipse and add it to TFS 2010 Version Control, you can go through my article -

To know how to create a Java Project in Eclipse and add it to TFS 2010 Version Control, you can go through my article - Using Team Foundation Server 2010 Version Control for a Java Project

Step 4: Let us now create build definition and queue build. To create an Ant script, add a new file to the Java project. Name it as build.xml

Step 5: Add the following code in this xml file

<project name="PwdValProject" default="compile">
   <target name="clean">

 

<delete dir="build"/>

    </target>
    <target name="compile" depends="clean">

<mkdir dir="build/classes"/>

<javac srcdir="." destdir="${DropLocation}\${BuildNumber}"/>

     </target>
</project>
 
Step 6: Checkin all the files

tfs-java-build-checkin

Step 7: Open the TeamFoundation Server Exploring perspective and expand the Tailspin Toys project. Select Builds node, right click on it and select New Build Definitions

tfs-new-build-definition
 
Step 8: Build Definition Creation wizard is started. In the first page of this wizard, enter the name of the build definition - Password Validator Build. You may optionally enter some description.

tfs-build-definition-validator

Step 9: Observe all the automation triggers on the trigger page. Keep the trigger to manual only but even if you select any automated trigger, it can be manually queued whenever required.

tfs-build-trigger

Step 10: Let the workspace to be used, be the default. On the Build Defaults page enter the drop location as \\MachineName\ShareName . If the shared folder does not already exists, then create and share it.

Step 11: On the Project File page of the wizard, browse to the Password Validator folder and then click the Create button

tfs-java-build5

Step 12: Select the option of MsBuild Configuration from existing Ant script and click Next

tfs-java-build6

Step 13: Drill down to the Build.xml file that you had checked in during the earlier step and Click Finish button

tfs-java-build7

Step 14: Let the retension policy be as it is

tfs-java-build8

Step 15: Click OK to complete the build configuration and close the wizard. You will find Password Validator Build definition appearing in the Builds folder of Team Explorer.

tfs-java-build9

Step 16: Right click on that build definition and select Queue New Build

tfs-java-build10

Click on the Queue button in the next page.

tfs-java-build11

You can view that the build is started and you will also be able to view the results once the build run is over.

Give a +1 to this article if you think it was well written. Thanks!
Recommended Articles
Subodh Sohoni, Team System MVP, is an MCTS – Microsoft Team Foundation Server – Configuration and Development and also is a Microsoft Certified Trainer(MCT) since 2004. Subodh has his own company and conducts a lot of corporate trainings. He is an M.Tech. in Aircraft Production from IIT Madras. He has over 20 years of experience working in sectors like Production, Marketing, Software development and now Software Training. Follow him on twitter @subodhsohoni


Page copy protected against web site content infringement by Copyscape


User Feedback
Comment posted by Winston on Friday, July 18, 2014 8:39 AM
This kind of stuff creeps me out

Post your comment
Name:  
E-mail: (Will not be displayed)
Comment:
Insert Cancel