Package org.sonar.api

Class Plugin.Context

  • Enclosing interface:
    Plugin

    public static class Plugin.Context
    extends java.lang.Object
    • Constructor Detail

      • Context

        public Context​(SonarRuntime sonarRuntime)
        For unit tests only. It's recommended to use org.sonar.api.internal.PluginContextImpl.Builder to create instances of Plugin.Context. The configuration returned by {@see #getBootConfiguration()} is empty.
    • Method Detail

      • getSonarQubeVersion

        public Version getSonarQubeVersion()
        Shortcut on getRuntime().getApiVersion() since version 6.0.
        Returns:
        the version of SonarQube API at runtime, not at compilation time
        Since:
        5.5
        See Also:
        getRuntime()
      • getRuntime

        public SonarRuntime getRuntime()
        Runtime environment. Can be use to add some extensions only on some conditions.
        Since:
        6.0
      • addExtension

        public Plugin.Context addExtension​(java.lang.Object extension)
        Add an extension as : Only a single component can be registered for a class. It's not allowed for example to register:
        • two MyExtension.class
        • MyExtension.class and new MyExtension()
      • getExtensions

        public java.util.List getExtensions()
      • getBootConfiguration

        public Configuration getBootConfiguration()
        The configuration that contains only the few properties required to bootstrap the process, for example: - conf/sonar.properties and persisted properties on web server and Compute Engine sides. The default values defined by plugins are ignored. - command-line arguments on scanner side. Default values or properties persisted in server are ignored.
        Since:
        7.1