Build and Analyze a .net 4 project in Maven Sonar – Part 2

Time has come to  configure  maven. Before that run mvn –version in cmd and double check whether maven is installed correctly. if maven is ready next thing to do is creating the pom.xml file. Following is a sample pom.xml file for a .net 4 application. it includes all the necessary plugins. Below mentioned plugin versions are compatible with sonar 2.8 and maven 3.0.3. If you are using any other versions of maven or sonar(remember you should have atleast sonar 2.4 and maven 3.0) please check plugins’ compatibility, otherwise it would be a big headache.

<project xmlns=”http://maven.apache.org/POM/4.0.0&#8243; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd”&gt;
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.maven.dotnet.example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<name>YourProject</name>
<packaging>sln</packaging>
<properties>
<visual.studio.solution>YourProject.sln</visual.studio.solution>
<visual.test.project.pattern>*.Tests</visual.test.project.pattern>
<dotnet.tool.version>4.0</dotnet.tool.version>
<sonar.language>cs</sonar.language>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar-plugins.dotnet</groupId>
<artifactId>maven-dotnet-plugin</artifactId>
<version>0.5</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.0-beta-2</version> <configuration>
<language>cs</language>
</configuration>
</plugin>
</plugins>
</build>
</project>

Now keep this in the folder where your .sln resides.You can see that I have defined two plugins in my pom. Those are maven-dotnet and sonar-maven. Be carefull there are two types of sonar-maven plugin, org.codehaus.mojo:sonar-maven-plugin and org.codehaus.sonar:sonar-maven-plugin. I’m using the first one because it make our lives easier. need to know how???? follow  http://docs.codehaus.org/display/SONAR/Frequently+Asked+Questions#FrequentlyAskedQuestions-Whatisthedifferencebetweenorg.codehaus.mojo%3Asonarmavenpluginandorg.codehaus.sonar%3Asonarmavenplugin%3F

Next you need to install several applications which are needed by maven-dotnet plugin. Those are

  • MsBuild
  • Gallio
  • PartCover
  • NCover
  • Source Monitor
  • Fx Cop
  • Style Cop
  • Mono Gendarme

http://maven-dotnet-plugin.appspot.com/usage.html provides a comprehensive guide of these applications. Configuring the settings.xml file in maven/conf is the next thing you must do………………………….let’s see that in the next blog post 🙂