|
1 | 1 | import org.jetbrains.changelog.Changelog
|
2 | 2 | import org.jetbrains.changelog.markdownToHTML
|
3 |
| -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
4 |
| -import java.util.* |
| 3 | +import org.jetbrains.intellij.platform.gradle.TestFrameworkType |
5 | 4 |
|
6 | 5 | fun properties(key: String) = project.findProperty(key).toString()
|
7 | 6 |
|
8 | 7 | plugins {
|
9 | 8 | // Java support
|
10 | 9 | id("java")
|
11 | 10 | // Kotlin support
|
12 |
| - id("org.jetbrains.kotlin.jvm") version "1.9.0" |
13 |
| - // Gradle IntelliJ Plugin |
14 |
| - id("org.jetbrains.intellij") version "1.15.0" |
15 |
| - // Gradle Changelog Plugin |
16 |
| - id("org.jetbrains.changelog") version "2.1.2" |
17 |
| - // Gradle Qodana Plugin |
18 |
| - id("org.jetbrains.qodana") version "0.1.13" |
19 |
| - // Dependency Updates |
20 |
| - id("com.github.ben-manes.versions") version "0.47.0" |
| 11 | +// id("org.jetbrains.kotlin.jvm") version "2.0.21" |
| 12 | +// // Gradle IntelliJ Plugin |
| 13 | +// id("org.jetbrains.intellij") version "1.17.0" |
| 14 | +// // Gradle Changelog Plugin |
| 15 | +// id("org.jetbrains.changelog") version "2.2.1" |
| 16 | +// // Gradle Qodana Plugin |
| 17 | +// id("org.jetbrains.qodana") version "0.1.13" |
| 18 | +// // Dependency Updates |
| 19 | +// id("com.github.ben-manes.versions") version "0.51.0" |
| 20 | + |
| 21 | + alias(libs.plugins.kotlin) // Kotlin support |
| 22 | + alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin |
| 23 | + alias(libs.plugins.changelog) // Gradle Changelog Plugin |
| 24 | + alias(libs.plugins.qodana) // Gradle Qodana Plugin |
| 25 | + alias(libs.plugins.kover) // Gradle Kover Plugin |
21 | 26 | }
|
22 | 27 |
|
23 | 28 | group = properties("pluginGroup")
|
24 | 29 | version = properties("pluginVersion")
|
25 | 30 |
|
| 31 | + |
| 32 | +kotlin { |
| 33 | + jvmToolchain(17) |
| 34 | +} |
26 | 35 | // Configure project's dependencies
|
27 | 36 | repositories {
|
28 | 37 | mavenCentral()
|
| 38 | + intellijPlatform { |
| 39 | + defaultRepositories() |
| 40 | + } |
29 | 41 | }
|
30 | 42 |
|
31 |
| -// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin |
32 |
| -intellij { |
33 |
| - pluginName.set(properties("pluginName")) |
34 |
| - version.set(properties("platformVersion")) |
35 |
| - type.set(properties("platformType")) |
| 43 | +// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog |
| 44 | +dependencies { |
| 45 | + testImplementation(libs.junit) |
| 46 | + testImplementation("org.opentest4j:opentest4j:1.3.0") |
36 | 47 |
|
37 |
| - // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. |
38 |
| - plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) |
39 |
| -} |
40 |
| - |
41 |
| -// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin |
42 |
| -changelog { |
43 |
| - version.set(properties("pluginVersion")) |
44 |
| - groups.set(emptyList()) |
45 |
| -} |
| 48 | + // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html |
| 49 | + intellijPlatform { |
| 50 | + create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion")) |
46 | 51 |
|
47 |
| -// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin |
48 |
| -qodana { |
49 |
| - cachePath.set(projectDir.resolve(".qodana").canonicalPath) |
50 |
| - reportPath.set(projectDir.resolve("build/reports/inspections").canonicalPath) |
51 |
| - saveReport.set(true) |
52 |
| - showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false) |
53 |
| -} |
| 52 | + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. |
| 53 | +// bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') }) |
54 | 54 |
|
55 |
| -tasks { |
56 |
| - // Set the JVM compatibility versions |
57 |
| - properties("javaVersion").let { |
58 |
| - withType<JavaCompile> { |
59 |
| - sourceCompatibility = it |
60 |
| - targetCompatibility = it |
61 |
| - } |
62 |
| - withType<KotlinCompile> { |
63 |
| - kotlinOptions.jvmTarget = it |
64 |
| - } |
65 |
| - } |
| 55 | + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. |
| 56 | +// plugins(providers.gradleProperty("platformPlugins").map { it.split(',') }) |
66 | 57 |
|
67 |
| - wrapper { |
68 |
| - gradleVersion = properties("gradleVersion") |
| 58 | + instrumentationTools() |
| 59 | + pluginVerifier() |
| 60 | + zipSigner() |
| 61 | + testFramework(TestFrameworkType.Platform) |
69 | 62 | }
|
70 |
| - |
71 |
| - patchPluginXml { |
72 |
| - version.set(properties("pluginVersion")) |
73 |
| - sinceBuild.set(properties("pluginSinceBuild")) |
74 |
| - untilBuild.set(properties("pluginUntilBuild")) |
| 63 | +} |
| 64 | +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html |
| 65 | +intellijPlatform { |
| 66 | + pluginConfiguration { |
| 67 | + version = providers.gradleProperty("pluginVersion") |
75 | 68 |
|
76 | 69 | // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
|
77 |
| - pluginDescription.set( |
78 |
| - projectDir.resolve("README.md").readText().lines().run { |
79 |
| - val start = "<!-- Plugin description -->" |
80 |
| - val end = "<!-- Plugin description end -->" |
| 70 | + description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { |
| 71 | + val start = "<!-- Plugin description -->" |
| 72 | + val end = "<!-- Plugin description end -->" |
81 | 73 |
|
| 74 | + with(it.lines()) { |
82 | 75 | if (!containsAll(listOf(start, end))) {
|
83 | 76 | throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
|
84 | 77 | }
|
85 |
| - subList(indexOf(start) + 1, indexOf(end)) |
86 |
| - }.joinToString("\n").run { markdownToHTML(this) } |
87 |
| - ) |
| 78 | + subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) |
| 79 | + } |
| 80 | + } |
88 | 81 |
|
| 82 | + val changelog = project.changelog // local variable for configuration cache compatibility |
89 | 83 | // Get the latest available change notes from the changelog file
|
90 |
| - changeNotes.set(provider { |
| 84 | + changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion -> |
91 | 85 | with(changelog) {
|
92 | 86 | renderItem(
|
93 |
| - (getOrNull(properties("pluginVersion")) ?: getUnreleased()) |
| 87 | + (getOrNull(pluginVersion) ?: getUnreleased()) |
94 | 88 | .withHeader(false)
|
95 | 89 | .withEmptySections(false),
|
96 | 90 | Changelog.OutputType.HTML,
|
97 | 91 | )
|
98 |
| - |
99 | 92 | }
|
100 |
| - }) |
| 93 | + } |
| 94 | + |
| 95 | + ideaVersion { |
| 96 | + sinceBuild = providers.gradleProperty("pluginSinceBuild") |
| 97 | +// untilBuild = providers.gradleProperty("pluginUntilBuild") |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + signing { |
| 102 | + certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN") |
| 103 | + privateKey = providers.environmentVariable("PRIVATE_KEY") |
| 104 | + password = providers.environmentVariable("PRIVATE_KEY_PASSWORD") |
101 | 105 | }
|
102 | 106 |
|
| 107 | + publishing { |
| 108 | + token = providers.environmentVariable("PUBLISH_TOKEN") |
| 109 | + // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 |
| 110 | + // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: |
| 111 | + // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel |
| 112 | + channels = providers.gradleProperty("pluginVersion") |
| 113 | + .map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) } |
| 114 | + } |
103 | 115 |
|
104 |
| - // Configure UI tests plugin |
105 |
| - // Read more: https://github.com/JetBrains/intellij-ui-test-robot |
106 |
| - runIdeForUiTests { |
107 |
| - systemProperty("robot-server.port", "8082") |
108 |
| - systemProperty("ide.mac.message.dialogs.as.sheets", "false") |
109 |
| - systemProperty("jb.privacy.policy.text", "<!--999.999-->") |
110 |
| - systemProperty("jb.consents.confirmation.enabled", "false") |
| 116 | + pluginVerification { |
| 117 | + ides { |
| 118 | + recommended() |
| 119 | + } |
111 | 120 | }
|
| 121 | +} |
| 122 | + |
| 123 | +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin |
| 124 | +changelog { |
| 125 | + groups.empty() |
| 126 | + repositoryUrl = providers.gradleProperty("pluginRepositoryUrl") |
| 127 | +} |
112 | 128 |
|
113 |
| - signPlugin { |
114 |
| - if (System.getenv("PRIVATE_KEY_PASSWORD") == null) { |
115 |
| - return@signPlugin |
| 129 | +// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration |
| 130 | +kover { |
| 131 | + reports { |
| 132 | + total { |
| 133 | + xml { |
| 134 | + onCheck = true |
| 135 | + } |
116 | 136 | }
|
117 |
| - val decoder = Base64.getDecoder() |
118 |
| - certificateChain.set(String(decoder.decode(System.getenv("CERTIFICATE_CHAIN")))) |
119 |
| - privateKey.set(String(decoder.decode(System.getenv("PRIVATE_KEY")))) |
120 |
| - password.set(String(decoder.decode(System.getenv("PRIVATE_KEY_PASSWORD")))) |
| 137 | + } |
| 138 | +} |
| 139 | + |
| 140 | +tasks { |
| 141 | + wrapper { |
| 142 | + gradleVersion = providers.gradleProperty("gradleVersion").get() |
121 | 143 | }
|
122 | 144 |
|
123 | 145 | publishPlugin {
|
124 |
| - dependsOn("patchChangelog") |
125 |
| - if (System.getenv("PUBLISH_TOKEN") == null) { |
126 |
| - return@publishPlugin |
| 146 | + dependsOn(patchChangelog) |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +intellijPlatformTesting { |
| 151 | + runIde { |
| 152 | + register("runIdeForUiTests") { |
| 153 | + task { |
| 154 | + jvmArgumentProviders += CommandLineArgumentProvider { |
| 155 | + listOf( |
| 156 | + "-Drobot-server.port=8082", |
| 157 | + "-Dide.mac.message.dialogs.as.sheets=false", |
| 158 | + "-Djb.privacy.policy.text=<!--999.999-->", |
| 159 | + "-Djb.consents.confirmation.enabled=false", |
| 160 | + ) |
| 161 | + } |
| 162 | + } |
| 163 | + |
| 164 | + plugins { |
| 165 | + robotServerPlugin() |
| 166 | + } |
127 | 167 | }
|
128 |
| - val decoder = Base64.getDecoder() |
129 |
| - token.set(String(decoder.decode(System.getenv("PUBLISH_TOKEN")))) |
130 |
| - // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 |
131 |
| - // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: |
132 |
| - // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel |
133 |
| - channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())) |
134 | 168 | }
|
135 | 169 | }
|
0 commit comments