|
1 | 1 | import org.jetbrains.changelog.Changelog |
2 | 2 | import org.jetbrains.changelog.markdownToHTML |
3 | | -import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel |
| 3 | +import org.jetbrains.intellij.platform.gradle.TestFrameworkType |
| 4 | +import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask.FailureLevel |
4 | 5 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
5 | 6 | import java.util.EnumSet |
6 | 7 |
|
7 | 8 | plugins { |
8 | 9 | id("java") |
9 | 10 | kotlin("jvm") version embeddedKotlinVersion |
10 | | - alias(libs.plugins.jetbrains.intellij) |
| 11 | + alias(libs.plugins.jetbrains.intellij.platform) |
11 | 12 | alias(libs.plugins.jetbrains.changelog) |
12 | 13 | alias(libs.plugins.jetbrains.grammarkit) |
13 | 14 | id("local.bump-version") |
@@ -44,22 +45,96 @@ kotlin { |
44 | 45 | // Configure project's dependencies |
45 | 46 | repositories { |
46 | 47 | mavenCentral() |
| 48 | + intellijPlatform { |
| 49 | + defaultRepositories() |
| 50 | + } |
47 | 51 | } |
48 | 52 |
|
49 | 53 | dependencies { |
| 54 | + compileOnly(libs.jetbrains.annotations) |
| 55 | + |
50 | 56 | testImplementation(platform(libs.junit5.bom)) |
51 | 57 | testImplementation(libs.junit5.jupiter) |
52 | 58 | testImplementation(libs.junit5.platform.testkit) |
| 59 | + testImplementation(libs.junit4) |
53 | 60 | testRuntimeOnly(libs.junit5.vintage.engine) |
| 61 | + |
| 62 | + intellijPlatform { |
| 63 | + create(platformType, platformVersion) |
| 64 | + testFramework(TestFrameworkType.Platform) |
| 65 | + //testFramework(TestFrameworkType.JUnit5) |
| 66 | + instrumentationTools() |
| 67 | + // Version 1.364 seems to be broken and always complains about supposedly missing 'plugin.xml': |
| 68 | + // https://youtrack.jetbrains.com/issue/MP-6388 |
| 69 | + pluginVerifier("1.307") |
| 70 | + } |
54 | 71 | } |
55 | 72 |
|
56 | | -// Configure gradle-intellij-plugin plugin. |
57 | | -// Read more: https://github.com/JetBrains/gradle-intellij-plugin |
58 | | -intellij.pluginName = pluginName |
59 | | -intellij { |
60 | | - version = platformVersion |
61 | | - type = platformType |
62 | | - updateSinceUntilBuild = true |
| 73 | +// Configure intellij-platform-gradle-plugin plugin. |
| 74 | +// Read more: https://github.com/JetBrains/intellij-platform-gradle-plugin |
| 75 | +intellijPlatform { |
| 76 | + projectName = pluginName |
| 77 | + pluginConfiguration { |
| 78 | + id = "nix-idea" |
| 79 | + name = "NixIDEA" |
| 80 | + version = pluginVersion |
| 81 | + vendor { |
| 82 | + name = "NixOS" |
| 83 | + } |
| 84 | + ideaVersion { |
| 85 | + sinceBuild = pluginSinceBuild |
| 86 | + untilBuild = pluginUntilBuild |
| 87 | + } |
| 88 | + // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest |
| 89 | + description = providers.provider { |
| 90 | + projectDir.resolve("README.md").readText().lines() |
| 91 | + .run { |
| 92 | + val start = "<!-- Plugin description -->" |
| 93 | + val end = "<!-- Plugin description end -->" |
| 94 | + if (!containsAll(listOf(start, end))) { |
| 95 | + throw GradleException("Plugin description section not found in README.md:\n$start ... $end") |
| 96 | + } |
| 97 | + subList(indexOf(start) + 1, indexOf(end)) |
| 98 | + } |
| 99 | + .joinToString("\n") |
| 100 | + .run { markdownToHTML(this) } |
| 101 | + } |
| 102 | + // Get the latest available change notes from the changelog file |
| 103 | + changeNotes = provider { |
| 104 | + with(changelog) { |
| 105 | + renderItem( |
| 106 | + (getOrNull(pluginVersion) ?: getUnreleased()) |
| 107 | + .withHeader(false) |
| 108 | + .withEmptySections(false), |
| 109 | + Changelog.OutputType.HTML |
| 110 | + ) |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | + verifyPlugin { |
| 115 | + ides { |
| 116 | + ides( |
| 117 | + providers.gradleProperty("verifierIdeVersionOverride") |
| 118 | + // Verify only against the IDE specified by the property |
| 119 | + .map { listOf(it) } |
| 120 | + // If property is not set, verify against the recommended list of IDEs |
| 121 | + .orElse(ProductReleasesValueSource()) |
| 122 | + ) |
| 123 | + } |
| 124 | + failureLevel = EnumSet.complementOf( |
| 125 | + EnumSet.of( |
| 126 | + FailureLevel.DEPRECATED_API_USAGES, |
| 127 | + FailureLevel.SCHEDULED_FOR_REMOVAL_API_USAGES, |
| 128 | + FailureLevel.EXPERIMENTAL_API_USAGES, |
| 129 | + ) |
| 130 | + ) |
| 131 | + } |
| 132 | + publishing { |
| 133 | + token = providers.environmentVariable("JETBRAINS_TOKEN") |
| 134 | + // Note: `listOf("foo").first()` does not what you think on Java 21 and Gradle 8.6. (The return type is TaskProvider<Task>) |
| 135 | + // See https://github.com/gradle/gradle/issues/27699 and https://youtrack.jetbrains.com/issue/KT-65235. |
| 136 | + channels = listOf(pluginVersion.split('-').getOrElse(1) { "default" }.split('.')[0]) |
| 137 | + } |
63 | 138 | } |
64 | 139 |
|
65 | 140 | changelog { |
@@ -151,58 +226,4 @@ tasks { |
151 | 226 | } |
152 | 227 | } |
153 | 228 |
|
154 | | - patchPluginXml { |
155 | | - version = pluginVersion |
156 | | - sinceBuild = pluginSinceBuild |
157 | | - untilBuild = pluginUntilBuild |
158 | | - |
159 | | - // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest |
160 | | - pluginDescription = providers.provider { |
161 | | - projectDir.resolve("README.md").readText().lines() |
162 | | - .run { |
163 | | - val start = "<!-- Plugin description -->" |
164 | | - val end = "<!-- Plugin description end -->" |
165 | | - if (!containsAll(listOf(start, end))) { |
166 | | - throw GradleException("Plugin description section not found in README.md:\n$start ... $end") |
167 | | - } |
168 | | - subList(indexOf(start) + 1, indexOf(end)) |
169 | | - } |
170 | | - .joinToString("\n") |
171 | | - .run { markdownToHTML(this) } |
172 | | - } |
173 | | - |
174 | | - // Get the latest available change notes from the changelog file |
175 | | - changeNotes = provider { |
176 | | - with(changelog) { |
177 | | - renderItem( |
178 | | - (getOrNull(pluginVersion) ?: getUnreleased()) |
179 | | - .withHeader(false) |
180 | | - .withEmptySections(false), |
181 | | - Changelog.OutputType.HTML |
182 | | - ) |
183 | | - } |
184 | | - } |
185 | | - } |
186 | | - |
187 | | - runPluginVerifier { |
188 | | - ideVersions = providers.gradleProperty("verifierIdeVersionOverride").map { listOf(it) }.orElse(listOf()) |
189 | | - failureLevel = EnumSet.complementOf( |
190 | | - EnumSet.of( |
191 | | - FailureLevel.DEPRECATED_API_USAGES, |
192 | | - FailureLevel.SCHEDULED_FOR_REMOVAL_API_USAGES, |
193 | | - FailureLevel.EXPERIMENTAL_API_USAGES, |
194 | | - ) |
195 | | - ) |
196 | | - // Version 1.364 seems to be broken and always complains about supposedly missing 'plugin.xml': |
197 | | - // https://youtrack.jetbrains.com/issue/MP-6388 |
198 | | - verifierVersion = "1.307" |
199 | | - } |
200 | | - |
201 | | - publishPlugin { |
202 | | - token = providers.environmentVariable("JETBRAINS_TOKEN") |
203 | | - // Note: `listOf("foo").first()` does not what you think on Java 21 and Gradle 8.6. (The return type is TaskProvider<Task>) |
204 | | - // See https://github.com/gradle/gradle/issues/27699 and https://youtrack.jetbrains.com/issue/KT-65235. |
205 | | - channels = listOf(pluginVersion.split('-').getOrElse(1) { "default" }.split('.')[0]) |
206 | | - } |
207 | | - |
208 | 229 | } |
0 commit comments