From the beginning, extensibility of TFS was a core design principle – both to enable great 3rd party partners (like Ekobit, Urban Turtle, InCycle and more) and because almost all development shops have a need to customize the tools they use.  As such we’ve provided a .NET library for interacting with and extending TFS from day one.  And I’m always amazed with the things people are able to do with it.

Today I am pleased to announce that we are now also extending this the Java side of the house.  We have just made the Team Foundation Server SDK for Java available as a public download.

Now you will be able to extend TFS using Java just as easily as you can with .NET.  This is going to enable teams using Team Explorer Everywhere to fully customize their development environment – in Eclipse or outside.  Further, we have a few 3rd party ISVs that are in the process of adding TFS support to their software offerings using our new SDK.  Their feedback has been great in helping make sure we have a solid and easy to use SDK.  Stay tuned in the coming weeks and months for news of these new partners.

The TFS SDK for Java includes the following:

  • A redistributable JAR file containing the TFS API’s.  This is a the same Java code that is used by Team Explorer Everywhere in the TFS plug-in for Eclipse and the Cross-platform command line client.  It provides access to version control, work item tracking, build and other functionality in TFS from your own Java based application.   We ship this as a single JAR file containing all the code and Java dependencies to make is easy to include in your own applications.
  • The native code libraries used by the TFS API. We have a small amount of JNI code in the API to handle functionality that is not natively supported in Java on all the platforms that we support (such as access to Kerberos for authentication, or integrating with Keychain on the Mac).  We are making this native code available, also redistributable and compiled for Windows (x86, x64), Mac (Universal), Linux(x86, x64, ppc), HP-UX (ia64_32, pa_risc), Solaris(sparc, x86, x64) and AIX (ppc).
  • Full API documentation in Javadoc format.  This is the same code documentation used by our developers, written by our developers.
  • Code Samples. The team are very aware that getting started with this large code base can be quite a challenge, therefore they have put together a bunch of sample code to try and get you started.  It includes: 
    • Sample custom check-in policy
    • Sample custom work item controls (including a Radio Button control, Simple Button control, File Source drop-down and a sample External Source drop-down)
    • A set of sample console applications utilizing build and version control capabilities
    • A series of simple snippets demonstrating many aspects of the API including Work Items, Version Control and Build access.
    • Instructions for building and an Ant based build script to get you started.

The license terms for the SDK are here.  We’ve tried hard to make sure the license is as helpful as possible.  You can use the SDK in your own applications redistributing the files listed for no charge.  You can create applications that run on any of the operating systems supported by the API.  There is no requirement that people must have Team Explorer Everywhere installed or even have a license for it – however you still need to make sure that anyone who is talking to TFS is licensed to use it (usually through a Client Access License).

Using the API should be very familiar to developers who have had experience with the .NET API – however the TFS SDK for Java is a proper Java implementation so conventions will be slightly different (for example it uses standard Java style collections along with getters and setters just like you would expect).  The following example show you how easy it is to query work items from Java using the SDK.

import com.microsoft.tfs.core.TFSTeamProjectCollection;
import com.microsoft.tfs.core.clients.workitem.WorkItem;
import com.microsoft.tfs.core.clients.workitem.WorkItemClient;
import com.microsoft.tfs.core.clients.workitem.project.Project;
import com.microsoft.tfs.core.clients.workitem.query.WorkItemCollection;

public class RunWorkItemQuery
{
    public static void main(final String[] args)
    {
        TFSTeamProjectCollection tpc =
            new TFSTeamProjectCollection("http://tfs2010:8080/tfs/DefaultCollection");

        Project project = tpc.getWorkItemClient().getProjects().get("Tailspin Toys");
        WorkItemClient workItemClient = project.getWorkItemClient();

        // Define the WIQL query.
        String wiqlQuery = "Select ID, Title from WorkItems where (State = 'Active') order by Title";

        // Run the query and get the results.
        WorkItemCollection workItems = workItemClient.query(wiqlQuery);
        System.out.println("Found " + workItems.size() + " work items.");
        System.out.println();

        // Write out the heading.
        System.out.println("ID\tTitle");

        // Output the first 20 results of the query, allowing the TFS SDK to page
        // in data as required
        final int maxToPrint = 20;
        for (int i = 0; i < workItems.size(); i++)
        {
            if (i >= maxToPrint)
            {
                System.out.println("[...]");
                break;
            }

            WorkItem workItem = workItems.getWorkItem(i);
            System.out.println(workItem.getID() + "\t" + workItem.getTitle());
        }
    }
}

 

The team have been hard at work creating samples and snippets to help you learn how to use the API, however if you have any particular examples that you would like to see that they haven’t included then please let me know in the comments and we’ll see what we can do.  Alternatively, head over to the forums where the team will be more than happy for the feedback and to assist where possible.  Our very own Martin Woodward has also said that he’ll be blogging some examples and tutorials soon on his personal site.

As I’ve said before, from day one we have wanted TFS to be an open platform upon which anyone can build their favorite development experiences.  This SDK for Java is an important milestone for us in ensuring equal access to the same API’s that we have developed for our own use and will hopefully enable many people people to build on our platform.  It’s also further evidence that we are serious about building a great ALM solution for truly heterogeneous teams.  I’m very excited to see what people are going to do with the SDK.  If you create something interesting then be sure to let me know.

Brian