Add check to validate related project are added into kotlin plugins bom
^KT-54691 Fixed
This commit is contained in:
committed by
Space Team
parent
8ec90e2bf2
commit
464005aebc
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import org.gradle.api.Action
|
import org.gradle.api.Action
|
||||||
|
import org.gradle.api.GradleException
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.artifacts.Configuration
|
import org.gradle.api.artifacts.Configuration
|
||||||
import org.gradle.api.artifacts.ModuleDependency
|
import org.gradle.api.artifacts.ModuleDependency
|
||||||
@@ -595,3 +596,40 @@ fun Project.publishShadowedJar(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Project.addBomCheckTask() {
|
||||||
|
val checkBomTask = tasks.register("checkGradlePluginsBom") {
|
||||||
|
group = "Validation"
|
||||||
|
description = "Check if project is added into Kotlin Gradle Plugins bom"
|
||||||
|
|
||||||
|
val bomBuildFile = project(":kotlin-gradle-plugins-bom").projectDir.resolve("build.gradle.kts")
|
||||||
|
val exceptions = listOf(
|
||||||
|
project(":gradle:android-test-fixes").path,
|
||||||
|
project(":kotlin-gradle-build-metrics").path,
|
||||||
|
project(":kotlin-gradle-statistics").path,
|
||||||
|
)
|
||||||
|
val projectPath = this@addBomCheckTask.path
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
if (projectPath in exceptions) return@doLast
|
||||||
|
|
||||||
|
val constraintsLines = bomBuildFile.readText()
|
||||||
|
.substringAfter("constraints {")
|
||||||
|
.substringBefore("}")
|
||||||
|
.split("\n")
|
||||||
|
.map { it.trim() }
|
||||||
|
|
||||||
|
val isContainingThisProject = constraintsLines.contains(
|
||||||
|
"api(project(\"$projectPath\"))"
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!isContainingThisProject) {
|
||||||
|
throw GradleException(":kotlin-gradle-plugins-bom does not contain $projectPath project constraint!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("check") {
|
||||||
|
dependsOn(checkBomTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ val signPublication = !version.toString().contains("-SNAPSHOT") &&
|
|||||||
|
|
||||||
configureCommonPublicationSettingsForGradle(signPublication)
|
configureCommonPublicationSettingsForGradle(signPublication)
|
||||||
configureKotlinCompileTasksGradleCompatibility()
|
configureKotlinCompileTasksGradleCompatibility()
|
||||||
|
addBomCheckTask()
|
||||||
extensions.extraProperties["kotlin.stdlib.default.dependency"] = "false"
|
extensions.extraProperties["kotlin.stdlib.default.dependency"] = "false"
|
||||||
|
|
||||||
// common plugin bundle configuration
|
// common plugin bundle configuration
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ plugins {
|
|||||||
|
|
||||||
configureCommonPublicationSettingsForGradle(signLibraryPublication)
|
configureCommonPublicationSettingsForGradle(signLibraryPublication)
|
||||||
configureKotlinCompileTasksGradleCompatibility()
|
configureKotlinCompileTasksGradleCompatibility()
|
||||||
|
addBomCheckTask()
|
||||||
extensions.extraProperties["kotlin.stdlib.default.dependency"] = "false"
|
extensions.extraProperties["kotlin.stdlib.default.dependency"] = "false"
|
||||||
|
|
||||||
val commonSourceSet = createGradleCommonSourceSet()
|
val commonSourceSet = createGradleCommonSourceSet()
|
||||||
|
|||||||
Reference in New Issue
Block a user