1
+ /*
2
+ * Copyright 2010-2024 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
+ package org.jetbrains.kotlin.gradle.regressionTests
7
+
8
+ import org.gradle.api.internal.provider.MissingValueException
9
+ import org.jetbrains.kotlin.gradle.plugin.mpp.resources.KotlinTargetResourcesPublication
10
+ import org.jetbrains.kotlin.gradle.plugin.mpp.resources.resourcesPublicationExtension
11
+ import org.jetbrains.kotlin.gradle.util.buildProjectWithMPP
12
+ import org.jetbrains.kotlin.gradle.util.kotlin
13
+ import java.io.File
14
+ import kotlin.test.Test
15
+ import kotlin.test.assertFailsWith
16
+ import kotlin.test.assertNotNull
17
+
18
+ class KT67636JvmWithJavaSetSrcDirsTest {
19
+
20
+ @Test
21
+ fun `resources publication - for jvm withJava target - doesn't fail project evaluation` () {
22
+ assertFailsWith(MissingValueException ::class ) {
23
+ buildProjectWithMPP {
24
+ kotlin {
25
+ assertNotNull(resourcesPublicationExtension).publishResourcesAsKotlinComponent(
26
+ target = jvm(),
27
+ resourcePathForSourceSet = { _ ->
28
+ KotlinTargetResourcesPublication .ResourceRoot (
29
+ layout.buildDirectory.dir(" foo" ).map { it.asFile },
30
+ emptyList(),
31
+ emptyList(),
32
+ )
33
+ },
34
+ relativeResourcePlacement = layout.buildDirectory.dir(" bar" ).map { it.asFile },
35
+ )
36
+
37
+ jvm {
38
+ withJava()
39
+ }
40
+ }
41
+ }.evaluate()
42
+ }
43
+ }
44
+
45
+ // FIXME: withJava forces providers in resources to be eagerly evaluated. See KT-67636
46
+ @Test
47
+ fun `jvm withJava target - provider in compilation's resources - fails project evaluation` () {
48
+ assertFailsWith(MissingValueException ::class ) {
49
+ buildProjectWithMPP {
50
+ kotlin {
51
+ val prop = objects.property(File ::class .java)
52
+
53
+ jvm {
54
+ compilations.getByName(" main" ).defaultSourceSet.resources.srcDir(prop)
55
+ withJava()
56
+ }
57
+
58
+ prop.set(File (" test" ))
59
+ }
60
+ }.evaluate()
61
+ }
62
+ }
63
+
64
+ }
0 commit comments