Execute code after project is loaded

Hi,

I'm extremely new to plugin development and trying to figure out how I can have some code invoked after a project has loaded.  I believe I just need to have my code call StartupManager.runWhenProjectIsInitialized, but I'm not sure how to have my code triggered in the first place when my plugin gets loaded.  I tried doing something like this in my plugin.xml:
  <extensions defaultExtensionNs="com.intellij">
      <projectService serviceInterface="RunOnStartup" serviceImplementation="RunOnStartup"/>
  </extensions>

and put my code into the constructor of RunOnStartup, but the code did not get executed.  Can someone please let me know what I'm doing wrong here?  Thank you!

Eric

2 comments
Comment actions Permalink

Services are always loaded on demand; if you simply create a service and don't have any other code that calls the service, it will never get instantiated. The easiest way to have code executed after a project is loaded is to implement the StartupActivity interface and to register your implementation as the postStartupActivity extension. You can find many example usages of this interface in the IntelliJ IDEA Community Edition codebase.

0
Comment actions Permalink

Thanks, this is exactly what I was looking for! :)

0

Please sign in to leave a comment.