Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions build-settings-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,75 @@ dependencies {
implementation(libs.gradlePlugin.gradle.customUserData)
implementation(libs.gradlePlugin.gradle.foojayToolchains)
}


//region check consistent develocity version

val checkBuildSettingsLogicPluginConsistency by tasks.registering {
description = "Check consistency of plugin versions in settings.gradle.kts with version catalog."
group = LifecycleBasePlugin.VERIFICATION_GROUP

val customUserDataVersion = libs.versions.gradlePlugin.gradle.customUserData
val develocityVersion = libs.versions.gradlePlugin.gradle.develocity
val foojayToolchainsVersion = libs.versions.gradlePlugin.gradle.foojayToolchains

inputs.property("customUserDataVersionCatalogVersion", customUserDataVersion)
inputs.property("develocityVersionCatalogVersion", develocityVersion)
inputs.property("foojayToolchainsVersionCatalogVersion", foojayToolchainsVersion)

val settingsGradleKtsInput = layout.projectDirectory.file("settings.gradle.kts")
inputs.file(settingsGradleKtsInput)
.withPropertyName("settingsGradleKtsInput")
.normalizeLineEndings()
.withPathSensitivity(PathSensitivity.RELATIVE)

val projectName = project.displayName

doLast {
val pluginVersionsMap =
settingsGradleKtsInput.asFile.useLines { lines ->
lines
.dropWhile { it != "plugins {" }
.takeWhile { it != "}" }
.filter { it.startsWith(" id(") }
.associate {
val id = it.substringAfter("id(\"")
.substringBefore("\")")
val version = it.substringAfter("version \"")
.substringBefore("\"")
id to version
}
}

val result = buildString {
fun checkVersion(id: String, version: String) {
val actualVersion = pluginVersionsMap[id]
when {
actualVersion == null ->
appendLine("plugin $id: missing")

actualVersion != version ->
appendLine("plugin $id: expected $version, actual ${pluginVersionsMap[id]}")
}
}

checkVersion("com.gradle.develocity", develocityVersion.get())
checkVersion("com.gradle.common-custom-user-data-gradle-plugin", customUserDataVersion.get())
checkVersion("org.gradle.toolchains.foojay-resolver-convention", foojayToolchainsVersion.get())
}

check(result.isEmpty()) {
"""
$projectName - inconsistent plugin versions:
${result.prependIndent()}
""".trimIndent()
}
}
}

tasks.compileKotlin {
// pick a task that always runs to depend on the check, to make sure it always runs
dependsOn(checkBuildSettingsLogicPluginConsistency)
}

//endregion
8 changes: 4 additions & 4 deletions build-settings-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ dependencyResolutionManagement {

//region copy of src/main/kotlin/dokkasettings.settings.gradle.kts

// version should be kept in sync with `gradle/libs.versions.toml`
plugins {
id("com.gradle.develocity") version "3.17.6"
id("com.gradle.common-custom-user-data-gradle-plugin") version "2.0.2" apply false
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
// versions should be kept in sync with `gradle/libs.versions.toml`
id("com.gradle.develocity") version "4.1.1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: build scan can not be published now
https://teamcity.jetbrains.com/buildConfiguration/KotlinTools_Dokka_IntegrationTests_virtual_Batch_4_1/5440896?showLog=5440896_1382_622&logFilter=debug&logView=flowAware

Publishing Build Scan...
13:15:46   
13:15:46   The request was rejected.
13:15:46   Develocity plugin version 4.1.1 is newer than the newest version supported by Develocity 2024.3.5 which is 3.19. Please update to a newer version of Develocity.

id("com.gradle.common-custom-user-data-gradle-plugin") version "2.3" apply false
id("org.gradle.toolchains.foojay-resolver-convention") version "0.10.0"
}

//region properties
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ gradlePlugin-gradleNode = "7.1.0"

## Gradle Develocity
# versions should be kept in sync with `build-settings-logic/settings.gradle.kts`
gradlePlugin-gradle-customUserData = "2.0.2"
gradlePlugin-gradle-develocity = "3.18.2"
gradlePlugin-gradle-foojayToolchains = "0.7.0"
gradlePlugin-gradle-customUserData = "2.3"
gradlePlugin-gradle-develocity = "4.1.1"
gradlePlugin-gradle-foojayToolchains = "0.10.0"

## Test
junit = "5.9.3"
Expand Down
Loading