From 50e2bb1db1b097cac4fb73b4aa211a37ba2184b5 Mon Sep 17 00:00:00 2001
From: Simon Brandhof The JAR manifest must declare the name of the implementation class in the property Example of implementation:
+ * Example of implementationPlugin-Class
.
* This property is automatically set by sonar-packaging-maven-plugin when building plugin.
* package com.mycompany.sonarqube;
* public class MyPlugin implements Plugin {
- * {@literal @}Override
+ * {@literal @}Override
* public void define(Context context) {
* context.addExtensions(MySensor.class, MyRules.class);
* if (context.getSonarQubeVersion().isGreaterThanOrEqual(SonarQubeVersion.V5_6)) {
@@ -46,8 +47,8 @@ import static java.util.Objects.requireNonNull;
* }
* }
*
- *
Example of pom.xml:
+ * + *Example of pom.xml
** <project> * ... @@ -68,20 +69,35 @@ import static java.util.Objects.requireNonNull; * </project> ** + *
Example of test
+ *+ * MyPlugin underTest = new MyPlugin(); + * + *{@literal @}Test + * public void test_plugin_extensions_compatible_with_5_5() { + * Plugin.Context context = new Plugin.Context(SonarQubeVersion.V5_5); + * underTest.define(context); + * assertThat(context.getExtensions()).hasSize(4); + * } + *+ * * @since 5.5 */ @Beta public interface Plugin { class Context { - private final SonarQubeVersion version; + private final Version version; private final List extensions = new ArrayList(); - public Context(SonarQubeVersion version) { + public Context(Version version) { this.version = version; } - public SonarQubeVersion getSonarQubeVersion() { + /** + * Runtime version of SonarQube + */ + public Version getSonarQubeVersion() { return version; } @@ -89,10 +105,10 @@ public interface Plugin { * Add an extension as : *