Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose API checks as a CLI #1061

Merged
merged 3 commits into from
Jun 27, 2023
Merged

Expose API checks as a CLI #1061

merged 3 commits into from
Jun 27, 2023

Conversation

swankjesse
Copy link
Contributor

Don't depend on the zipline-api-validator code in the Gradle runtime; instead fork a process and call this CLI.

Also migrate from Picocli to Clikt.

@@ -325,7 +325,7 @@ class ZiplinePluginTest {
val result = createRunner(projectDir, "clean", taskName).buildAndFail()
assertThat(result.output).contains(
"""
|Zipline API file is incomplete. Run :ziplineApiDump to update it.
|Zipline API file is incomplete. Run zipline-api-dump to update it.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I feel about this. The CLI’s instructions recommend the CLI command to re-run, but this could be confusing for Gradle users since it wants :ziplineApiDump and not zipline-api-dump.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pass in the command to report in failure messages so that I can vary it between raw CLI usage and Gradle usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Good idea.

}

@TaskAction
fun task() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much of this plumbing stolen from Redwood


private val classpath by option("--class-path")
.convert { it.split(File.pathSeparator).map(::File) }
.required()
Copy link
Contributor Author

@swankjesse swankjesse Jun 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Clikt API is so so nice I love it. Thank you, @ajalt!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the kind words!

If you didn't know about the built-in split, you could use it to make this even a little simpler:

val classpath: List<File> by option("--class-path")
    .file().split(File.pathSeparator).required()

Base automatically changed from jwilson.0626.separate_module to trunk June 26, 2023 22:37
Don't depend on the zipline-api-validator code in the Gradle runtime;
instead fork a process and call this CLI.

Also migrate from Picocli to Clikt.
@swankjesse swankjesse enabled auto-merge (squash) June 27, 2023 00:10
@swankjesse swankjesse merged commit 1e9f043 into trunk Jun 27, 2023
6 checks passed
@swankjesse swankjesse deleted the jwilson.0626.cli branch June 27, 2023 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants