Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »


To create a Sonar plugin, you need Java 5 or later. Maven is not required to build sources but it is highly recommended. Moreover this guide uses Maven to create and compile sources.

Creating a new plugin

Use the following command to create a new plugin in the directory defined by the parameter <pluginArtifactId> :

Parameters are :

  • <archetypeId> can either be 'sonar-basic-plugin-archetype' for a vanilla plugin or 'sonar-gwt-plugin-archetype' for a plugin with Google Web Toolkit extensions.
  • <sonarVersion> is the minimum version required to install the plugin, for example '2.1'.
  • <pluginGroupId> is the Maven group id of the plugin, for example 'com.mycompany.sonar.mysonarplugin'
  • <pluginArtifactId> is the Maven artifact id of the plugin, for example 'mysonarplugin'
  • <pluginVersion> is the plugin initial version, for example '0.1-SNAPSHOT'
  • <pluginPackage> is the root package, for example 'com.mycompany.sonar.myplugin'

Example :

Plugin manifest

A Sonar plugin is a set of POJOs that implement one or more Sonar extension points. Those extension points are interfaces or abstract classes that model an aspect of the system and define contracts of what needs to be implemented. POJOs are then placed in a container that implements the Plugin extension point.

Sonar must then have a way to retrieve the plugin class. For this, the plugin class must be declared in the JAR manifest. Maven can handle this stuff by adding this in your pom.xml file :

A plugin is packaged in a JAR file that must be deployed into the directory $SONAR_HOME/extensions/plugins before starting the server.

  • No labels