From b6a8e58832929cd08d7fcd9f92e7fd010990f5e0 Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 18 Jul 2022 14:41:22 +0200 Subject: [PATCH] Remove kotlin-stdlib dependency from gradle runner (#2570) --- runners/gradle-plugin/build.gradle.kts | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/runners/gradle-plugin/build.gradle.kts b/runners/gradle-plugin/build.gradle.kts index f8e519e647..2a61294fd4 100644 --- a/runners/gradle-plugin/build.gradle.kts +++ b/runners/gradle-plugin/build.gradle.kts @@ -32,13 +32,27 @@ dependencies { // Gradle will put its own version of the stdlib in the classpath, do not pull our own we will end up with // warnings like 'Runtime JAR files in the classpath should have the same version' -configurations.api { - exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib") - exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7") - exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8") - exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common") +configurations.api.configure { + excludeGradleCommonDependencies() } +/** + * These dependencies will be provided by Gradle, and we should prevent version conflict + * Code taken from the Kotlin Gradle plugin: + * https://github.com/JetBrains/kotlin/blob/70e15b281cb43379068facb82b8e4bcb897a3c4f/buildSrc/src/main/kotlin/GradleCommon.kt#L72 + */ +fun Configuration.excludeGradleCommonDependencies() { + dependencies + .withType() + .configureEach { + exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib") + exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7") + exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8") + exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common") + exclude(group = "org.jetbrains.kotlin", module = "kotlin-reflect") + exclude(group = "org.jetbrains.kotlin", module = "kotlin-script-runtime") + } +} val sourceJar by tasks.registering(Jar::class) { archiveClassifier.set("sources")