sonarqubesonar-plugin

How to reach PropertyDefinitions properties


In the JavaDoc, it's clearly defined how to set a property in SonarQube using org.sonar.api.config.PropertyDefinition in a plugin, however there is nothing on how to get it.

It seems to not work like System.getProperty(key) in Java, so, should I declare a new class that implements Configuration? Is there a way to reach these properties back properly?


Solution

  • You can get a Configuration object through a Context one or by injecting it through extension point constructor:

    public MyExtensionPoint(Configuration config) { this.config = config; }

    Use context.config() to get your Configuration object.

    Then use configuration.get("key") to get the property.