Skip to content

Commit

Permalink
Allow spaces in commandLineArgumentProvider values
Browse files Browse the repository at this point in the history
  • Loading branch information
audkar committed Jun 21, 2023
1 parent bf2ebf0 commit e94c61c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
)
commandLineArgumentProviders.get().forEach {
it.asArguments().forEach { argument ->
if (!argument.matches(Regex("\\S+=\\S+"))) {
throw IllegalArgumentException("KSP apoption does not match \\S+=\\S+: $argument")
if (!argument.matches(Regex("\\S+=.*\\S+.*"))) {
throw IllegalArgumentException("KSP apoption does not match \\S+=.*\\S+.*: $argument")
}
options += InternalSubpluginOption("apoption", argument)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class GradleCompilationTest {
testRule.appModule.buildFileAdditions.add(
"""
ksp {
arg(Provider(project.layout.projectDirectory.dir("schemas").asFile))
arg(Provider(project.layout.projectDirectory.dir("room schemas").asFile))
}
class Provider(roomOutputDir: File) : CommandLineArgumentProvider {
Expand All @@ -200,10 +200,10 @@ class GradleCompilationTest {
)
val result = testRule.runner().withArguments(":app:assembleDebug").build()
val pattern1 = Regex.escape("apoption=room.schemaLocation=")
val pattern2 = Regex.escape("${testRule.appModule.moduleRoot}/schemas")
val pattern2 = Regex.escape("${testRule.appModule.moduleRoot}/room schemas")
assertThat(result.output).containsMatch("$pattern1\\S*$pattern2")
assertThat(result.output).contains("apoption=room.generateKotlin=true")
val schemasFolder = testRule.appModule.moduleRoot.resolve("schemas")
val schemasFolder = testRule.appModule.moduleRoot.resolve("room schemas")
assertThat(result.task(":app:kspDebugKotlin")!!.outcome).isEquivalentAccordingToCompareTo(TaskOutcome.SUCCESS)
assertThat(schemasFolder.exists()).isTrue()
assertThat(schemasFolder.resolve("Database/1.json").exists()).isTrue()
Expand Down Expand Up @@ -234,7 +234,7 @@ class GradleCompilationTest {
)

val result = testRule.runner().withArguments(":app:assemble").buildAndFail()
assertThat(result.output).contains("KSP apoption does not match \\S+=\\S+: invalid")
assertThat(result.output).contains("KSP apoption does not match \\S+=.*\\S+.*: invalid")
}

@Test
Expand Down

0 comments on commit e94c61c

Please sign in to comment.