Sonar analysis for a non-maven based Java project

In my previous post, i had explained the steps for installation and configuration of Sonar to analyse a maven based project in eclipse. You can refer the same here.

With Sonar version greater than 2.6, there has been many refactoring done. One of the major thing was removal of tight coupling of Sonar with maven. So, what this means is now you can analyse your non-maven based project without much of trouble!

5. Create a “sonar-project.properties” file and put this file to the root folder of your java project.

Below is a skeleton of this file. Edit this file as per your project.

# required metadata
sonar.projectKey=sanjit:JavaProject
sonar.projectName=Java Project
sonar.projectVersion=1.0
# path to source directories (required)
sources=D:\\sanjit\\workspace\\test\\JavaProject\\src
# path to test source directories (optional)
#tests=testDir1,testDir2
# path to project binaries (optional), for example directory of Java bytecode
#binaries=binDir
# optional comma-separated list of paths to libraries. Only path to JAR file and path to directory of classes are supported.
#libraries=path/to/library.jar,path/to/classes/dir
# Uncomment those lines if some features of java 5 or java 6 like annotations, enum, ...
# are used in the source code to be analysed
#sonar.java.source=1.5
#sonar.java.target=1.5
# Uncomment this line to analyse a project which is not a java project.
# The value of the property must be the key of the language.
#sonar.language=cobol
# Advanced parameters
#my.property=value

6. Go to the root of your java project and run this command : sonar-runner.bat

Upon successful execution of above command, check in the sonar dashboard. It should now be showing sonar analysis of your project. Below is a snippet of the sonar-runner.bat output for your reference:-