/
EmbeddedKotlinProviderTest.kt
99 lines (73 loc) · 3.14 KB
/
EmbeddedKotlinProviderTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package org.gradle.kotlin.dsl.support
import org.gradle.kotlin.dsl.embeddedKotlinVersion
import org.gradle.kotlin.dsl.fixtures.AbstractKotlinIntegrationTest
import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Test
class EmbeddedKotlinProviderTest : AbstractKotlinIntegrationTest() {
@Test
fun `no extra dependencies are added to the buildscript classpath`() {
val result = build("buildEnvironment")
assertThat(result.output, containsString("No dependencies"))
}
@Test
fun `buildscript dependencies to embedded kotlin are resolved without an extra repository`() {
withBuildScript("""
buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-stdlib:$embeddedKotlinVersion")
classpath("org.jetbrains.kotlin:kotlin-reflect:$embeddedKotlinVersion")
classpath("org.jetbrains.kotlin:kotlin-compiler-embeddable:$embeddedKotlinVersion")
classpath("org.jetbrains.kotlin:kotlin-script-runtime:$embeddedKotlinVersion")
classpath("org.jetbrains.kotlin:kotlin-sam-with-receiver-compiler-plugin:$embeddedKotlinVersion")
}
}
""")
val result = build("buildEnvironment")
listOf("stdlib", "reflect", "compiler-embeddable", "script-runtime", "sam-with-receiver-compiler-plugin").forEach { module ->
assertThat(result.output, containsString("org.jetbrains.kotlin:kotlin-$module:$embeddedKotlinVersion"))
}
}
@Test
fun `stdlib and reflect are pinned to the embedded kotlin version`() {
withBuildScript("""
buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-stdlib:1.0")
classpath("org.jetbrains.kotlin:kotlin-reflect:1.0")
}
}
""")
val result = build("buildEnvironment")
listOf("stdlib", "reflect").forEach { module ->
assertThat(result.output, containsString("org.jetbrains.kotlin:kotlin-$module:1.0 -> $embeddedKotlinVersion"))
}
}
@Test
fun `compiler-embeddable is not pinned`() {
withBuildScript("""
buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0")
}
}
""")
val result = buildAndFail("buildEnvironment")
assertThat(result.error, containsString("Could not find org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0"))
}
@Test
fun `embedded kotlin is compatible with locking because it properly reflects the dependency tree`() {
withBuildScript("""
${scriptWithKotlinDslPlugin()}
dependencyLocking {
lockAllConfigurations()
}
""")
withFile("src/main/kotlin/test/Test.kt", """
package test
val test = true
""")
build("dependencies", "--configuration", "compileClasspath", "--write-locks")
build("compileKotlin")
}
}