Uninstall a plug-in when the plug-in is installed
Answered
Are there any ways to detect whether certain plug-ins are installed when the user installs the plug-ins, and uninstall them automatically
Please sign in to leave a comment.
Your plugin can check installed plugins (com.intellij.ide.plugins.PluginManagerCore#getPlugin) using StartupActivity (https://plugins.jetbrains.com/docs/intellij/plugin-components.html#project-open) and show notification (https://plugins.jetbrains.com/docs/intellij/notifications.html#top-level-notifications-balloons) suggesting uninstalling incompatible plugins.
Hello
I have to uninstall a certain plug-in while installing a new plug-in, instead of notifying the user to uninstall, because my plug-in is divided into basic and advanced versions. When the user installs the basic version and then installs the advanced version , If you don’t uninstall the basic version when you install the advanced version, there will be a registration component error, or an error with the same key
If you control both plugins, you can use com.intellij.ide.plugins.PluginReplacement extension point. But it will not enforce disabling plugin.
id=com.zoulejiu.mybatis.smart.plugin This is the ID of the base version
id=com.mybatis.smart.pro.plugin is the ID of the premium version
The premium version contains the code of the basic version
Please also consider this option https://plugins.jetbrains.com/docs/marketplace/free-functionality.html
Is there a way to delete a file after the idea is closed
You can add listener implementing com.intellij.ide.AppLifecycleListener
I added this, but when I went to delete the file, an error was reported saying that the file was occupied
What is "the file"? It could be the IDE or OS or some antivirus etc. etc. that keeps lock on file.
The file is the folder of the basic version of my plugin
2022-01-06 15:20:19,102 [2259381] INFO - is.listener.CheckMybatisPlugin - del file path:C:\Users\zoulejiu\AppData\Local\JetBrains\Toolbox\apps\IDEA-C\ch-0\213.6461.79.plugins\Mybatis Smart Code Helpis errorjava.nio.file.AccessDeniedException: C:\Users\zoulejiu\AppData\Local\JetBrains\Toolbox\apps\IDEA-C\ch-0\213.6461.79.plugins\Mybatis Smart Code Help\lib\activation-1.1.jar
I used this method NioFiles.deleteRecursively(Path.of(pluginPath)) to delete
You should not touch any files in the IDE own configuration/settings directories manually.
I saw that PluginManagerCore has methods to disable plugins and enable plugins, but I couldn’t find a way to add plugins, so I wanted to delete the plugin folder manually
Please use the two approaches suggested earlier (PluginReplacement, paid/free mixed version of plugin) and don't try to manually install/uninstall plugins via code.