How to register a New Project type without using the non-dynamic ModuleType extension?

Answered

The goal is to both be able to install the plugin without restart, and to have a custom language option in the new project dialog.

Currently, we establish the second by using a ModuleType. However, the IntelliJ Plugin Verifier shows:

The following prevents the plugin to be dynamically loaded/unloaded without requiring user to restart IDE: Plugin declares non-dynamic extensions: com.intellij.moduleType

(Contrary to what https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/dynamic_plugins.html suggests, I have not been able to run the Plugin DevKit | Plugin descriptor | Plugin.xml dynamic plugin verification locally, because the project uses Gradle which I think is the cause of this option not existing.)

At first there were many other extensions that were not declared dynamic, but for quite a while this is the only one left so I suspect that we have to remove our dependency on it?

The Javadoc of the ModuleType class indeed says

* <strong>Module Type concept is considered as outdated.</strong> Enabling some features only in modules of a specific type makes it harder
* to mix different technologies in the same source directory, and cause conflicts in configuration files when the same directory is opened
* in different IDEs.
* </p>
* If you need
* to show special kinds of projects in New Project wizard, register an implementation of {@link ModuleBuilder} as an extension instead.

which does make sense. Registering an implementation of ModuleBuilder was already done, but when I just remove the ModuleType from the plugin.xml then the LaTex project is not shown in the New Project dialog, or the New Module dialog. I also returned a Java module type instead in the ModuleBuilder implementation:

override fun getModuleType(): ModuleType<JavaModuleBuilder> = StdModuleTypes.JAVA

The documentation at https://www.jetbrains.org/intellij/sdk/docs/reference_guide/project_wizard.html still recommends to use a module type, so that doesn't help much.

The documentation there suggests "If your module type is based on the java module and meant to support Java as well, extending JavaModuleBuilder is enough. No extension point needs to be registered."

so I made the LatexModuleBuilder extend JavaModuleBuilder instead of ModuleBuilder, but it didn't help.

We also have an implementation of a DirectoryProjectGenerator, for the New Project entry to show in non-IntelliJ IDEs. I couldn't find documentation about this, just https://stackoverflow.com/questions/49710209/creating-an-intellij-module-programmatically/49713551#49713551

I also saw a ProjectImportBuilder class that we did not implement, but from the name I am guessing (couldn't find any docs) that it is only for New | Project from Existing Sources (perhaps we need to implement it anyway)

I also couldn't find any other example plugins which do not use a ModuleType for this.

The plugin under consideration is TeXiFy-IDEA (https://plugins.jetbrains.com/plugin/9473-texify-idea)

1
2 comments

- the inspection Plugin DevKit | Plugin descriptor | Plugin.xml dynamic plugin verification is available in 2020.1 EAP only

- Making moduleType dynamic is scheduled for 2020.2 https://youtrack.jetbrains.com/issue/IDEA-235291

0

Thanks, found it now.

Thanks for letting me know, looking forward to that!

0

Please sign in to leave a comment.