Fix Gradle 7 deprecation on adding associated compilation dependencies.
^KT-45787 Fixed
This commit is contained in:
committed by
TeamCityServer
parent
7f60cd81fe
commit
768c165a72
+20
@@ -1207,4 +1207,24 @@ class KotlinGradleIT : BaseGradleIT() {
|
||||
assertTrue(compiledKotlinClasses.isEmpty())
|
||||
}
|
||||
}
|
||||
|
||||
/** Regression test for KT-45787. **/
|
||||
@Test
|
||||
fun testPluginDoesNotUseDeprecatedConfigurationsForAssociatedDependencies() {
|
||||
with(
|
||||
Project(
|
||||
projectName = "associatedDependencies",
|
||||
minLogLevel = LogLevel.INFO
|
||||
)
|
||||
) {
|
||||
setupWorkingDir()
|
||||
|
||||
build(
|
||||
"tasks",
|
||||
options = defaultBuildOptions().copy(warningMode = WarningMode.Fail)
|
||||
) {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
integrationTest {
|
||||
kotlin {
|
||||
srcDirs += "src/integrationTest/kotlin"
|
||||
}
|
||||
java {
|
||||
srcDirs += "src/integrationTest/java"
|
||||
}
|
||||
resources {
|
||||
srcDirs += "src/integrationTest/resources"
|
||||
}
|
||||
compileClasspath += main.output + test.output
|
||||
runtimeClasspath += main.output + test.output
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
target {
|
||||
java
|
||||
compilations.integrationTest {
|
||||
associateWith compilations.main
|
||||
associateWith compilations.test
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm" version "$kotlin_version"
|
||||
}
|
||||
}
|
||||
+12
-7
@@ -253,18 +253,23 @@ abstract class AbstractKotlinCompilation<T : KotlinCommonOptions>(
|
||||
}
|
||||
|
||||
protected open fun addAssociateCompilationDependencies(other: KotlinCompilation<*>) {
|
||||
target.project.dependencies.run {
|
||||
val project = target.project
|
||||
with(target.project) {
|
||||
|
||||
add(
|
||||
compileDependencyConfigurationName,
|
||||
project.files(Callable { other.output.classesDirs }, Callable { other.compileDependencyFiles })
|
||||
dependencies.add(
|
||||
compileOnlyConfigurationName,
|
||||
project.files(Callable { other.output.classesDirs })
|
||||
)
|
||||
|
||||
configurations.named(compileOnlyConfigurationName).configure {
|
||||
it.extendsFrom(configurations.findByName(other.compileDependencyConfigurationName))
|
||||
}
|
||||
|
||||
if (this@AbstractKotlinCompilation is KotlinCompilationToRunnableFiles<*>) {
|
||||
add(runtimeDependencyConfigurationName, project.files(Callable { other.output.allOutputs }))
|
||||
dependencies.add(runtimeOnlyConfigurationName, project.files(Callable { other.output.allOutputs }))
|
||||
if (other is KotlinCompilationToRunnableFiles<*>) {
|
||||
add(runtimeDependencyConfigurationName, project.files(Callable { other.runtimeDependencyFiles }))
|
||||
configurations.named(runtimeOnlyConfigurationName).configure {
|
||||
it.extendsFrom(configurations.findByName(other.runtimeDependencyConfigurationName))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user