Intellij Platform Plugin Listener when new project is created and built completely
Answered
I'm new in Intellij Platform Plugin Development. The required case is that i want a listener when a new project is created and built successfully (after all the required sources are created). I tried the following ones:
- ProjectManagerListener
- PostStartUpActivity
- CompileTask
None of these work. The first two listeners are getting called as soon as the project is opened, i.e, before the build is finished and the files are created. But i need a listener after the build is finished so that i can access all the source folders and files. Is there any workaround for this case?
Please sign in to leave a comment.
Hi,
Could you please clarify what build do you mean? Please also describe your use case if possible.
Hi,
I just want a listener once the new project is completely built and loaded with default files. The use case is i have to access the java and resource folders that are created initially. I can’t do it before the project is completely built and indexing are done.
Hi,
It is still unclear to me what you mean.
What kind of projects do you mean? What kind of build system do you mean? Does a project use Maven, Gradle, other, or no external build system at all? Do you mean a project sync process or something else?
Hi, I am gonna use this plugin in Android Studio. So yes its an android project and it uses Gradle. But I’m mentioning the project sync process for the first time when a new Android Studio project is created.
Hi,
Take a look at: https://plugins.jetbrains.com/docs/intellij/extension-point-list.html#android-plugin-listeners then, and these two in particular:
I don't think it is possible to react only to the first sync, but you can handle it by persisting some flags on the project level to avoid triggering it multiple times (see https://plugins.jetbrains.com/docs/intellij/persisting-state-of-components.html).
Hi,
Thanks a lot. The GradleSyncListener just works fine. Been searching for it all along. Saved my day !!