|
1 |
| -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. |
| 1 | +import org.jetbrains.changelog.Changelog |
| 2 | +import org.jetbrains.changelog.markdownToHTML |
| 3 | +import org.jetbrains.intellij.platform.gradle.TestFrameworkType |
2 | 4 |
|
3 | 5 | plugins {
|
4 |
| - id("org.jetbrains.kotlin.jvm") version "1.6.10" |
5 |
| - id("org.jetbrains.intellij") version "1.12.0" |
6 |
| - id("org.jlleitschuh.gradle.ktlint") version "10.2.1" |
| 6 | + id("java") // Java support |
| 7 | + alias(libs.plugins.kotlin) // Kotlin support |
| 8 | + alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin |
| 9 | + alias(libs.plugins.changelog) // Gradle Changelog Plugin |
| 10 | + alias(libs.plugins.qodana) // Gradle Qodana Plugin |
| 11 | + alias(libs.plugins.kover) // Gradle Kover Plugin |
7 | 12 | }
|
8 | 13 |
|
9 |
| -fun properties(key: String) = project.findProperty(key).toString() |
| 14 | +group = providers.gradleProperty("pluginGroup").get() |
| 15 | +version = providers.gradleProperty("pluginVersion").get() |
10 | 16 |
|
11 |
| -group = project.property("pluginGroup") as String |
12 |
| -version = properties("version") |
| 17 | +// Set the JVM language level used to build the project. |
| 18 | +kotlin { |
| 19 | + jvmToolchain(21) |
| 20 | +} |
13 | 21 |
|
| 22 | +// Configure project's dependencies |
14 | 23 | repositories {
|
15 | 24 | mavenCentral()
|
| 25 | + |
| 26 | + // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html |
| 27 | + intellijPlatform { |
| 28 | + defaultRepositories() |
| 29 | + } |
16 | 30 | }
|
17 | 31 |
|
| 32 | +// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog |
18 | 33 | dependencies {
|
19 |
| - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") |
20 |
| -} |
| 34 | + testImplementation(libs.junit) |
| 35 | + testImplementation(libs.opentest4j) |
21 | 36 |
|
22 |
| -java { |
23 |
| - sourceCompatibility = JavaVersion.VERSION_17 |
24 |
| -} |
| 37 | + // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html |
| 38 | + intellijPlatform { |
| 39 | + androidStudio(providers.gradleProperty("platformVersion"), useInstaller = true) |
| 40 | + |
| 41 | + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. |
| 42 | + bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') }) |
| 43 | + |
| 44 | + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. |
| 45 | + plugins(providers.gradleProperty("platformPlugins").map { it.split(',') }) |
25 | 46 |
|
26 |
| -// See https://github.com/JetBrains/gradle-intellij-plugin/ |
27 |
| -intellij { |
28 |
| - version.set(properties("InstrumentCodeVersion")) |
29 |
| - type.set(properties("platformType")) |
30 |
| - |
31 |
| - plugins.set( |
32 |
| - listOf( |
33 |
| - "Kotlin", |
34 |
| - "gradle", |
35 |
| - "android", |
36 |
| - "java" |
37 |
| - ) |
38 |
| - ) |
| 47 | + testFramework(TestFrameworkType.Platform) |
| 48 | + } |
39 | 49 | }
|
40 | 50 |
|
41 |
| -tasks { |
42 |
| - buildSearchableOptions { |
43 |
| - enabled = false |
| 51 | +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html |
| 52 | +intellijPlatform { |
| 53 | + pluginConfiguration { |
| 54 | + name = providers.gradleProperty("pluginName") |
| 55 | + version = providers.gradleProperty("pluginVersion") |
| 56 | + |
| 57 | + // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest |
| 58 | + description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { |
| 59 | + val start = "<!-- Plugin description -->" |
| 60 | + val end = "<!-- Plugin description end -->" |
| 61 | + |
| 62 | + with(it.lines()) { |
| 63 | + if (!containsAll(listOf(start, end))) { |
| 64 | + throw GradleException("Plugin description section not found in README.md:\n$start ... $end") |
| 65 | + } |
| 66 | + subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + val changelog = project.changelog // local variable for configuration cache compatibility |
| 71 | + // Get the latest available change notes from the changelog file |
| 72 | + changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion -> |
| 73 | + with(changelog) { |
| 74 | + renderItem( |
| 75 | + (getOrNull(pluginVersion) ?: getUnreleased()) |
| 76 | + .withHeader(false) |
| 77 | + .withEmptySections(false), |
| 78 | + Changelog.OutputType.HTML, |
| 79 | + ) |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + ideaVersion { |
| 84 | + sinceBuild = providers.gradleProperty("pluginSinceBuild") |
| 85 | + untilBuild = providers.gradleProperty("pluginUntilBuild") |
| 86 | + } |
44 | 87 | }
|
45 | 88 |
|
46 |
| - patchPluginXml { |
47 |
| - version.set("${project.version}") |
48 |
| - sinceBuild.set(properties("pluginSinceBuild")) |
49 |
| - untilBuild.set(properties("pluginUntilBuild")) |
| 89 | + signing { |
| 90 | + certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN") |
| 91 | + privateKey = providers.environmentVariable("PRIVATE_KEY") |
| 92 | + password = providers.environmentVariable("PRIVATE_KEY_PASSWORD") |
50 | 93 | }
|
| 94 | + |
| 95 | + publishing { |
| 96 | + token = providers.environmentVariable("PUBLISH_TOKEN") |
| 97 | + // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 |
| 98 | + // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: |
| 99 | + // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel |
| 100 | + channels = providers.gradleProperty("pluginVersion") |
| 101 | + .map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) } |
| 102 | + } |
| 103 | + |
| 104 | + pluginVerification { |
| 105 | + ides { |
| 106 | + recommended() |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin |
| 112 | +changelog { |
| 113 | + groups.empty() |
| 114 | + repositoryUrl = providers.gradleProperty("pluginRepositoryUrl") |
51 | 115 | }
|
52 | 116 |
|
53 |
| -tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { |
54 |
| - kotlinOptions { |
55 |
| - jvmTarget = "17" |
| 117 | +// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration |
| 118 | +kover { |
| 119 | + reports { |
| 120 | + total { |
| 121 | + xml { |
| 122 | + onCheck = true |
| 123 | + } |
| 124 | + } |
56 | 125 | }
|
57 | 126 | }
|
58 | 127 |
|
59 | 128 | tasks {
|
| 129 | + wrapper { |
| 130 | + gradleVersion = providers.gradleProperty("gradleVersion").get() |
| 131 | + } |
| 132 | + |
| 133 | + publishPlugin { |
| 134 | + dependsOn(patchChangelog) |
| 135 | + } |
| 136 | +} |
| 137 | + |
| 138 | +intellijPlatformTesting { |
60 | 139 | runIde {
|
61 |
| - // Absolute path to installed target 3.5 Android Studio to use as |
62 |
| - // IDE Development Instance (the "Contents" directory is macOS specific): |
63 |
| - ideDir.set(file("/Applications/Android Studio Preview.app/Contents")) |
| 140 | + register("runIdeForUiTests") { |
| 141 | + task { |
| 142 | + jvmArgumentProviders += CommandLineArgumentProvider { |
| 143 | + listOf( |
| 144 | + "-Drobot-server.port=8082", |
| 145 | + "-Dide.mac.message.dialogs.as.sheets=false", |
| 146 | + "-Djb.privacy.policy.text=<!--999.999-->", |
| 147 | + "-Djb.consents.confirmation.enabled=false", |
| 148 | + ) |
| 149 | + } |
| 150 | + } |
| 151 | + |
| 152 | + plugins { |
| 153 | + robotServerPlugin() |
| 154 | + } |
| 155 | + } |
64 | 156 | }
|
65 | 157 | }
|
0 commit comments