Skip to content

Commit

Permalink
Add the ziplineApiCheck task as a 'check'
Browse files Browse the repository at this point in the history
This will break downstream users. They'll be able to fix by
running ziplineApiDump and checking in the produced file.
  • Loading branch information
squarejesse committed Jun 22, 2023
1 parent 062de52 commit 0f30dfb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ abstract class ZiplineApiValidationTask @Inject constructor(
@get:Classpath
internal val classpath = fileCollectionFactory.configurableFiles("classpath")

init {
when (mode) {
Mode.Check -> {
group = "verification"
description = "Confirm that the current Zipline API matches the expectations file"
}
Mode.Dump -> {
description = "Write the current Zipline APIs to the expectations file"
}
}
}

@TaskAction
fun task() {
val tomlFile = ziplineApiFile.get().asFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class ZiplinePlugin : KotlinCompilerPluginSupportPlugin {

private fun registerZiplineApiTask(
project: Project,
kotlinCompileTool: KotlinCompileTool,
compileTask: KotlinCompileTool,
mode: ZiplineApiValidationTask.Mode,
) {
val task = project.tasks.register(
Expand All @@ -125,10 +125,16 @@ class ZiplinePlugin : KotlinCompilerPluginSupportPlugin {
mode,
)

task.configure {
it.ziplineApiFile.set(project.file("api/zipline-api.toml"))
it.sourcepath.setFrom(kotlinCompileTool.sources)
it.classpath.setFrom(kotlinCompileTool.libraries)
if (mode == ZiplineApiValidationTask.Mode.Check) {
project.tasks.named("check").configure { checkTask ->
checkTask.dependsOn(task)
}
}

task.configure { task ->
task.ziplineApiFile.set(project.file("api/zipline-api.toml"))
task.sourcepath.setFrom(compileTask.sources)
task.classpath.setFrom(compileTask.libraries)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ class ZiplinePluginTest {
ziplineApiTaskFailsOnDroppedApi(":lib:ziplineApiDump")
}

@Test
fun checkTaskIncludesZiplineApiCheck() {
ziplineApiTaskFailsOnDroppedApi(":lib:check")
}

private fun ziplineApiTaskFailsOnDroppedApi(taskName: String) {
val projectDir = File("src/test/projects/basic")
val ziplineApiToml = projectDir.resolve("lib/api/zipline-api.toml")
Expand Down

0 comments on commit 0f30dfb

Please sign in to comment.