Fix exposing provided by Gradle Kotlin dependencies.
Ensure that Gradle plugin dependencies do not include kotlin-stdlib, kotlin-reflect and other dependencies that are provided by Gradle runtime. ^KT-41142 Fixed
This commit is contained in:
committed by
teamcityserver
parent
1198b40c11
commit
13fd2a24ea
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
publish()
|
||||
standardPublicJars()
|
||||
|
||||
extensions.extraProperties["kotlin.stdlib.default.dependency"] = "false"
|
||||
|
||||
dependencies {
|
||||
compileOnly(kotlinStdlib())
|
||||
compileOnly(gradleApi())
|
||||
}
|
||||
|
||||
// These dependencies will be provided by Gradle and we should prevent version conflict
|
||||
fun Configuration.excludeGradleCommonDependencies() {
|
||||
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")
|
||||
}
|
||||
configurations {
|
||||
"implementation" {
|
||||
excludeGradleCommonDependencies()
|
||||
}
|
||||
"api" {
|
||||
excludeGradleCommonDependencies()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.languageVersion = "1.3"
|
||||
kotlinOptions.apiVersion = "1.3"
|
||||
kotlinOptions.freeCompilerArgs += listOf(
|
||||
"-Xskip-prerelease-check",
|
||||
"-Xskip-runtime-version-check",
|
||||
"-Xsuppress-version-warnings"
|
||||
)
|
||||
}
|
||||
|
||||
tasks.named<Jar>("jar") {
|
||||
callGroovy("manifestAttributes", manifest, project)
|
||||
}
|
||||
@@ -72,6 +72,7 @@ class CodeConformanceTest : TestCase() {
|
||||
File("."),
|
||||
listOf(
|
||||
"build",
|
||||
"buildSrc/build/generated-sources",
|
||||
"buildSrc/prepare-deps/build",
|
||||
"compiler/ir/serialization.js/build/fullRuntime",
|
||||
"compiler/ir/serialization.js/build/reducedRuntime/src/libraries/stdlib/js-ir/runtime/longjs.kt",
|
||||
@@ -97,6 +98,7 @@ class CodeConformanceTest : TestCase() {
|
||||
"libraries/stdlib/js-v1/node_modules",
|
||||
"libraries/stdlib/wasm/build",
|
||||
"libraries/tools/kotlin-gradle-plugin-integration-tests/build",
|
||||
"libraries/tools/kotlin-gradle-plugin-integration-tests/.testKitDir",
|
||||
"libraries/tools/kotlin-maven-plugin-test/target",
|
||||
"libraries/tools/kotlin-test-js-runner/.gradle",
|
||||
"libraries/tools/kotlin-test-js-runner/lib",
|
||||
|
||||
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile(kotlinStdlib())
|
||||
implementation(kotlinStdlib())
|
||||
testImplementation(commonDep("junit:junit"))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
description = "kotlin-gradle-statistics"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("gradle-plugin-common-configuration")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(kotlinStdlib())
|
||||
|
||||
testImplementation(project(":kotlin-test:kotlin-test-junit"))
|
||||
testImplementation("junit:junit:4.12")
|
||||
}
|
||||
@@ -20,8 +18,3 @@ sourceSets {
|
||||
projectTest {
|
||||
workingDir = rootDir
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
@@ -1,20 +1,13 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.pill.PillExtension
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("gradle-plugin-common-configuration")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
standardPublicJars()
|
||||
|
||||
dependencies {
|
||||
implementation(kotlinStdlib())
|
||||
implementation(project(":native:kotlin-native-utils"))
|
||||
api(project(":native:kotlin-native-utils"))
|
||||
|
||||
compileOnly(gradleApi())
|
||||
compileOnly("com.android.tools.build:gradle:3.4.0")
|
||||
compileOnly(project(":kotlin-project-model"))
|
||||
}
|
||||
@@ -22,19 +15,3 @@ dependencies {
|
||||
pill {
|
||||
variant = PillExtension.Variant.FULL
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<KotlinCompile> {
|
||||
kotlinOptions.languageVersion = "1.3"
|
||||
kotlinOptions.apiVersion = "1.3"
|
||||
kotlinOptions.freeCompilerArgs += listOf(
|
||||
"-Xskip-prerelease-check",
|
||||
"-Xskip-runtime-version-check",
|
||||
"-Xsuppress-version-warnings"
|
||||
)
|
||||
}
|
||||
|
||||
named<Jar>("jar") {
|
||||
callGroovy("manifestAttributes", manifest, project)
|
||||
}
|
||||
}
|
||||
|
||||
+29
@@ -178,4 +178,33 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GradleTest
|
||||
@DisplayName("Should not produce kotlin-stdlib version conflict on Kotlin files compilation in 'buildSrc' module")
|
||||
internal fun testKotlinDslStdlibVersionConflict(gradleVersion: GradleVersion) {
|
||||
project(
|
||||
projectName = "buildSrcUsingKotlinCompilationAndKotlinPlugin",
|
||||
gradleVersion,
|
||||
forceOutput = true
|
||||
) {
|
||||
listOf(
|
||||
"compileClasspath",
|
||||
"compileOnly",
|
||||
"runtimeClasspath"
|
||||
).forEach { configuration ->
|
||||
build("-p", "buildSrc", "dependencies", "--configuration", configuration) {
|
||||
listOf(
|
||||
"org.jetbrains.kotlin:kotlin-stdlib:${buildOptions.kotlinVersion}",
|
||||
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:${buildOptions.kotlinVersion}",
|
||||
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:${buildOptions.kotlinVersion}",
|
||||
"org.jetbrains.kotlin:kotlin-stdlib-common:${buildOptions.kotlinVersion}",
|
||||
"org.jetbrains.kotlin:kotlin-reflect:${buildOptions.kotlinVersion}",
|
||||
"org.jetbrains.kotlin:kotlin-script-runtime:${buildOptions.kotlinVersion}"
|
||||
).forEach { assertOutputDoesNotContain(it) }
|
||||
}
|
||||
}
|
||||
|
||||
build("assemble")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${property("kotlin_version")}")
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import org.gradle.api.Project
|
||||
|
||||
fun Project.nameLength() = name.length
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
fun main() {
|
||||
println("Hello World!")
|
||||
}
|
||||
@@ -1,33 +1,10 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.pill.PillExtension
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("gradle-plugin-common-configuration")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
standardPublicJars()
|
||||
|
||||
dependencies {
|
||||
compile(kotlinStdlib())
|
||||
}
|
||||
|
||||
pill {
|
||||
variant = PillExtension.Variant.FULL
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<KotlinCompile> {
|
||||
kotlinOptions.languageVersion = "1.3"
|
||||
kotlinOptions.apiVersion = "1.3"
|
||||
kotlinOptions.freeCompilerArgs += listOf(
|
||||
"-Xskip-prerelease-check", "-Xsuppress-version-warnings"
|
||||
)
|
||||
}
|
||||
|
||||
named<Jar>("jar") {
|
||||
callGroovy("manifestAttributes", manifest, project)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import org.jetbrains.dokka.gradle.DokkaTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.pill.PillExtension
|
||||
|
||||
plugins {
|
||||
java
|
||||
kotlin("jvm")
|
||||
`java-gradle-plugin`
|
||||
id("gradle-plugin-common-configuration")
|
||||
id("org.jetbrains.dokka")
|
||||
id("jps-compatible")
|
||||
}
|
||||
@@ -17,13 +16,8 @@ configure<GradlePluginDevelopmentExtension> {
|
||||
isAutomatedPublishing = false
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
val jarContents by configurations.creating
|
||||
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
repositories {
|
||||
google()
|
||||
maven("https://plugins.gradle.org/m2/")
|
||||
@@ -40,7 +34,6 @@ dependencies {
|
||||
compileOnly(project(":compiler:incremental-compilation-impl"))
|
||||
compileOnly(project(":daemon-common"))
|
||||
|
||||
implementation(kotlinStdlib())
|
||||
implementation(project(":kotlin-util-klib"))
|
||||
implementation(project(":native:kotlin-klib-commonizer-api"))
|
||||
implementation(project(":kotlin-tooling-metadata"))
|
||||
@@ -70,8 +63,7 @@ dependencies {
|
||||
compileOnly("com.android.tools.build:builder:3.4.0")
|
||||
compileOnly("com.android.tools.build:builder-model:3.4.0")
|
||||
compileOnly("org.codehaus.groovy:groovy-all:2.4.12")
|
||||
compileOnly(gradleApi())
|
||||
|
||||
compileOnly(project(":kotlin-reflect"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
|
||||
runtimeOnly(projectRuntimeJar(":kotlin-compiler-embeddable"))
|
||||
@@ -80,7 +72,6 @@ dependencies {
|
||||
runtimeOnly(projectRuntimeJar(":kotlin-compiler-runner"))
|
||||
runtimeOnly(projectRuntimeJar(":kotlin-scripting-compiler-embeddable"))
|
||||
runtimeOnly(projectRuntimeJar(":kotlin-scripting-compiler-impl-embeddable"))
|
||||
runtimeOnly(project(":kotlin-reflect"))
|
||||
|
||||
jarContents(compileOnly(intellijDep()) {
|
||||
includeJars("asm-all", "gson", "guava", "serviceMessages", rootProject = rootProject)
|
||||
@@ -124,17 +115,6 @@ runtimeJar(rewriteDefaultJarDepsToShadedCompiler()).configure {
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<KotlinCompile> {
|
||||
kotlinOptions.jdkHome = rootProject.extra["JDK_18"] as String
|
||||
kotlinOptions.languageVersion = "1.3"
|
||||
kotlinOptions.apiVersion = "1.3"
|
||||
kotlinOptions.freeCompilerArgs += listOf(
|
||||
"-Xskip-prerelease-check",
|
||||
"-Xskip-runtime-version-check",
|
||||
"-Xsuppress-version-warnings"
|
||||
)
|
||||
}
|
||||
|
||||
named<ProcessResources>("processResources") {
|
||||
val propertiesToExpand = mapOf(
|
||||
"projectVersion" to project.version,
|
||||
@@ -148,10 +128,6 @@ tasks {
|
||||
}
|
||||
}
|
||||
|
||||
named<Jar>("jar") {
|
||||
callGroovy("manifestAttributes", manifest, project)
|
||||
}
|
||||
|
||||
withType<ValidatePlugins>().configureEach {
|
||||
failOnWarning.set(true)
|
||||
enableStricterValidation.set(true)
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
description = "kotlin-gradle-statistics"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("gradle-plugin-common-configuration")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(kotlinStdlib())
|
||||
|
||||
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
||||
testCompile("junit:junit:4.12")
|
||||
testImplementation(project(":kotlin-test:kotlin-test-junit"))
|
||||
testImplementation("junit:junit:4.12")
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -7,11 +7,11 @@ description = "Kotlin/Native utils"
|
||||
|
||||
dependencies {
|
||||
compileOnly(kotlinStdlib())
|
||||
compile(project(":kotlin-util-io"))
|
||||
api(project(":kotlin-util-io"))
|
||||
|
||||
testCompile(commonDep("junit:junit"))
|
||||
testImplementation(commonDep("junit:junit"))
|
||||
testCompileOnly(project(":kotlin-reflect-api"))
|
||||
testRuntime(project(":kotlin-reflect"))
|
||||
testImplementation(project(":kotlin-reflect"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
Reference in New Issue
Block a user