felipebz / zpa

Parser and static code analysis tool for PL/SQL and Oracle SQL.
https://zpa.felipebz.com
GNU Lesser General Public License v3.0
211 stars 77 forks source link

Custom plugins shouldn't be declared with <basePlugin> #102

Closed felipebz closed 5 years ago

felipebz commented 5 years ago

Currently the custom plugin example is defined as:

https://github.com/felipebz/sonar-plsql/blob/34d39dffc76e5bf4a5b3fd24de44fed8df5f9e8d/plsql-custom-rules/pom.xml#L48-L50

But...

basePlugin will make your two plugins share the same classloader. This is not always good. Another option is to put your interface MyExtensionPoint in the package org.sonar.plugins.<plugin key>.api. By convention all classes in this package are visible to all other plugins. (...) But as I said using basePlugin is only needed when the extension point is not in the API. In fact I will check but to me no custom rule plugin should use basePlugin. (Source)

And there is SONAR-10286 Deprecate Plugin-ChildFirstClassLoader and Plugin-Base.

Ideally the custom plugins shouldn't be declared with the <basePlugin> attribute. But, right now, just removing this tag from pom.xml breaks the plugin because it'll be able to access only the classes in the package org.sonar.plugins.plsqlopen.api.

Plan

This breaking change will happen in next release (2.3.0). Every custom plugin will have to migrate to the new API, located in the package org.sonar.plugins.plsqlopen.api.*.

Impacts

After this change, only classes/interfaces in the package org.sonar.plugins.plsqlopen.api will be considered "officially supported" and breaking changes will be avoided where possible. Custom plugins must remove the <basePlugin> attribute from their sonar-packaging-maven-plugin configuration.

Tasks

Move all classes used by custom plugins to the package org.sonar.plugins.plsqlopen.api:

Tests/docs:

felipebz commented 5 years ago

Change of plans: the initial idea was to make this change in version 2.3.0 without breaking changes (you can see the original plan in the edit history), but there's already breaking changes in the API since 2.2.0. Since I'm the sole developer of this project and I maintain it in my free time, I don't have time / don't want to avoid theses breaking changes right now.

To be compatible with version 2.3.0, all custom plugin will have to migrate to the new API located in the package org.sonar.plugins.plsqlopen.api.*.

felipebz commented 5 years ago

Updated documentation: https://github.com/felipebz/sonar-plsql/wiki/Create-a-plugin-with-custom-rules