miércoles, 8 de febrero de 2012

Java SDK for TFS

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.

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 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());
        }

    }
}


Download: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=22616


Fuente:


http://blogs.msdn.com/b/bharry/´


Más información:


http://www.woodwardweb.com/programming/getting_started_1.html

No hay comentarios:

Publicar un comentario