|
| 1 | +import org.jetbrains.changelog.Changelog |
| 2 | +import org.jetbrains.changelog.markdownToHTML |
| 3 | +import org.jetbrains.intellij.platform.gradle.Constants.Constraints |
| 4 | +import org.jetbrains.intellij.platform.gradle.TestFrameworkType |
| 5 | + |
1 | 6 | plugins { |
2 | | - id("java") |
3 | | - id("org.jetbrains.kotlin.jvm") version "1.9.24" |
4 | | - id("org.jetbrains.intellij") version "1.17.3" |
| 7 | + id("java") // Java support |
| 8 | + alias(libs.plugins.kotlin) // Kotlin support |
| 9 | + alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin |
| 10 | + alias(libs.plugins.changelog) // Gradle Changelog Plugin |
| 11 | + alias(libs.plugins.qodana) // Gradle Qodana Plugin |
| 12 | + alias(libs.plugins.kover) // Gradle Kover Plugin |
5 | 13 | } |
6 | 14 |
|
7 | | -group = "com.github.junkfactory" |
8 | | -version = "1.0-SNAPSHOT" |
| 15 | +group = providers.gradleProperty("pluginGroup").get() |
| 16 | +version = providers.gradleProperty("pluginVersion").get() |
| 17 | + |
| 18 | +// Set the JVM language level used to build the project. |
| 19 | +kotlin { |
| 20 | + jvmToolchain(17) |
| 21 | +} |
9 | 22 |
|
| 23 | +// Configure project's dependencies |
10 | 24 | repositories { |
11 | | - mavenCentral() |
| 25 | + mavenCentral() |
| 26 | + |
| 27 | + // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html |
| 28 | + intellijPlatform { |
| 29 | + defaultRepositories() |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog |
| 34 | +dependencies { |
| 35 | + testImplementation(libs.junit) |
| 36 | + |
| 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 | + create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion")) |
| 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(',') }) |
| 46 | + |
| 47 | + instrumentationTools() |
| 48 | + pluginVerifier() |
| 49 | + zipSigner() |
| 50 | + testFramework(TestFrameworkType.Platform) |
| 51 | + bundledPlugin("com.intellij.java") |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html |
| 56 | +intellijPlatform { |
| 57 | + pluginConfiguration { |
| 58 | + version = providers.gradleProperty("pluginVersion") |
| 59 | + |
| 60 | + // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest |
| 61 | + description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { |
| 62 | + val start = "<!-- Plugin description -->" |
| 63 | + val end = "<!-- Plugin description end -->" |
| 64 | + |
| 65 | + with(it.lines()) { |
| 66 | + if (!containsAll(listOf(start, end))) { |
| 67 | + throw GradleException("Plugin description section not found in README.md:\n$start ... $end") |
| 68 | + } |
| 69 | + subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + val changelog = project.changelog // local variable for configuration cache compatibility |
| 74 | + // Get the latest available change notes from the changelog file |
| 75 | + changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion -> |
| 76 | + with(changelog) { |
| 77 | + renderItem( |
| 78 | + (getOrNull(pluginVersion) ?: getUnreleased()) |
| 79 | + .withHeader(false) |
| 80 | + .withEmptySections(false), |
| 81 | + Changelog.OutputType.HTML, |
| 82 | + ) |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + ideaVersion { |
| 87 | + sinceBuild = providers.gradleProperty("pluginSinceBuild") |
| 88 | + untilBuild = providers.gradleProperty("pluginUntilBuild") |
| 89 | + } |
| 90 | + } |
| 91 | + |
| 92 | + signing { |
| 93 | + certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN") |
| 94 | + privateKey = providers.environmentVariable("PRIVATE_KEY") |
| 95 | + password = providers.environmentVariable("PRIVATE_KEY_PASSWORD") |
| 96 | + } |
| 97 | + |
| 98 | + publishing { |
| 99 | + token = providers.environmentVariable("PUBLISH_TOKEN") |
| 100 | + // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 |
| 101 | + // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: |
| 102 | + // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel |
| 103 | + channels = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) } |
| 104 | + } |
| 105 | + |
| 106 | + pluginVerification { |
| 107 | + ides { |
| 108 | + recommended() |
| 109 | + } |
| 110 | + } |
12 | 111 | } |
13 | 112 |
|
14 | | -// Configure Gradle IntelliJ Plugin |
15 | | -// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html |
16 | | -intellij { |
17 | | - version.set("2023.2.6") |
18 | | - type.set("IC") // Target IDE Platform |
| 113 | +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin |
| 114 | +changelog { |
| 115 | + groups.empty() |
| 116 | + repositoryUrl = providers.gradleProperty("pluginRepositoryUrl") |
| 117 | +} |
19 | 118 |
|
20 | | - plugins.set(listOf("com.intellij.java")) |
| 119 | +// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration |
| 120 | +kover { |
| 121 | + reports { |
| 122 | + total { |
| 123 | + xml { |
| 124 | + onCheck = true |
| 125 | + } |
| 126 | + } |
| 127 | + } |
21 | 128 | } |
22 | 129 |
|
23 | 130 | tasks { |
24 | | - // Set the JVM compatibility versions |
25 | | - withType<JavaCompile> { |
26 | | - sourceCompatibility = "17" |
27 | | - targetCompatibility = "17" |
28 | | - } |
29 | | - withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { |
30 | | - kotlinOptions.jvmTarget = "17" |
31 | | - } |
32 | | - |
33 | | - patchPluginXml { |
34 | | - sinceBuild.set("232") |
35 | | - untilBuild.set("242.*") |
36 | | - } |
37 | | - |
38 | | - signPlugin { |
39 | | - certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) |
40 | | - privateKey.set(System.getenv("PRIVATE_KEY")) |
41 | | - password.set(System.getenv("PRIVATE_KEY_PASSWORD")) |
42 | | - } |
43 | | - |
44 | | - publishPlugin { |
45 | | - token.set(System.getenv("PUBLISH_TOKEN")) |
46 | | - } |
| 131 | + wrapper { |
| 132 | + gradleVersion = providers.gradleProperty("gradleVersion").get() |
| 133 | + } |
| 134 | + |
| 135 | + publishPlugin { |
| 136 | + dependsOn(patchChangelog) |
| 137 | + } |
| 138 | +} |
| 139 | + |
| 140 | +val runIdeForUiTests by intellijPlatformTesting.runIde.registering { |
| 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(Constraints.LATEST_VERSION) |
| 154 | + } |
47 | 155 | } |
0 commit comments