Including ProjectTemplate in a plugin
Greetings
Currently, I can see that you can make a projectTemplate by opening a project and going Tools->Save Project as template.
I can see that this adds a zip file in the projectTemplates folder in IntelliJ config
Is there a way that I can include a projectTemplate as part of a plugin, so when we distribute our plugin, they can automatically generate new projects based one packaged inside the plugin?
Thanks
Please sign in to leave a comment.
It looks like there are two ways, though I haven't done either myself, so YMMV:
1) Place a description and path to a template (.zip) in plugin.xml. See ProjectTemplateEP.java.
2) Implement a subclass of ProjectTemplatesFactory, overriding (at least) the createTemplates() method. Register that factory in your plugin.xml in the extensions section.
For your factory, you can create a subclass of ProjectTemplate, or use one of the ones provided.
Thanks a lot. I will give that a go.
Warmest regards
Does it actually include the Project inside the plugin?
Eg, I want to deploy my plugin and I want the project to go along with it without having to send anything else.
I would assume I need to add the archive as a resource.
Thanks
That depends upon how you implement your sub-class of ProjectTemplate.
For the extension point, I think it loads a .zip file from the directory. There are some tricks as to how to use a jar file as a file system (to find your .zip file), like using an url of "jar://<some_path>", but whether that will work in the face of your plugin .jar file being renamed, I don't know. I've never actually done this, so your best bet is to clone the community edition sources and start reading code. Look for JarFileSystem and JarFileSystemImpl.