How to handle Deprecated code when developing Plugin?
Answered
Hi
How to properly handle Deprecated API when developing plugin? I have added version check to handle, but it failed when verification.
In 2023 major version some of the previous API is scheduled for removal status. But no probs with 2021 version . So I have added
If(2023) new API()
Else previous API ()
This is not working when plugin verification.
How to include both code inside plugin?
Please sign in to leave a comment.
Hi Joseph,
Plugin Verifier checks the binary compatibility by analyzing your plugin distribution (compiled classes). The `if` conditions can't help here, as the incompatible code is still in the plugin distribution, and Plugin Verifier doesn't understand if it will be executed or not.
If you want to target multiple versions, consider maintaining separate Git branches for each target version. Each branch should contain a code compatible with the target version. Of course, proper since/until build values must be used in plugin.xml. You will need to build the plugin for each target version separately.
Ok so, what I understand from your comment is the need to build multiple plugins for each version. That is really complicated because I have so many plugin users, they need to migrate to a new plugin for a deprecated API. Is there any possible alternative way for that?
Hi Joseph,
Not for each version, but for each version range (since/until build). I don't understand what problems related to users you mean. It is transparent for users as IDE downloads the newest version it supports.
Minimizing the number of issues reported by Plugin Verifier is highly recommended, but in your case, it is not required to release multiple versions. Deprecated and scheduled for removal APIs do not break binary compatibility, and the plugin will work even if such issues are reported by Plugin Verifier.