Share via


Maven Builds in Visual Studio Online

This post shows how to use Maven to build projects in Visual Studio Online using the Team Foundation Server plug-in for Eclipse.

Background

As I have been doing a bit of Java coding lately, I am starting to see some of the opportunities to highlight capabilities people likely didn’t know about.  For instance, did you know that you can build Java code in Visual Studio Online using Ant or Maven?  This post will show you how.

The really nice thing about Visual Studio Online as a remote Git repo is that you get FREE UNLIMITED PRIVATE REPOS.  You get 5 free basic user licenses, free work item tracking, and a whole lot more

Setting up the Team Foundation Server Plug-in for Eclipse

The first thing you’ll need to do is install the plug-in, as shown in the article Install the Team Foundation Server Plug-in for Eclipse.  The article is quite detailed with screen shots and is very easy to follow along with.  Just install the plug-in, restart Eclipse, and now you’re ready to connect.

Connecting to Visual Studio Online

In Eclipse, click on the Open Perspective item in the menu bar and then choose the Team Foundation Server Exploring perspective.

image

Next, click the Connect to Team Foundation Server link.

image

On the Add Existing Team Project page, click Servers, then click Add on the next panel, and finally provide the URL of your Visual Studio Online account. 

image

You are then prompted to sign in.

image

The next screen asks you to select the projects that you want to work with.  I am using the same one from my previous blog post where I showed a simple Git Push demo.

image

We can now manage work items, source, or even builds!

image

If we expand the Git Repositories item, we can see the commit that we performed in the last post.

image

That’s kind of cool, but I want to see something I didn’t expect, like using Maven builds of Java source, built by the hosted build controller in Visual Studio Online.  That’s right, I can use the hosted build controller online to build my Java solutions.

Building With Maven in the Hosted Build Controller

This is just so cool to me.  Go to the Builds item in the Team Explorer pane and choose New Build Definition.  A dialog appears:

image

I can choose to build manually, upon checkin, or even rolling builds or build on a schedule. 

image

I tell it the source settings where to find the project to build.

image

We want to copy output to the server.

image

The next screen is looking for a TFSBuild.proj file.  Click the Create button to create one.

image

ZOMG!  Are you kidding me?  Maybe this doesn’t shock you, but it does me… the build options are Ant or even Maven.  Since I just wrote a blog post on Using the Azure SDK for Java with Eclipse and Maven, we’ll choose Maven.

image

The next screen asks us for the location of the pom.xml file in the repository.

image

Our warning is now updated.

image

Easy enough… click OK, and the dialog to commit the changes appears.  We provide a commit message and then choose Commit and Push to make sure our changes are committed to the server.

image

Once we are done, the plug-in shows that a build is running…

image

We double-click on the build and inspect the log.

image

Once it is complete, we see a summary:

image

We can download the drop as a ZIP file and see the contents, and see that our App.java turned into a .class file.

image

I have known about the Eclipse integration for a long time, but I honestly haven’t ever seen using continuous integration to build a solution online using Maven.  That is just slick.

Summary

In case you didn’t catch what just happened… we make changes to our code locally and commit to our local repository.  When we are ready, we push those changes to a remote repository, at which time a continuous integration build kicks off and builds our project according to our Maven pom.xml file.  We set up literally zero infrastructure to make that happen, we just push our source to Visual Studio Online.  Oh yeah… and Visual Studio Online is free for up to 5 basic users and enables free unlimited private repos

For More Information

Installing the Team Foundation Server Plug-in for Eclipse

Build your Eclipse projects

What is Visual Studio Online? – Details how to sign up for the service, free for up to 5 users and unlimited private repos