From 90a9bf9dbe09cc66f60d799d29bbb55d27223a96 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Fri, 5 May 2023 15:37:17 +0200 Subject: [PATCH] [Gradle] Implement KT58280JvmWithJavaTestCompileClasspath to cover KT-58280 (cherry picked from commit 3196981799dfb6f328d678cc5bfaaa741af44625) --- .../KT58280JvmWithJavaTestCompileClasspath.kt | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT58280JvmWithJavaTestCompileClasspath.kt diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT58280JvmWithJavaTestCompileClasspath.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT58280JvmWithJavaTestCompileClasspath.kt new file mode 100644 index 0000000000000..4af38326dac7c --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT58280JvmWithJavaTestCompileClasspath.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2023 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. + */ + +@file:Suppress("FunctionName") + +package org.jetbrains.kotlin.gradle.regressionTests + +import org.jetbrains.kotlin.gradle.dependencyResolutionTests.kpm.mavenCentralCacheRedirector +import org.jetbrains.kotlin.gradle.dsl.kotlinJvmExtension +import org.jetbrains.kotlin.gradle.plugin.mpp.internal +import org.jetbrains.kotlin.gradle.util.applyKotlinJvmPlugin +import org.jetbrains.kotlin.gradle.util.buildProject +import org.jetbrains.kotlin.gradle.util.main +import org.jetbrains.kotlin.gradle.util.test +import kotlin.test.Test +import kotlin.test.fail + +class KT58280JvmWithJavaTestCompileClasspath { + /** + * Context: + * https://youtrack.jetbrains.com/issue/KT-58280/org.jetbrains.kotlin.jvm-Gradle-plugin-contributes-build-directories-to-the-test-compile-classpath + * + * This is not necessarily a 'regression' as IntelliJ and CLI compilations work fine. + * Tools like eclipse did not expect this output. + * + * The commit the initially (and accidentally) changed the behavior was: + * [Gradle] Implement KotlinWithJavaCompilation with underlying KotlinCompilationImpl Sebastian Sellmair* 04.10.22, 17:16 + * af198825899df9943814e2cb54d39868fff399fb + * + * This test 'fixates' the old behaviour. + */ + @Test + fun `test - KT58280 - jvmWithJava Target does not add main classes to test compile classpath`() { + val project = buildProject() + project.plugins.apply("java-library") + project.applyKotlinJvmPlugin() + project.repositories.mavenLocal() + project.repositories.mavenCentralCacheRedirector() + val kotlin = project.kotlinJvmExtension + + /* This kind of association is not required for java: java plugin handles this separately */ + kotlin.target.compilations.test.internal.configurations.compileDependencyConfiguration.resolvedConfiguration.files.forEach { file -> + if (file in kotlin.target.compilations.main.output.allOutputs) { + fail("Unexpected file in test compile dependencies: $file") + } + } + } +} \ No newline at end of file