mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
Tabs for Gradle/Gradle Kotlin DSL examples
This commit is contained in:
parent
c6d6491127
commit
bae57f878b
@ -81,7 +81,7 @@ An example `pluginSigning` configuration may look like:
|
||||
<tabs>
|
||||
<tab title="Gradle">
|
||||
|
||||
```Groovy
|
||||
```groovy
|
||||
signPlugin {
|
||||
certificateChain = """
|
||||
-----BEGIN CERTIFICATE-----
|
||||
@ -110,7 +110,7 @@ publishPlugin {
|
||||
</tab>
|
||||
<tab title="Gradle Kotlin DSL">
|
||||
|
||||
```Kotlin
|
||||
```kotlin
|
||||
signPlugin {
|
||||
certificateChain.set("""
|
||||
-----BEGIN CERTIFICATE-----
|
||||
@ -155,7 +155,7 @@ To specify secrets like `PUBLISH_TOKEN` and values required for the `signPlugin`
|
||||
<tabs>
|
||||
<tab title="Gradle">
|
||||
|
||||
```Groovy
|
||||
```groovy
|
||||
signPlugin {
|
||||
certificateChain = System.getenv("CERTIFICATE_CHAIN")
|
||||
privateKey = System.getenv("PRIVATE_KEY")
|
||||
@ -170,7 +170,7 @@ publishPlugin {
|
||||
</tab>
|
||||
<tab title="Gradle Kotlin DSL">
|
||||
|
||||
```Kotlin
|
||||
```kotlin
|
||||
signPlugin {
|
||||
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
|
||||
privateKey.set(System.getenv("PRIVATE_KEY"))
|
||||
|
@ -56,6 +56,9 @@ Here are the steps to configure the <path>build.gradle</path> file for developin
|
||||
|
||||
The snippet below is an example of configuring the Setup and Running DSLs in a <path>build.gradle</path> specific to developing a plugin targeted at Android Studio.
|
||||
|
||||
<tabs>
|
||||
<tab title="Gradle">
|
||||
|
||||
```groovy
|
||||
intellij {
|
||||
// Define IntelliJ Platform against which to build the plugin project.
|
||||
@ -72,6 +75,29 @@ The snippet below is an example of configuring the Setup and Running DSLs in a <
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
<tab title="Gradle Kotlin DSL">
|
||||
|
||||
```kotlin
|
||||
intellij {
|
||||
// Define IntelliJ Platform against which to build the plugin project.
|
||||
version.set("191.8026.42") // Same IntelliJ IDEA version (2019.1.4) as target 3.5 Android Studio
|
||||
type.set("IC") // Use IntelliJ IDEA CE because it's the basis of the IntelliJ Platform
|
||||
// Require the Android plugin, Gradle will match the plugin version to intellij.version
|
||||
plugins.set(listOf("android"))
|
||||
}
|
||||
|
||||
runIde {
|
||||
// Absolute path to installed target 3.5 Android Studio to use as IDE Development Instance
|
||||
// The "Contents" directory is macOS specific.
|
||||
ideDir.set(file("/Applications/Android Studio.app/Contents"))
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
</tabs>
|
||||
|
||||
|
||||
### Configuring the Plugin plugin.xml File
|
||||
When using APIs from the `android` plugin, declare a dependency:
|
||||
|
||||
|
@ -43,6 +43,9 @@ A <path>build.gradle</path> snippet setting a plugin project to target PyCharm i
|
||||
The `gradle-intellij-plugin` will fetch the matching build of PyCharm Professional to define the APIs available, and use that build of PyCharm (and associated JetBrains runtime) as the Development Instance.
|
||||
No additional product-specific configuration needs to be set in <path>build.gradle</path>:
|
||||
|
||||
<tabs>
|
||||
<tab title="Gradle">
|
||||
|
||||
```groovy
|
||||
intellij {
|
||||
version = '2019.2.3'
|
||||
@ -50,6 +53,19 @@ intellij {
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
<tab title="Gradle Kotlin DSL">
|
||||
|
||||
```kotlin
|
||||
intellij {
|
||||
version.set("2019.2.3")
|
||||
type.set("PY")
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
</tabs>
|
||||
|
||||
### Configuring Plugin Projects Using the IntelliJ IDEA Product Attribute
|
||||
If the `gradle-intellij-plugin` does not directly support an IntelliJ Platform-based product, the <path>build.gradle</path> file can still be configured to target the desired product.
|
||||
In this case, the <path>build.gradle</path> file is configured to use IntelliJ IDEA (Community or Ultimate Edition) as the basis for the available APIs.
|
||||
@ -106,6 +122,9 @@ The exact path format varies by operating system.
|
||||
|
||||
This snippet is an example for configuring the Setup and Running DSLs in a <path>build.gradle</path> specific to developing a plugin for _targetIDE_.
|
||||
|
||||
<tabs>
|
||||
<tab title="Gradle">
|
||||
|
||||
```groovy
|
||||
intellij {
|
||||
// Define the IntelliJ Platform against which to build the plugin project.
|
||||
@ -124,6 +143,30 @@ runIde {
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
<tab title="Gradle Kotlin DSL">
|
||||
|
||||
```kotlin
|
||||
intellij {
|
||||
// Define the IntelliJ Platform against which to build the plugin project.
|
||||
// Use the IntelliJ Platform BRANCH.BUILD version matching "targetIDE" (PhpStorm)
|
||||
version.set("192.7142.36") // baseIntelliJPlatformVersion
|
||||
type.set("IU")
|
||||
// Require the targetIDE plugin or library
|
||||
// Use the stable version compatible with intellij.version and intellij.type specified above
|
||||
plugins.set(listOf("com.jetbrains.php:192.6603.42"))
|
||||
}
|
||||
|
||||
runIde {
|
||||
// Absolute path to the installed targetIDE to use as IDE Development Instance
|
||||
// Note the Contents directory must be added at the end of the path for macOS.
|
||||
ideDir.set(file("/Users/$USERNAME$/Library/Application Support/JetBrains/Toolbox/apps/PhpStorm/ch-0/192.7142.41/PhpStorm.app/Contents"))
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
</tabs>
|
||||
|
||||
## Configuring plugin.xml
|
||||
As discussed on the [Plugin Dependencies](plugin_compatibility.md#declaring-plugin-dependencies) page of this guide, a plugin's dependency on [Modules Specific to Functionality](plugin_compatibility.md#modules-specific-to-functionality) must be declared in <path>plugin.xml</path>.
|
||||
When using features (APIs) specific to the target product, a dependency on the target product module must be declared, as shown in the code snippet below.
|
||||
|
@ -97,6 +97,9 @@ There are two parts to the example: the repository and the dependency sections.
|
||||
This code snippet selects the release repository with the first URL, and the repository of IntelliJ Platform dependencies with the second URL.
|
||||
The second URL is needed because this example selects individual modules.
|
||||
|
||||
<tabs>
|
||||
<tab title="Gradle">
|
||||
|
||||
```groovy
|
||||
repositories {
|
||||
maven { url "https://www.jetbrains.com/intellij-repository/releases" }
|
||||
@ -104,16 +107,45 @@ repositories {
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
<tab title="Gradle Kotlin DSL">
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
maven("https://www.jetbrains.com/intellij-repository/releases")
|
||||
maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
</tabs>
|
||||
|
||||
### Dependencies Section
|
||||
This code snippet specifies the desired module artifacts.
|
||||
|
||||
<tabs>
|
||||
<tab title="Gradle">
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
compile "com.jetbrains.intellij.platform:jps-model-serialization:182.2949.4"
|
||||
compile "com.jetbrains.intellij.platform:jps-model-impl:182.2949.4"
|
||||
implementation "com.jetbrains.intellij.platform:jps-model-serialization:182.2949.4"
|
||||
implementation "com.jetbrains.intellij.platform:jps-model-impl:182.2949.4"
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
<tab title="Gradle Kotlin DSL">
|
||||
|
||||
```kotlin
|
||||
dependencies {
|
||||
implementation("com.jetbrains.intellij.platform:jps-model-serialization:182.2949.4")
|
||||
implementation("com.jetbrains.intellij.platform:jps-model-impl:182.2949.4")
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
</tabs>
|
||||
|
||||
Note:
|
||||
* The artifact version (`182.2949.4`) must match in both statements.
|
||||
* In this example `jps-model-serialization` declares the APIs and `jps-model-impl` provides the implementation, so both are required dependencies.
|
||||
|
@ -49,12 +49,28 @@ export ORG_GRADLE_PROJECT_intellijPublishToken='YOUR_TOKEN'
|
||||
Now provide the environment variable in the run configuration with which you run the `publishPlugin` task locally.
|
||||
To do so, create a Gradle run configuration (if not already done), choose your Gradle project, specify the `publishPlugin` task, and then add the environment variable.
|
||||
|
||||
<tabs>
|
||||
<tab title="Gradle">
|
||||
|
||||
```groovy
|
||||
publishPlugin {
|
||||
token = System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken")
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
<tab title="Gradle Kotlin DSL">
|
||||
|
||||
```kotlin
|
||||
publishPlugin {
|
||||
token.set(System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken"))
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
</tabs>
|
||||
|
||||
|
||||
Note that you still need to put some default values (can be empty) in the Gradle properties because otherwise, you will get a compilation error.
|
||||
|
||||
### Using Parameters for the Gradle Task
|
||||
@ -91,12 +107,27 @@ If successfully deployed, any users who currently have your plugin installed on
|
||||
You may also deploy plugins to a release channel of your choosing, by configuring the `publishPlugin.channels` property.
|
||||
For example:
|
||||
|
||||
<tabs>
|
||||
<tab title="Gradle">
|
||||
|
||||
```groovy
|
||||
publishPlugin {
|
||||
channels = ['beta']
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
<tab title="Gradle Kotlin DSL">
|
||||
|
||||
```kotlin
|
||||
publishPlugin {
|
||||
channels.set(listOf("beta"))
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
</tabs>
|
||||
|
||||
When empty, this uses the default plugin repository, available to all [JetBrains Marketplace](https://plugins.jetbrains.com/) users.
|
||||
However, you can publish it to an arbitrarily-named channel.
|
||||
These non-default release channels are treated as separate repositories.
|
||||
|
@ -17,17 +17,16 @@ Beginning in version 2019.2, a dependency on Java plugin [must be declared expli
|
||||
First, add a dependency on the Java plugin in Gradle build file:
|
||||
|
||||
<tabs>
|
||||
<tab title="build.gradle">
|
||||
<tab title="Gradle">
|
||||
|
||||
```groovy
|
||||
```kotlin
|
||||
intellij {
|
||||
plugins = ['com.intellij.java']
|
||||
}
|
||||
```
|
||||
|
||||
</tab>
|
||||
|
||||
<tab title="build.gradle.kts">
|
||||
<tab title="Gradle Kotlin DSL">
|
||||
|
||||
```kotlin
|
||||
intellij {
|
||||
|
Loading…
x
Reference in New Issue
Block a user