File tree 1 file changed +25
-1
lines changed
gradle-plugin/src/test/kotlin/app/softwork/serviceloader
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ class KspTesting {
28
28
|
29
29
|kotlin.jvmToolchain(8)
30
30
|
31
+ |sourceSets.register("bar")
32
+ |
31
33
""" .trimMargin()
32
34
)
33
35
val projectDir = System .getenv(" projectDir" )
@@ -53,14 +55,31 @@ class KspTesting {
53
55
""" .trimMargin()
54
56
)
55
57
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
+
56
75
val build = GradleRunner .create()
57
76
.withPluginClasspath()
58
77
.apply {
59
78
val pluginFiles = System .getenv(" pluginFiles" )?.split(" :" )?.map { File (it) } ? : emptyList()
60
79
withPluginClasspath(pluginClasspath + pluginFiles)
61
80
}
62
81
.withProjectDir(tmp)
63
- .withArguments(" :assemble" , " --stacktrace" , " --configuration-cache" )
82
+ .withArguments(" :assemble" , " :kspBarKotlin " , " --stacktrace" , " --configuration-cache" )
64
83
.build()
65
84
66
85
assertEquals(TaskOutcome .SUCCESS , build.task(" :assemble" )?.outcome)
@@ -70,6 +89,11 @@ class KspTesting {
70
89
(temp / " build/generated/ksp/main/resources/META-INF/services" ).toFile().listFiles()
71
90
?.map { it.name }?.toSet()
72
91
)
92
+ assertEquals(
93
+ setOf (" Bar" ),
94
+ (temp / " build/generated/ksp/bar/resources/META-INF/services" ).toFile().listFiles()
95
+ ?.map { it.name }?.toSet()
96
+ )
73
97
}
74
98
75
99
@Test
You can’t perform that action at this time.
0 commit comments