j-roskopf / ComposeGuard

A Gradle plugin for detecting regressions in Jetpack Compose / Compose Multiplatform
MIT License
89 stars 2 forks source link

Running Generate task on a project without any kotlin files in main does not generate anything #34

Closed matejdro closed 1 day ago

matejdro commented 4 days ago

In our project we have a module that is test-only (it only contains unit tests, including Composables, but not any main code). Since tests contain compose, this plugin is blanked-applied among other compose-related configuration.

But it appears that the ComposeCompilerGenerate will not generate anything when main source set is empty - presumably it should generate empty txt files and json stats file with all zeros?

j-roskopf commented 4 days ago

I don't think this is something I have a ton of control over unfortunately. I believe that behavior would be within the compose / kotlin compiler and how it generates metrics. I think you'd see the same behavior by just generating the compose compiler metrics for that module following the standard instructions - https://github.com/JetBrains/kotlin/blob/master/plugins/compose/design/compiler-metrics.md#enabling-metrics - please let me know if that is not the case though!

This tool could theoretically do what you suggest though, and generate empty / zero'd files on top of that, if it detected no files were generated as a result. Is there a use case you had in mind for why that would be valuable?

matejdro commented 1 day ago

I admit that this was a bit of an XXYY problem.

The real problem here is that running Verify task on such a project will cause a task to crash because the files inside do not exist.

j-roskopf commented 1 day ago

That crashing behavior is specifically done by me in the tool when running the verify task. If no golden metrics exist, I throw an exception. I can see how that would be problematic though in a module like you mention with no main source set. I can look into giving a warning but still letting the task complete successfully

j-roskopf commented 1 day ago

I took a stab at ignoring empty main modules for check / generate tasks - https://github.com/j-roskopf/ComposeGuard/pull/39

the behavior of failing check task with a valid main source set is still preserved

will play around with it a bit more before merging

matejdro commented 16 hours ago

Thank you!

j-roskopf commented 10 hours ago

no problem at all! pushed out 2.2.1 to maven central with the fix