1
+ /*
2
+ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
3
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4
+ */
5
+
6
+ @file:Suppress(" FunctionName" )
7
+
8
+ package org.jetbrains.kotlin.gradle.regressionTests
9
+
10
+ import org.jetbrains.kotlin.gradle.dependencyResolutionTests.kpm.mavenCentralCacheRedirector
11
+ import org.jetbrains.kotlin.gradle.dsl.kotlinJvmExtension
12
+ import org.jetbrains.kotlin.gradle.plugin.mpp.internal
13
+ import org.jetbrains.kotlin.gradle.util.applyKotlinJvmPlugin
14
+ import org.jetbrains.kotlin.gradle.util.buildProject
15
+ import org.jetbrains.kotlin.gradle.util.main
16
+ import org.jetbrains.kotlin.gradle.util.test
17
+ import kotlin.test.Test
18
+ import kotlin.test.fail
19
+
20
+ class KT58280JvmWithJavaTestCompileClasspath {
21
+ /* *
22
+ * Context:
23
+ * https://youtrack.jetbrains.com/issue/KT-58280/org.jetbrains.kotlin.jvm-Gradle-plugin-contributes-build-directories-to-the-test-compile-classpath
24
+ *
25
+ * This is not necessarily a 'regression' as IntelliJ and CLI compilations work fine.
26
+ * Tools like eclipse did not expect this output.
27
+ *
28
+ * The commit the initially (and accidentally) changed the behavior was:
29
+ * [Gradle] Implement KotlinWithJavaCompilation with underlying KotlinCompilationImpl Sebastian Sellmair* 04.10.22, 17:16
30
+ * af198825899df9943814e2cb54d39868fff399fb
31
+ *
32
+ * This test 'fixates' the old behaviour.
33
+ */
34
+ @Test
35
+ fun `test - KT58280 - jvmWithJava Target does not add main classes to test compile classpath` () {
36
+ val project = buildProject()
37
+ project.plugins.apply (" java-library" )
38
+ project.applyKotlinJvmPlugin()
39
+ project.repositories.mavenLocal()
40
+ project.repositories.mavenCentralCacheRedirector()
41
+ val kotlin = project.kotlinJvmExtension
42
+
43
+ /* This kind of association is not required for java: java plugin handles this separately */
44
+ kotlin.target.compilations.test.internal.configurations.compileDependencyConfiguration.resolvedConfiguration.files.forEach { file ->
45
+ if (file in kotlin.target.compilations.main.output.allOutputs) {
46
+ fail(" Unexpected file in test compile dependencies: $file " )
47
+ }
48
+ }
49
+ }
50
+ }
0 commit comments