Skip to content

Commit 711c317

Browse files
authored
Add a test for multiple source sets (#121)
1 parent c975bd3 commit 711c317

File tree

1 file changed

+25
-1
lines changed
  • gradle-plugin/src/test/kotlin/app/softwork/serviceloader

1 file changed

+25
-1
lines changed

Diff for: gradle-plugin/src/test/kotlin/app/softwork/serviceloader/KspTesting.kt

+25-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class KspTesting {
2828
|
2929
|kotlin.jvmToolchain(8)
3030
|
31+
|sourceSets.register("bar")
32+
|
3133
""".trimMargin()
3234
)
3335
val projectDir = System.getenv("projectDir")
@@ -53,14 +55,31 @@ class KspTesting {
5355
""".trimMargin()
5456
)
5557

58+
val bar = File(tmp, "src/bar/kotlin").apply {
59+
mkdirs()
60+
}
61+
File(bar, "Bar.kt").apply {
62+
createNewFile()
63+
}.writeText(
64+
//language=kotlin
65+
"""
66+
|import app.softwork.serviceloader.ServiceLoader
67+
|
68+
|interface Bar
69+
|
70+
|@ServiceLoader(Bar::class)
71+
|class BarImpl : Bar
72+
""".trimMargin()
73+
)
74+
5675
val build = GradleRunner.create()
5776
.withPluginClasspath()
5877
.apply {
5978
val pluginFiles = System.getenv("pluginFiles")?.split(":")?.map { File(it) } ?: emptyList()
6079
withPluginClasspath(pluginClasspath + pluginFiles)
6180
}
6281
.withProjectDir(tmp)
63-
.withArguments(":assemble", "--stacktrace", "--configuration-cache")
82+
.withArguments(":assemble", ":kspBarKotlin", "--stacktrace", "--configuration-cache")
6483
.build()
6584

6685
assertEquals(TaskOutcome.SUCCESS, build.task(":assemble")?.outcome)
@@ -70,6 +89,11 @@ class KspTesting {
7089
(temp / "build/generated/ksp/main/resources/META-INF/services").toFile().listFiles()
7190
?.map { it.name }?.toSet()
7291
)
92+
assertEquals(
93+
setOf("Bar"),
94+
(temp / "build/generated/ksp/bar/resources/META-INF/services").toFile().listFiles()
95+
?.map { it.name }?.toSet()
96+
)
7397
}
7498

7599
@Test

0 commit comments

Comments
 (0)