Where to put JPS plugin initialization logic?

What's the best place to execute some initialization logic for my JPS plugin? This includes in my case loading external data and initializing some libraries on which I depend. The initialization will always have to take place.

Perhaps in my JpsModelSerializerExtension, or in the constructor of my BuilderService? Or is there a specific service that I can register and use for initialization?

1 comment
Comment actions Permalink

It's better to execute initialization logic lazily when the related classes/methods are used. The build process may be invoked for a project which doesn't contain anything related to your plugin so it's better not to spent time on unnecessary initialization activities in such cases. The implementations of BuilderService are instantiated when the build process is started so it would be better to put initialization logic to static initializers or constructors of your classes which are called from 'build' methods only if the currently built project needs to be processed by your builder.


Please sign in to leave a comment.