|
1 | 1 | import org.jetbrains.changelog.Changelog |
2 | 2 | import org.jetbrains.changelog.markdownToHTML |
3 | 3 |
|
4 | | -fun properties(key: String) = project.findProperty(key).toString() |
| 4 | +fun properties(key: String) = providers.gradleProperty(key) |
| 5 | +fun environment(key: String) = providers.environmentVariable(key) |
5 | 6 |
|
6 | 7 | plugins { |
7 | | - // Java support |
8 | | - id("java") |
9 | | - // Kotlin support |
10 | | - id("org.jetbrains.kotlin.jvm") version "1.9.22" |
11 | | - // Gradle IntelliJ Plugin |
12 | | - id("org.jetbrains.intellij") version "1.16.1" |
13 | | - // Gradle Changelog Plugin |
14 | | -/* ROLL_BACK_CHANGELOG_PLUGIN BEGIN - https://github.com/JetBrains/gradle-changelog-plugin/issues/147 |
15 | | - id("org.jetbrains.changelog") version "2.0.0" |
16 | | -*/ |
17 | | - id("org.jetbrains.changelog") version "2.2.0" |
18 | | -/* ROLL_BACK_CHANGELOG_PLUGIN END */ |
19 | | - // Gradle Qodana Plugin |
20 | | - id("org.jetbrains.qodana") version "0.1.13" |
| 8 | + id("java") // Java support |
| 9 | + alias(libs.plugins.kotlin) // Kotlin support |
| 10 | + alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin |
| 11 | + alias(libs.plugins.changelog) // Gradle Changelog Plugin |
| 12 | + alias(libs.plugins.qodana) // Gradle Qodana Plugin |
| 13 | + alias(libs.plugins.kover) // Gradle Kover Plugin |
21 | 14 | } |
22 | 15 |
|
23 | | -group = properties("pluginGroup") |
24 | | -version = properties("pluginVersion") |
| 16 | +group = properties("pluginGroup").get() |
| 17 | +version = properties("pluginVersion").get() |
25 | 18 |
|
26 | 19 | // Configure project's dependencies |
27 | 20 | repositories { |
28 | 21 | mavenCentral() |
29 | 22 | } |
| 23 | + |
| 24 | +// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog |
30 | 25 | dependencies { |
31 | | - implementation("io.ktor:ktor-client-content-negotiation:2.3.7") |
32 | | - implementation("io.ktor:ktor-client-core:2.3.7") |
33 | | - implementation("io.ktor:ktor-client-cio:2.3.7") |
34 | | - implementation("io.ktor:ktor-client-gson:2.3.7") |
35 | | - implementation("io.ktor:ktor-serialization-gson:2.3.7") |
| 26 | + implementation(libs.ktor.content.negotiation) |
| 27 | + implementation(libs.ktor.client.core) |
| 28 | + implementation(libs.ktor.client.cio) |
| 29 | + implementation(libs.ktor.client.gson) |
| 30 | + implementation(libs.ktor.serialization.gson) |
36 | 31 | } |
37 | 32 |
|
38 | 33 | // Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+. |
39 | 34 | kotlin { |
40 | | - jvmToolchain(17) |
| 35 | + jvmToolchain { |
| 36 | + languageVersion = JavaLanguageVersion.of(17) |
| 37 | + vendor = JvmVendorSpec.JETBRAINS |
| 38 | + } |
41 | 39 | } |
42 | 40 |
|
43 | 41 | // Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html |
44 | 42 | intellij { |
45 | | - pluginName.set(properties("pluginName")) |
46 | | - version.set(properties("platformVersion")) |
47 | | - type.set(properties("platformType")) |
| 43 | + pluginName = properties("pluginName") |
| 44 | + version = properties("platformVersion") |
| 45 | + type = properties("platformType") |
48 | 46 |
|
49 | 47 | // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. |
50 | | - plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) |
| 48 | + plugins = properties("platformPlugins").map { it.split(',').map(String::trim).filter(String::isNotEmpty) } |
51 | 49 | } |
52 | 50 |
|
53 | 51 | // Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin |
54 | 52 | changelog { |
55 | | - groups.set(emptyList()) |
56 | | -/* ROLL_BACK_CHANGELOG_PLUGIN BEGIN - https://github.com/JetBrains/gradle-changelog-plugin/issues/147 |
57 | | - repositoryUrl.set(properties("pluginRepositoryUrl")) |
58 | | -*/ |
59 | | -/* ROLL_BACK_CHANGELOG_PLUGIN END */ |
60 | | - path.set(File(projectDir, "../CHANGELOG.md").absolutePath) |
| 53 | + groups.empty() |
| 54 | + repositoryUrl = properties("pluginRepositoryUrl") |
| 55 | + path = File(projectDir, "../CHANGELOG.md").absolutePath |
61 | 56 | } |
62 | 57 |
|
63 | 58 | // Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin |
64 | 59 | qodana { |
65 | | - cachePath.set(file(".qodana").canonicalPath) |
66 | | - reportPath.set(file("build/reports/inspections").canonicalPath) |
67 | | - saveReport.set(true) |
68 | | - showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false) |
| 60 | + cachePath = provider { file(".qodana").canonicalPath } |
| 61 | + reportPath = provider { file("build/reports/inspections").canonicalPath } |
| 62 | + saveReport = true |
| 63 | + showReport = environment("QODANA_SHOW_REPORT").map { it.toBoolean() }.getOrElse(false) |
| 64 | +} |
| 65 | + |
| 66 | +// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration |
| 67 | +koverReport { |
| 68 | + defaults { |
| 69 | + xml { |
| 70 | + onCheck = true |
| 71 | + } |
| 72 | + } |
69 | 73 | } |
70 | 74 |
|
71 | 75 | tasks { |
72 | 76 | wrapper { |
73 | | - gradleVersion = properties("gradleVersion") |
| 77 | + gradleVersion = properties("gradleVersion").get() |
74 | 78 | } |
75 | 79 |
|
76 | 80 | patchPluginXml { |
77 | | - version.set(properties("pluginVersion")) |
78 | | - sinceBuild.set(properties("pluginSinceBuild")) |
79 | | - untilBuild.set(properties("pluginUntilBuild")) |
| 81 | + version = properties("pluginVersion") |
| 82 | + sinceBuild = properties("pluginSinceBuild") |
| 83 | + untilBuild = properties("pluginUntilBuild") |
80 | 84 |
|
81 | 85 | // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest |
82 | | - pluginDescription.set( |
83 | | - file("../README.md").readText().lines().run { |
84 | | - val start = "<!-- Plugin description -->" |
85 | | - val end = "<!-- Plugin description end -->" |
| 86 | + pluginDescription = providers.fileContents(layout.projectDirectory.file("../README.md")).asText.map { |
| 87 | + val start = "<!-- Plugin description -->" |
| 88 | + val end = "<!-- Plugin description end -->" |
86 | 89 |
|
| 90 | + with (it.lines()) { |
87 | 91 | if (!containsAll(listOf(start, end))) { |
88 | 92 | throw GradleException("Plugin description section not found in README.md:\n$start ... $end") |
89 | 93 | } |
90 | | - subList(indexOf(start) + 1, indexOf(end)) |
91 | | - }.joinToString("\n").let { markdownToHTML(it) } |
92 | | - ) |
| 94 | + subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) |
| 95 | + } |
| 96 | + } |
93 | 97 |
|
| 98 | + val changelog = project.changelog // local variable for configuration cache compatibility |
94 | 99 | // Get the latest available change notes from the changelog file |
95 | | - changeNotes.set(provider { |
96 | | -/* ROLL_BACK_CHANGELOG_PLUGIN BEGIN - https://github.com/JetBrains/gradle-changelog-plugin/issues/147 |
97 | | - renderItem( |
98 | | - getOrNull(properties("pluginVersion")) |
99 | | - ?: runCatching { getLatest() }.getOrElse { getUnreleased() }, |
100 | | - Changelog.OutputType.HTML, |
101 | | - ) |
102 | | -*/ |
103 | | - changelog.renderItem(changelog.run { |
104 | | - getOrNull(properties("pluginVersion")) ?: getLatest() |
105 | | - }, Changelog.OutputType.HTML) |
106 | | -/* ROLL_BACK_CHANGELOG_PLUGIN END */ |
107 | | - }) |
| 100 | + changeNotes = properties("pluginVersion").map { pluginVersion -> |
| 101 | + with(changelog) { |
| 102 | + renderItem( |
| 103 | + (getOrNull(pluginVersion) ?: getUnreleased()) |
| 104 | + .withHeader(false) |
| 105 | + .withEmptySections(false), |
| 106 | + Changelog.OutputType.HTML, |
| 107 | + ) |
| 108 | + } |
| 109 | + } |
108 | 110 | } |
109 | 111 |
|
110 | 112 | // Configure UI tests plugin |
@@ -135,17 +137,17 @@ tasks { |
135 | 137 | } |
136 | 138 |
|
137 | 139 | signPlugin { |
138 | | - certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) |
139 | | - privateKey.set(System.getenv("PRIVATE_KEY")) |
140 | | - password.set(System.getenv("PRIVATE_KEY_PASSWORD")) |
| 140 | + certificateChain = environment("CERTIFICATE_CHAIN") |
| 141 | + privateKey = environment("PRIVATE_KEY") |
| 142 | + password = environment("PRIVATE_KEY_PASSWORD") |
141 | 143 | } |
142 | 144 |
|
143 | 145 | publishPlugin { |
144 | 146 | dependsOn("patchChangelog") |
145 | | - token.set(System.getenv("PUBLISH_TOKEN")) |
| 147 | + token = environment("PUBLISH_TOKEN") |
146 | 148 | // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 |
147 | 149 | // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: |
148 | 150 | // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel |
149 | | - channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())) |
| 151 | + channels = properties("pluginVersion").map { listOf(it.split('-').getOrElse(1) { "default" }.split('.').first()) } |
150 | 152 | } |
151 | 153 | } |
0 commit comments