[Plugin] Gradle compilation fails with optional dependencies

Answered

Hi, 

I am currently working on a plugin that provides a new module type in the New Project-wizard. Depending on whether the plugin is used in IntelliJ or PyCharm, this module type should be (respectively) Java or Python based. Of course, if the Python plugin is installed in IntelliJ, it should be possible to create a Python-based project in IntelliJ as well. To accomplish this, I went with the following structure:

build.gradle

intellij {
downloadSources false
pluginName 'my-plugin'
// IntelliJ
type 'IC'
version '2019.1'
// PyCharm
// type 'PC'
// version 'PC-2019.1'
}

plugin.xml

<!-- Java-specific features -->
<depends optional="true" config-file="plugin-java.xml">com.intellij.modules.java</depends>
<depends optional="true" config-file="plugin-java.xml">com.intellij.java</depends>

<!-- Python-specific features -->
<depends optional="true" config-file="plugin-python.xml">com.intellij.modules.python</depends>

plugin-java.xml

<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<moduleType id="MY_JAVA_MODULE" implementationClass="my.plugin.JavaType"/>
</extensions>
</idea-plugin>

plugin-python.xml

<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<moduleType id="MY_PYTHON_MODULE" implementationClass="my.plugin.PythonType"/>
</extensions>
</idea-plugin>

Both of these JavaType and PythonType classes are implemented along with a ModuleBuilder. The builder for the JavaType extends JavaModuleBuilder while the PythonType extends PythonModuleBuilderBase.java.

However, I cannot compile this, because if I use an IntelliJ-based IDE, the PythonModuleBuilderBase does not exist, and if I use a PyCharm-based IDE, the JavaModuleBuilder does not exist.

I figured that this may be resolved by making 2 separate versions of the plugin, but I would rather keep it as 1 version if this is somehow possible.

2 comments
Comment actions Permalink

Update: I was able to successfully compile and run it under IntelliJ, by using the following construct:

build.gradle

intellij {
downloadSources false
pluginName 'my-plugin'
plugins = ['java', 'PythonCore:2019.2.192.5728.98']
version 'IU-192.5728.98'
}

 

However, I cannot seem to use this same idea to launch a PyCharm IDE.

0
Comment actions Permalink

You can set alternativeIdePath in runIde task to start a different IDE.

https://github.com/JetBrains/gradle-intellij-plugin/#rundebug-ide-properties

0

Please sign in to leave a comment.