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?

0

As per javadoc, use `com.intellij.openapi.startup.StartupActivity` instead

0

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.

0

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.

0

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

0

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.

0

Yann Cebron But does that mean that my StartupActivity does not work anymore?

0

No, everything will continue to work as before.

0

请先登录再写评论。