Valkyrie icon indicating copy to clipboard operation
Valkyrie copied to clipboard

Add Gradle Plugin

Open jonapoul opened this issue 6 months ago โ€ข 5 comments

As mentioned in https://github.com/ComposeGears/Valkyrie/issues/28, there hasn't yet been a gradle plugin to add to this project. Main use case for me is to help automate the generation logic.

Here's my initial stab at it - it's maybe not 100% fully featured but I thought I'd put it out there and see what people think. There are a few test cases to show basic usage too.

One thing to be aware of: it depends on the various components modules. So if/when you publish the gradle plugin, you'll either need to:

  • also publish the components modules, or
  • figure out some kind of fat-JAR logic to bundle them all together when publishing.

The second one will be a fair bit more complicated than the one you've already done in the CLI app, but it might be possible. Publishing them all is probably best though.

  • Closes #28.

jonapoul avatar May 25 '25 19:05 jonapoul

[!WARNING] There is an error in the Gemini Code Assist config file for this repository at .gemini/config.yaml and the configuration cannot be used until the file is fixed.

gemini-code-assist[bot] avatar May 26 '25 07:05 gemini-code-assist[bot]

[!WARNING] There is an error in the Gemini Code Assist config file for this repository at .gemini/config.yaml and the configuration cannot be used until the file is fixed.

gemini-code-assist[bot] avatar May 26 '25 08:05 gemini-code-assist[bot]

[!WARNING] There is an error in the Gemini Code Assist config file for this repository at .gemini/config.yaml and the configuration cannot be used until the file is fixed.

gemini-code-assist[bot] avatar May 26 '25 08:05 gemini-code-assist[bot]

[!WARNING] There is an error in the Gemini Code Assist config file for this repository at .gemini/config.yaml and the configuration cannot be used until the file is fixed.

gemini-code-assist[bot] avatar May 26 '25 09:05 gemini-code-assist[bot]

I'll review the rest carefully later.

Goooler avatar May 26 '25 10:05 Goooler

@jonapoul hello, thank you for contribution โค๏ธ Will you able to complete PR?

egorikftp avatar Jun 26 '25 15:06 egorikftp

@egorikftp I'll be honest - it completely slipped my mind! Will take another look over the next few days

jonapoul avatar Jun 26 '25 15:06 jonapoul

Reworked a big chunk of the PR (finally!) - should be good for re-review now

jonapoul avatar Jun 28 '25 09:06 jonapoul

@Goooler could you please take a look? ๐Ÿ™‚

egorikftp avatar Jun 28 '25 10:06 egorikftp

@egorikftp I can't reply to the comment directly but the compose dependency is only there to verify that the project compiles once the codegen has been run. It's not being auto-added to any project outside of unit tests

jonapoul avatar Jul 11 '25 08:07 jonapoul

@jonapoul Hello, sorry for ping again ๐Ÿ™‚ Could you please resolve conflicts, I would like to merge changes and prepare first release) Thanks for your time! โค๏ธ

egorikftp avatar Oct 20 '25 07:10 egorikftp

@egorikftp Squashed/rebased and got the tests running (locally at least), but no functional changes since I last looked at it. Do you still want the compose UI dependency removed? That'll get rid of a good chunk of the unit tests for the plugin.

jonapoul avatar Oct 20 '25 19:10 jonapoul

@jonapoul Thank you! โค๏ธ Please keep the dependency for now, I will check it after merging.

egorikftp avatar Oct 20 '25 20:10 egorikftp

[!NOTE]

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a new Gradle plugin module (tools/gradle-plugin) including ValkyrieGradlePlugin, ValkyrieExtension, GenerateImageVectorsTask, and utility wiring for per-source-set task registration. Introduces plugin build configuration, tests (Gradle TestKit integration), and test utilities. Registers the plugin in settings.gradle.kts and includes it in kover test coverage. Updates gradle/libs.versions.toml (AGP and compose-ui). Changes PathUtils writeToKt/writeToFile to return java.nio.file.Path. Minor README bullet split.

Estimated code review effort

๐ŸŽฏ 5 (Critical) | โฑ๏ธ ~120 minutes

Points requiring extra attention:

  • API change: PathUtils.writeToKt / writeToFile return type changed to java.nio.file.Path โ€” verify callers and binary compatibility.
  • New public Gradle API surface: GenerateImageVectorsTask and ValkyrieExtension โ€” validate property types, defaults, and task caching/inputs/outputs.
  • Plugin wiring in ValkyrieGradlePlugin and Utils.registerTask โ€” ensure sourceSet handling, Android/AGP detection, and task dependencies are correct.
  • Extensive Gradle TestKit tests and test utilities โ€” confirm environment guards and test reliability.
  • build.gradle.kts plugin test config including androidHome() resolution and plugin classpath handling.
  • gradle/libs.versions.toml additions (AGP) โ€” check version alignment and compatibility.

Possibly related PRs

  • ComposeGears/Valkyrie#634 โ€” Modifies the same PathUtilsKt writeToKt API (related return-type/signature changes).

Suggested labels

feature-plugin

Suggested reviewers

  • egorikftp

Pre-merge checks and finishing touches

โŒ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage โš ๏ธ Warning Docstring coverage is 3.57% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
โœ… Passed checks (4 passed)
Check name Status Explanation
Title Check โœ… Passed The title "Add Gradle Plugin" directly reflects the primary objective of this changeset. The PR introduces a new Gradle plugin module (tools/gradle-plugin/) with comprehensive implementation including ValkyrieGradlePlugin, GenerateImageVectorsTask, ValkyrieExtension interface, and test coverage. The title is concise, clear, and accurately summarizes the main contribution without being overly broad or vague.
Linked Issues Check โœ… Passed The PR fulfills the coding requirements from issue #28. It adds a Gradle plugin project under tools/gradle-plugin/ with a structured layout similar to detekt, including API definitions (gradle-plugin.api), implementation files (ValkyrieGradlePlugin, GenerateImageVectorsTask, ValkyrieExtension), and comprehensive tests (ValkyrieGradlePluginTest). The plugin is properly integrated into the build system via settings.gradle.kts using include("tools:gradle-plugin"). The implementation provides the core functionality to automate generation logic as intended by issue #28.
Out of Scope Changes Check โœ… Passed
Description Check โœ… Passed The pull request description is directly related to the changeset. It explains the purpose of adding a Gradle plugin to automate generation logic, references the issue being closed (#28), acknowledges the implementation includes test cases, and discusses important considerations regarding dependencies and publishing options. The description provides meaningful context about the change without being vague or off-topic.
โœจ Finishing touches
  • [ ] ๐Ÿ“ Generate docstrings
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 20 '25 20:10 coderabbitai[bot]

@Goooler is it finalized from your side? ๐Ÿ™‚

egorikftp avatar Oct 26 '25 11:10 egorikftp

@jonapoul thanks so much for your contribution on the project! โค๏ธ

egorikftp avatar Oct 29 '25 06:10 egorikftp

We got there in the end!

jonapoul avatar Oct 29 '25 06:10 jonapoul