How to use sonar.version, sonar.plugin.api.version and sonarQubeMinVersion?

Hi,

I’m developing a plugin and wonder how to find and set the values of sonar.version, sonar.plugin.api.version and sonarQubeMinVersion correctly?

If I only ever want to use the latest version, that seems easy. But how can I make sure that my plugin is also compatible with older versions?

My understanding for sonar.plugin.api.version:

But how to deal with Bump sonar.version from 9.9.0.65466 to 9.9.4.87374?

  • for 9.9.4 there is no item in the table
  • if I use 9.9.4, is it ensured that my plugin is still compatible with 9.9.0?

How can I ensure that my plugin is working with SQ 9.9 LTS and the latest SQ 10.x version?

  • Which settings do I have to use here?

What is the sonarQubeMinVersion entry for?

Thanks for your answer!

Regards,
Guenter

Hi,

for sonarQubeMinVersion I found the answer here: Plugin basics

Other points are still open.

Minimal version of supported Sonar Plugin API at runtime. For example, if the value is 9.8.0.203, then deploying the plugin on SonarQube versions with sonar-plugin-api 9.6.1.114 (ie. SonarQube 9.5) and lower will fail. The default value is given by the version of sonar-plugin-api dependency. It can be overridden with the Maven property pluginApiMinVersion (since sonar-packaging-maven-plugin 1.22). That allows in some cases to use new features of recent API and to still be compatible at runtime with older versions of SonarQube. Default: version of dependency sonar-plugin-api

Regards,

1 Like

A post was split to a new topic: API changes: sonarQubeMinVersion

Hi,

Seems ‘sonarQubeMinVersion’ is no more supported in future?

BREAKING CHANGE: Rename ‘sonarQubeMinVersion’ to ‘pluginApiMinVersion’

Regards,

Hi @guwirth ,

There are 2 important versions of the Sonar Plugin API to consider:

  • the version you are using to compile your project
  • the minimal version of the API your plugin is able to deal with, at runtime

Each Sonar product will check at startup if a plugin’s “minimal API version” is lower or equal to the version of the API it is implementing.

For most simple cases, the two versions are the same. You compile your plugin against version X.Y of the plugin API, using for example an API foo introduced in version X.Y. At runtime, your plugin can be installed in any Sonar product that is implementing at least version X.Y of the Sonar Plugin API. Otherwise, your plugin will crash when calling foo.

There are advanced use cases where a plugin wants to use an API introduced in a new version of the Sonar Plugin API, but stay compatible with older Sonar products. Those plugins will often use reflection or other technics to not crash at runtime.
In this case, you can manually force the minimal Sonar Plugin API version to an older value than the version you are compiling with.

When using the sonar-maven-packaging-plugin, by default the minimal version is the same as the version of the sonar-plugin-api dependency.
But if you are in the advanced use case I described earlier, you can override the minimal version using the property pluginApiMinVersion. Our example is outdated and is using the old name, but we are going to fix it.

Hope this clarifies.

Hello Julien,

thanks for your answer!

One thing I like to ask again:

Is it ensured that after updating to SQ 9.9.4 the pluging is still working with SQ 9.9.0?

Thx & Regards

According to the matrix

image

SonarQube 9.9 implements the plugin API 9.14. The API is usually backward compatible at least from one LTS to another, so I think it should be fine.

However, if you are targeting SQ 9.9 only, maybe it is simpler to directly update your dependency on sonar-plugin-api to 9.14.0.375.