To create a Sonar pluginSonarQube plugin, you need Java 6 or later. Maven is not required to build sources but it is highly recommended. Moreover this guide uses Maven to create and compile sources.
compile and package the plugin.
Creating a New Plugin
The recommended way is to duplicate one of the examples located in the directory / plugins directory of this the following GitHub repository: https://github.com/SonarSource/sonar-examples. If you donaren't which one must be usedsure which plugin to use, then select the plugins/sonar-reference-plugin.
There are two ways to copy the example:
- if you have Git, then just clone the repository
- if you don't have Git, download the repository at https://github.com/SonarSource/sonar-examples/zipball/master
Deploying a Plugin
mvn clean install
from the root directory, for example /path/to/sonar-reference-plugin. The JAR file is generated in the target directory /target. It must be copied to the directory /extensions/plugin of your Sonar installation. The server must be restarted..
Then, copy the JAR to the SONARQUBE_HOME/extensions/plugins directory and restart your SonarQube server.
Next step is: coding a plugin.
Working on SonarQube Eclipse Plugin in Eclipse
- Java at least 1.6
- Maven at least 3.0.4
- clone https://github.com/SonarSource/sonar-eclipse
- run an initial Maven build from the command line: mvn clean install
- import everything into Eclipse as a Maven project (the Tycho connector should be installed automatically)
- in Eclipse preferences, configure a new variable in Run/Debug > String substitution: M2_REPO = /path/to/your/local/m2/repo
- open and activate one of the following target platforms:
- If you want to work with Kepler: target-platform-e43/target-platform-e43-dev.target
- If you want to work with Juno: target-platform-e42/target-platform-e42-dev.target
- you may have to use quick fix to ignore some m2e Lifecycle execution not covered errors