Skip to content

Commit

Permalink
[Gradle] KotlinCompilationAssociator: Restore 1.8.10 behaviour for Ko…
Browse files Browse the repository at this point in the history
…tlinWithJavaTarget

^KT-58280 Verification Pending

(cherry picked from commit 08f3d56)
  • Loading branch information
sellmair authored and qodana-bot committed Jun 5, 2023
1 parent 90a9bf9 commit 918a74f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,16 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
buildGradle.appendText(
"""
|
|tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile.class).configureEach {
| if (it.name == "compileKotlin") {
| it.destinationDirectory.set(project.layout.buildDirectory.dir("banana"))
| }
|def compileKotlinTask = tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile.class)
|
|compileKotlinTask.configure {
| it.destinationDirectory.set(project.layout.buildDirectory.dir("banana"))
|}
|
|def compileKotlinTaskOutput = compileKotlinTask.flatMap { it.destinationDirectory }
|sourceSets.test.compileClasspath.from(compileKotlinTaskOutput)
|sourceSets.test.runtimeClasspath.from(compileKotlinTaskOutput)
|
""".trimMargin()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl

import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.jvm
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.InternalKotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.isMain
import org.jetbrains.kotlin.gradle.plugin.mpp.isTest
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
Expand Down Expand Up @@ -76,7 +78,11 @@ internal object KotlinNativeCompilationAssociator : KotlinCompilationAssociator
internal object KotlinJvmCompilationAssociator : KotlinCompilationAssociator {
override fun associate(target: KotlinTarget, auxiliary: InternalKotlinCompilation<*>, main: InternalKotlinCompilation<*>) {
/* Main to Test association handled already by java plugin */
if (target is KotlinJvmTarget && target.withJavaEnabled && auxiliary.isTest() && main.isMain()) {
if (
((target is KotlinWithJavaTarget<*, *> && target.platformType == jvm) ||
(target is KotlinJvmTarget && target.withJavaEnabled)) &&
auxiliary.isTest() && main.isMain()
) {
return
} else DefaultKotlinCompilationAssociator.associate(target, auxiliary, main)
}
Expand Down

0 comments on commit 918a74f

Please sign in to comment.