Generalize for Part VIII

This commit is contained in:
JohnHake 2019-10-23 13:27:57 -07:00
parent ae6aa07cf9
commit 253e27b2da
5 changed files with 98 additions and 31 deletions

View File

@ -228,6 +228,7 @@
## Part VIII - Product Specific
* [Build Number Ranges](basics/getting_started/build_number_ranges.md)
* [Developing for Multiple Products](products/dev_alternate_products.md)
* [Compatibility with Multiple Products](basics/getting_started/plugin_compatibility.md)
* [Android Studio](products/android_studio.md)
* AppCode

View File

@ -0,0 +1,95 @@
---
title: Plugins Targeting IntelliJ Platform-Based IDEs
---
This page is an introduction to configuring Gradle plugin projects that target IDEs based on the [IntelliJ Platform](/intro/intellij_platform.md), but are not IntelliJ IDEA.
All of the Gradle configuration attributes mentioned here are discussed in-depth on the [Configuring Gradle for IntelliJ Platform Plugins](/tutorials/build_system/gradle_guide.md) page.
Information common to projects targeting products other than IntelliJ IDEA is introduced here.
Details particular to an IntelliJ Platform-based IDE is described on the individual product pages in Part VIII.
* bullet list
{:toc}
## Introduction
Plugins can extend or add functionality to IDEs based on the IntelliJ Platform.
This extensibility applies to a variety of JetBrains' IDEs, such as Android Studio, WebStorm, PhpStorm, and PyCharm.
Plugins can be written in Kotlin or Java, or a mix of both, and are created using IntelliJ IDEA.
Once completed, plugins can be packaged and distributed at [plugins.jetbrains.com](https://plugins.jetbrains.com).
## Configuring Plugin Projects Targeting Alternate IntelliJ Platform-Based IDEs
To create a new Gradle plugin project, follow the tutorial on the [Getting Started with Gradle](/tutorials/build_system/prerequisites.md) page.
The tutorial produces a skeleton Gradle project suitable to use as a starting point.
Some minor modifications are needed, as described below, and on the individual product pages in Part VIII.
Understanding the relationship between build numbers is critical when developing a plugin to target an IntelliJ Platform-based IDE:
* _targetIDE_ is the (version-specific) IntelliJ Platform-based IDE in which the plugin is intended to run, such as PyCharm.
The path in Gradle plugin attribute [`runIde.ideaDirectory`](/tutorials/build_system/gradle_guide.md#running-against-alternate-versions-and-types-of-intellij-platform-based-ides) is set to the installed location of _targetIDE_.
* _baseIntelliJPlatformVersion_ is the (version-specific) IntelliJ Platform used in the build of the _targetIDE_.
The IntelliJ Platform is defined by a specific build of the IntelliJ IDEA Community Edition.
The Gradle plugin attribute [`intellij.version`](/tutorials/build_system/gradle_guide.md#intellij-platform-configuration) is set to be _baseIntelliJPlatformVersion_.
For API compatibility, the IntelliJ Platform version used in the _targetIDE_ dictates the _baseIntelliJPlatformVersion_ used for developing a plugin.
### Matching Versions of the IntelliJ Platform with the Target IDE Version
The _baseIntelliJPlatformVersion_ used in the _targetIDE_ may not be readily apparent, depending on the product.
See the individual product pages in Part VIII for exceptions.
To find the version of the IntelliJ Platform used to build the _targetIDE_, use the _About_ dialog screen for the _targetIDE_.
Next to **Build #** is the BRANCH.BUILD.FIX version of the IntelliJ Platform used to build the _targetIDE_.
In the example shown below, the (BRANCH.BUILD.FIX) version of the IntelliJ Platform is `192.6817.19`.
The product version is 2019.2.3.
![Example PyCharm](img/pycharm_build.png){:width="600px"}
If the product version isn't clear on the _About_ screen, consult the individual product pages in Part VIII.
Using [Toolbox](https://www.jetbrains.com/toolbox-app/) is an easy way to find build numbers for recent versions.
In the example below, IntelliJ IDEA Community (which defines the IntelliJ Platform) for v2019.2.3 is build number `192.6817.14`.
![Toolbox Lookup](img/toolbox_lookup.png){:width="400px"}
Although the FIX versions are different, this is not uncommon between products, and the builds are still compatible.
The BRANCH and BUILD numbers match, therefor in this PyCharm example:
* The _targetIDE_ (PyCharm) is `192.6817.19`,
* The _baseIntelliJPlatformVersion_ (IntelliJ IDEA Community Edition) is `192.6817.14`
### Configuring the Plugin build.gradle File
For a project developing a plugin for _targetIDE_, configure the `build.gradle` file as follows:
* The Gradle plugin attributes describing the configuration of the [IntelliJ Platform used to build the plugin project](/tutorials/build_system/gradle_guide.md#configuring-the-gradle-plugin-for-building-intellij-platform-plugin-projects) must be explicitly set.
The `intellij.type` is "IC" because the IntelliJ IDEA Community Edition defines the IntelliJ Platform.
The `intellij.version` is _baseIntelliJPlatformVersion_.
* Declare the [plugin's dependency](/tutorials/build_system/gradle_guide.md#plugin-dependencies) on any _targetIDE_-specific plugins or modules.
Use the Gradle plugin attribute `intellij.plugins` to declare a dependency.
See the specific product pages in Part VIII for the _targetIDE_ plugin or module name.
* The best practice is to use a local installation of _targetIDE_ as the [IDE Development Instance](/basics/ide_development_instance.md).
Set the Development Instance to the (user-specific) absolute path to the _targetIDE_ application.
The exact path varies by the operating system; macOS is shown.
The snippet below is an example of configuring the Setup and Running DSLs in a `build.gradle` specific to developing a plugin for _targetIDE_.
```groovy
intellij {
// Define IntelliJ Platform against which to build the plugin project.
// Use the IntelliJ Platform BRANCH.BUILD version ("baseIntelliJPlatformVersion") matching "targetIDE"
// For example, '192.6817.14'
version '<baseIntelliJPlatformVersion>'
type 'IC'
// Require the targetIDE plugin or library
plugins '<targetIDE-specific modules or plugins>' // For example, 'python'
}
runIde {
// Absolute path to installed target application to use as IDE Development Instance
// For example, the path to PyCharm build 192.6817.19
ideaDirectory '/Applications/<targetIDE>.app/Contents'
}
```
### Configuring the Plugin plugin.xml File
As discussed on the [Plugin Dependencies](/basics/getting_started/plugin_compatibility.md#declaring-plugin-dependencies) page of this guide, a plugin's dependency on [Modules Specific to Functionality](/basics/getting_started/plugin_compatibility.md#modules-specific-to-functionality) must be declared in `plugin.xml`.
When using _targetIDE_-specific features (APIs), a dependency on the _targetIDE_ module must be declared, as shown in the code snippet below.
Otherwise, if only general IntelliJ Platform features (APIs) are used, then a dependency on `com.intellij.modules.platform` must be declared as discussed in [Plugin Compatibility with IntelliJ Platform Products](/basics/getting_started/plugin_compatibility.md).
```xml
<!-- For example, com.intellij.modules.python -->
<depends>com.intellij.modules.targetIDE</depends>
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

View File

@ -134,34 +134,5 @@ IntelliJ Platform plugins targeting IntelliJ IDEA have the most straightforward
* Set the appropriate attributes for [patching the `plugin.xml` file](#patching-the-plugin-configuration-file).
### Plugins Targeting Alternate IntelliJ Platform-Based IDEs
The Gradle plugin can also be configured for developing plugins to run in IDEs that are based on the IntelliJ Platform but are not IntelliJ IDEA.
This example focuses on the details of developing a plugin for PhpStorm.
It will be helpful to review the [PhpStorm Plugin Development](/products/phpstorm/phpstorm.md) section.
* The Gradle plugin attributes describing the configuration of the [IntelliJ Platform used to build the plugin project](#configuring-the-gradle-plugin-for-building-intellij-platform-plugin-projects) must be explicitly set.
The type will be "IC" because the IntelliJ Platform is defined by the IntelliJ IDEA Community Edition.
The BRANCH.BUILD number of the IntelliJ Platform (IntelliJ IDEA CE) is the same as for the PhpStorm target.
Although the FIX (tertiary) number may differ between the same versions of the applications, it won't affect the match of the IntelliJ Platform.
* All PhpStorm plugin projects have a dependency on the PhpStorm OpenAPI Library.
Any plugin targeting PhpStorm must list a dependency on the PHP plugin, and its version must be compatible with the target version of PhpStorm.
The plugin dependency must be declared using the Gradle plugin `intellij.plugins` attribute, which lists the `id` and `version` of the plugin dependency.
* The best practice is to use the target version of PhpStorm as the IDE Development Instance.
That enables running and debugging the plugin in the target (e.g., PhpStorm) application.
The choice of application to use for the IDE Development Instance is configured using the Gradle plugin attribute `runIde.ideaDirectory`.
The snippet below is an example of configuring the Setup and Running DSLs in a `build.gradle` file to develop a plugin targeted at PhpStorm.
The configuration uses IntelliJ IDEA Community Edition v2019.1.2 (build 191.7141.44) as the IntelliJ Platform against which the plugin project is built.
It uses PhpStorm v2019.1.2 (build 191.7141.52) as the IDE Development Instance in which the plugin project is run and debugged.
```groovy
intellij {
// Define IntelliJ Platform against which to build the plugin project.
version '191.7141.44' // Same version (2019.1.2) as target PhpStorm
type 'IC' // Use IntelliJ IDEA CE as basis of IntelliJ Platform
// Require the Php plugin, must be compatible with target v2019.1.2
plugins 'com.jetbrains.php:191.6707.66'
}
runIde {
// Path to installed v2019.1.2 PhpStorm to use as IDE Development Instance
ideaDirectory '/Applications/apps/PhpStorm/ch-0/191.7141.52/PhpStorm.app/Contents'
}
```
Gradle also supports developing plugins to run in IDEs that are based on the IntelliJ Platform, but are not IntelliJ IDEA.
For more information, see the [Developing for Multiple Products](/products/dev_alternate_products.md) page of this guide.