Post install task for installed plugin
Answered
Are there any hooks or any post Install actions I can use inside my plugin while user is installing it?
I would like to launch as soon as plugin is installed some additional tasks e.g::
- NPM INSTALL
- Fetch additional JAR files and add them to class path
Thanks,
Frank
Please sign in to leave a comment.
One approach you can use is in your plugin's Application Component detect a new installation based on missing components and/or plugin settings and perform installation completion steps if these are necessary.
Thanks for your feedback. This is actually a way to solve this. The only thing I worry about is that first initial start might take a while.
Or i would probably run all this in the background and expecting user will not notice or he/she will start using it before all the post install steps are finished.
The best way would be if there are any extension points even on this Plugin install level and it would happen right there .
In that case you can do the installation actions in a project component by registering after startup action in projectOpened().
To handle the case that multiple projects can be loading at the same time, do the initialization in your application component but the call to the method should come from your project component’s
projectOpened()
runWhenProjectIsInitialized
call back and then use the first method invocation to test if further installation is needed while ignoring subsequent calls.If after installation you need to restart the IDE you can present a dialog and restart the IDE if the user OKs the action:
I sometimes add another 5 to 10 seconds delay after initialization is complete before launching extra tasks to prevent delaying the IDE load.
There is probably a better way of doing this, especially in 2018 and 2019 IDEs but I found that this works reliably on IDEs way back to 2016.3 and easy enough to implement.
You can use EP com.intellij.ide.ApplicationLoadListener. Please bear in mind that network may not be available on restart after initial plugin installation.
Is this EP called at the time Application startup or during Plugin Installation?
During application startup. There is no possibility to hook into plugin installation process.
Great. Last thing might be ..
If I use this EP that kicks in as soon as I open IDE where I can start fetching nessesary resources and save them to plugin folder and To give some feedback back to user is it possible to post some message to the splan screen ?
I could display there some meaningfull messages that we run post-install task for xyz plugin and about its progress.
No, there is no possibility to draw on splash screen. If you need some progress/messages/UI to interrupt download, then I'd actually recommend Vladimir's approach.