-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the sonar-unibz wiki!
MEMO for me for further development:
To create a custom plugin you first have to create a pom.xml that is the build file used by maven. The entry point for the plugin is a class that extends the class org.sonar.api.SonarPlugin
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.unibz.sonar.mairegger</groupId>
<artifactId>tools.sonarqube.idemetadata</artifactId><!--change artifactId-->
<packaging>sonar-plugin</packaging>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>5.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.7</version>
<extensions>true</extensions>
<configuration>
<pluginKey>idemetadata</pluginKey>
<pluginClass>it.unibz.sonar.mairegger.plugin.ClassComplexityPlugin</pluginClass>
<pluginName>Custom Plugin for SonarQube developed by Michael Mairegger</pluginName>
<pluginDescription>TODO</pluginDescription>
</configuration>
</plugin>
</plugins>
</build>
</project>Lets focus on the pluginClass line. This line indicates where the entry point for the plugin is found. This module structure rapresents the exact path to the file where the java class is found. The path must be constructed as follows: src/main/java/pathInPluginClass otherwise maven will complain that the entry point could not be found.
Install maven and run following command on the root folder where the pom.xml file is located.
mvn clean installCopy the created jar file to the extensions/plugin directory found under the install directory of SonarQube.
Do not forget to restart SonarQube in order to reload the plugin.