One of our ALM Rangers Hosam Kamel from our Center of Expertise has recently just finished a large project that involved integrating several different technologies and platforms. In this project he made several key learning's and wanted to share them with the ALM Community!
Thanks Hosam!!
****************************
Overview
Quality is not something that can be easily added later. Problems that are too complex, too obscure, or are discovered too late in the product cycle are usually not fixed, the Code Analysis feature of Visual Studio performs static code analysis on code to help developers identify potential design, globalization, interoperability, performance, security, and a host of other categories of potential problems. (In Visual Studio 2013 a lot of new enhancement has been added you can check this blog post for more details What is New in Code Analysis for Visual Studio 2013)
Many organizations use different development tools to target different software platforms while Visual Studio is often the tools of choice for the Widows platform, Eclipse-based Integrated Development Environments (IDEs) are almost invariably the tools of choice, TFS is Microsoft’s collaboration platform for software development teams. It provides services such as source control, management of work items, request management, a test platform, and build and release management and it helps the organizations to avoid having multiple Application Lifecycle Management (ALM) tools and methodologies.
In this post I’ll focus more on how you can use Team Explorer Everywhere to build Java project and run code analysis using SONAR as a build step.
Tools
Multiple tools will be integrated together to achieve this scenario.
· Eclipse
· Microsoft Visual Studio Team Foundation Server 2012 Build Extensions: The Team Foundation Server Build Extensions provide the ability to execute Ant or Maven builds from Team Foundation Server and publish the results of the build along with any associated JUnit test results back to Team Foundation Server.
· Apache Ant: The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications.
· SonarQube (previously called Sonar) is an open source quality management platform, dedicated to continuously analyze and measure technical quality, from project portfolio to method. If you wish to extend the SonarQube platform with open source plugins.
· SonarQube Ant Task: The SonarQube Ant Task allows integration of SonarQube analysis into an Apache Ant build script.
Integration Scenario
Developers work with Eclipse and integrated with Team Foundation Server. When developers want to build their changes, they can push their changes to Team Foundation Server and either setup a continuous integration build or kick-off the build manually.
As a part of build process, SONAR code analysis will be kicked-off to run the code analysis on the latest pushed code on TFS and the result will then get published to SONAR portal.
Java developers can check the code analysis from SOANR portal fixing the issues locally and re-run the build again if needed.
Install and configure Microsoft Visual Studio Team Foundation Server 2012 Build Extensions
· Download the step file from Visual Studio Extension gallery, You must have the following installed on the same server that is hosting the Team Foundation Build Agent:
- Java JDK (the latest one available from your JDK vendor is recommended)
- Ant (if Ant support is required).
Install and configure SONAR Ant Task
- Just download the SonarQube Ant Task on your machine from here http://repository.codehaus.org/org/codehaus/sonar-plugins/sonar-ant-task/2.1/sonar-ant-task-2.1.jar
- Place it in the Ant library folder “lib”
Create a new build definition based on Ant
· Click on “New Build Definition”
· Follow the wizard
· Make sure on the “Project File” step to pick “MSBuild Configuration from Existing Ant Buildfile”
- Point to your build.xml file
Modify the build script to kick-off SONAR
- Open the build.xml file and add the following lines
- The typical configuration should be as below
Kick-off the new build based on the build definition we created
- Wait for the build to complete
- Once the build succeeded you can navigate now to SONAR portal (typically http://localhost:9000) to check the projects and the latest analysis reports.
- Select the project by clicking on the project name and you will get access java code analysis reports for that project
In Closing
Visual Studio provide a great tool to ensure quality with enhanced code review workflows to facilitate the collaboration among developers and provide a rich environment to review code and propose changes.
In Team Foundation Server TFS we put more focus on the Cross-Platform Development, You use the languages that are right for your projects, and you target the platforms that let you reach your customers. Platforms like Windows Phone, Windows, Android, iOS, Linux, and more, with data and services in the cloud, As far as TFS is concerned, all code is created equal. You can use TFS to share code and to build continuously across all your platforms. And TFS can help you collaborate within your team, and with your customers.
About the Author:
Hosam is a Senior Software Engineer who have been working in the field for around 5 year for major software companies in the region, like ESRI (Northeast Africa) & ITWorx. Hosam mainly develops using Microsoft technology stack in many projects targeting customers in the Middle-East. Hosam is a star-member and top-answerer at the Microsoft official ASP.NET forum for the years 2007 ,2008 and 2009 under user name "HosamKamel". Hosam gave many talks in developer-community events included internal session at ESRI & ITWorx along with other public ones like DotNetWork gatherings, CodeCamp 2009 and 2009 ESRI Middle East and North Africa User Conference (MEAUC). Hosam now works at Microsoft MEA HQ in our center or excellence and is #Software Architect, Developer,#Blogger,Speaker,#Egyptian,Developer and Platform Evangelist (#DPE), Visual Studio ALM Ranger (#almrangers) and above all else is a GEEK!