Skip to content

Commit d6a9a98

Browse files
committed
build: use the Provider API whenever possible
1 parent 7bb2f03 commit d6a9a98

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

build.gradle.kts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
88
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
99
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
1010

11-
fun stringProperty(key: String, default: String? = null): String =
12-
findProperty(key)?.toString() ?: default ?: error("Expected a valid property $key")
13-
1411
plugins {
1512
java
1613
alias(libs.plugins.kotlin)
@@ -27,9 +24,13 @@ repositories {
2724
}
2825
}
2926

27+
val pluginVersion: Provider<String> = providers.gradleProperty("version")
28+
val pluginSinceBuild: Provider<String> = providers.gradleProperty("pluginSinceBuild")
29+
val platformVersion: Provider<String> = providers.gradleProperty("platformVersion")
30+
3031
dependencies {
3132
intellijPlatform {
32-
intellijIdea(version = stringProperty("platformVersion"))
33+
intellijIdea(version = platformVersion)
3334

3435
bundledModule("intellij.platform.vcs.dvcs")
3536
bundledModule("intellij.platform.vcs.dvcs.impl")
@@ -53,17 +54,17 @@ dependencies {
5354

5455
intellijPlatform {
5556
pluginConfiguration {
56-
val versionStr = stringProperty("version")
57-
version = versionStr
57+
version = pluginVersion
5858

59-
val descriptionFile = file("plugin-description.html")
60-
description = descriptionFile.readText()
59+
val pluginDescFile = layout.projectDirectory.file("plugin-description.html")
60+
description = providers.fileContents(pluginDescFile).asText
6161

62-
val changeNotesFile = file("change-notes/${versionStr.replace('.', '_')}.html")
63-
changeNotes = changeNotesFile.readText()
62+
val changeNotesPath = pluginVersion.map { "change-notes/${it.replace('.', '_')}.html" }
63+
val changeNotesFile = layout.projectDirectory.file(changeNotesPath)
64+
changeNotes = providers.fileContents(changeNotesFile).asText
6465

6566
ideaVersion {
66-
sinceBuild = stringProperty("pluginSinceBuild")
67+
sinceBuild = pluginSinceBuild
6768
}
6869
}
6970

0 commit comments

Comments
 (0)