Create a plugin for multiple Intellij products

After reading the documentation it sounds to me that I can create a plugin for multiple Intellij Platform products as long as it does not depend on any feature/classes only available in one.
So I already have a plugin for Android Studio which configures the users application Gradle-build, I would now also like to build a corresponding plugin for iOS projects in AppCode with CocoaPods.
This will have to be two separate plugins, right?

6 comments
Comment actions Permalink

You can use the mechanism of optional dependencies to package all of this functionality in a single plugin. For example, you can optionally depend on the Android plugin and register a Gradle version of the configuration service in the plugin descriptor used with this optional dependency, and optionally depend on the AppCode module with another version of the confguration service.

0
Comment actions Permalink

How would I do that exactly? Would I define different Plugin Services in the <extensions> tag of my plugin.xml then load the right service at runtime?
Are you referring to this or another mechanism?
On the plugin compatibility page there is a mention of a separate config file like this:

<depends optional="true" config-file="my-java-features.xml">com.intellij.modules.java</depends>

But I don't find any reference or sample as to how this config-file should look and if it's the right answer.

If I were to chose different behavior at runtime depending on the product/platform, what would be the best/safest way to do so? I don't see any method on Application/ApplicationInfo to determine that.

Lastly: Which SDK should I link the plugin against?

Thanks,
Mat

0
Comment actions Permalink

The optional plugin config file has exactly the same format as a regular plugin.xml. You can put different service registrations into different files referenced as optional dependencies.

To check the current product at runtime, you can use functions from the PlatformUtils class. However, note that it's not a recommended approach.

As the SDK to link to, you should normally use IntelliJ IDEA Ultimate, as it provides the most complete set of APIs. In addition to that, you can set up continuous integration builds against other SDKs to ensure that you're not using any APIs which aren't available in the other product you're targeting.

0
Comment actions Permalink

Can this be used to have different extensions installed depending on the version of IntelliJ which is running? If the optional config file has the same structure as a normal plugin, does it support since-build and until-build? It seems like this could be used to build a single plugin supporting multiple versions of IntelliJ, or at least disabling functionality that is incompatible with the current build.

0
Comment actions Permalink

This could theoretically be supported, but now it's not. YouTrack issue welcome. :)

0

Please sign in to leave a comment.