Pages

samedi 27 juin 2009

Running Sonar against a GAE Java project

The GAE SDK generates a project that is not Maven enabled. Namely, source and target directories does not follow Maven conventions.

Sonar may be run against such a project by using Sonar light mode configuration.
  • We will write a minimal POM project and instruct Sonar to run only static analysis (code violations, complexity).
  • For the time being, we will put dynamic analysis (unit test results and code coverage) aside as it requires code to be executed, therefore dependencies configuration. Sonar may actually report dynamic analysis if surefire and cobertura reports are available.

But let's start with some simple configuration.
You will need Sonar (1.8 minimum) and Maven 2.


Write a POM


Open the Eclipse project generated by GAE SDK and create a pom.xml file at the project's root.

Add your project's information (replace cirrus in the snapshot below by your project's information)

Add GAE build information. You should not have to change these lines.

Add some Sonar configuration to skip dynamic analysis. You should not have to change these lines.

Depending on your repository and mirror, you may have to download sonar jars from the Codehaus repository.


Run Sonar


Now run sonar from the shell command line or configure an Eclipse launcher. As the Sonar maven plugin will send out data to Sonar during the build, the Sonar server must be running.

It may take a while the first time, as maven will download tons of libraries and plugins.

When it's done, Sonar's analysis report is available at http://localhost:9000.

You may find usefull information about Sonar configuration including "Non-Maven" projects in Analyzing Java Projects

Aucun commentaire: