Alternative to StartupManager.runAfterOpened()
After creating a new project via its Project Wizard, my plugin needs to run some initialization tasks related to the Framework the plugin supports. These tasks however need to wait until the initial import of the project is done and project open has completed. As such, I have been using the `StartupManager.runAfterOpened()` method. However, in v2023.1 this was marked as `@ApiStatus.Internal`.
Similarly, if a user opens an existing project (containing the supported framework), I need to run some initialization tasks, but again, not until the project opening has completed.
What is the alternative/proper way for a plugin to run a task after the opening of the project has completed now that this method is marked for internal use only?
Please sign in to leave a comment.
As per javadoc, use `com.intellij.openapi.startup.StartupActivity` instead
Yann, I forgot to mention in my original post, the recommended `com.intellij.openapi.startup.StartupActivity` is marked as `@Obsolete`. That in turns tells you to use `com.intellij.openapi.startup.ProjectActivity`. That in turn says to reference the docs at https://youtrack.jetbrains.com/articles/IJPL-A-34/Startup-Activity which shows "Article not Found". So it's not clear if the `ProjectActivity` will wait until the project is fully opened before running, or if it runs during the opening activity.
Obsolete API ref: https://plugins.jetbrains.com/docs/intellij/verifying-plugin-compatibility.html#obsolete-api
So it’s still possible to use it if needed.
Regarding
com.intellij.openapi.startup.ProjectActivity
docs: it means "after project is opened". We'll clarify and expand documentation around this soon.Yann Cebron
I have multiple questions about this thing because of an issue opened today on my plugin: https://github.com/0verEngineer/InlineProblems/issues/51
1. Is there a migration Guide?
2. What if my plugin is written in java and not in kotlin?
3. Does this error the user sees in the issue mean that from 2023.3.3 onwards the StartupActivity is not working anymore?
Thanks a lot
User1234 Please see https://plugins.jetbrains.com/docs/intellij/plugin-components.html#project-open for general information.
You can easily add Kotlin to your plugin (even just for one class), see https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#adding-kotlin-support.
No, it's not an error but a warning that is logged only. Since 2023.3 it will also not report 3rd-party plugins anymore.
Yann Cebron But does that mean that my StartupActivity does not work anymore?
No, everything will continue to work as before.