-
Notifications
You must be signed in to change notification settings - Fork 21
[Gradle] Add automatic handling of full qualified imports for conflicting icon names #758
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
Conversation
WalkthroughThe changes detect icon file names that collide with reserved Compose qualified names (Brush, Color, Offset) during image vector generation. GenerateImageVectorsTask collects conflicting full-qualified names, logs them, and passes them into the generation flow. ImageVectorGeneratorConfig is set to use full-qualified imports for those conflicts. A new FullQualifiedNamesTest class adds tests that verify full-qualified imports are applied and that direct imports of the reserved types are not emitted. Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-12-07T20:07:49.744ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (6)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tools/gradle-plugin/src/main/kotlin/io/github/composegears/valkyrie/gradle/internal/task/GenerateImageVectorsTask.kt (1)
166-187: Consider extracting config creation to reduce duplication.The logic for creating
FullQualifiedImportsis duplicated in bothgenerateIconsWithoutPack(lines 182-186) andgenerateIconsWithIconPack(lines 214-218). While the duplication is limited and the code is clear, extracting to a helper method would improve maintainability.Example helper method:
private fun createFullQualifiedImports(fullQualifiedNames: List<String>): FullQualifiedImports { return FullQualifiedImports( brush = "Brush" in fullQualifiedNames, color = "Color" in fullQualifiedNames, offset = "Offset" in fullQualifiedNames, ) }Then use:
fullQualifiedImports = createFullQualifiedImports(fullQualifiedNames)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
tools/gradle-plugin/CHANGELOG.md(1 hunks)tools/gradle-plugin/src/main/kotlin/io/github/composegears/valkyrie/gradle/internal/task/GenerateImageVectorsTask.kt(6 hunks)tools/gradle-plugin/src/test/kotlin/io/github/composegears/valkyrie/gradle/FullQualifiedNamesTest.kt(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: egorikftp
Repo: ComposeGears/Valkyrie PR: 750
File: tools/gradle-plugin/src/main/kotlin/io/github/composegears/valkyrie/gradle/internal/task/GenerateImageVectorsTask.kt:71-85
Timestamp: 2025-12-07T20:07:49.744Z
Learning: In the Valkyrie Gradle plugin (Kotlin), the `useFlatPackage` flag in `IconPackExtension` is only applicable when nested packs are configured. For single icon packs (without nested packs), the flag is intentionally not propagated to `ImageVectorGeneratorConfig` as there is no package hierarchy to flatten.
📚 Learning: 2025-10-21T20:55:27.073Z
Learnt from: egorikftp
Repo: ComposeGears/Valkyrie PR: 651
File: tools/idea-plugin/build.gradle.kts:147-175
Timestamp: 2025-10-21T20:55:27.073Z
Learning: In Gradle Kotlin DSL (.gradle.kts) scripts, the types `org.gradle.api.artifacts.ArtifactCollection` and `org.gradle.api.artifacts.component.ModuleComponentIdentifier` are implicitly available and do not require explicit import statements.
Applied to files:
tools/gradle-plugin/src/test/kotlin/io/github/composegears/valkyrie/gradle/FullQualifiedNamesTest.kt
📚 Learning: 2025-12-07T20:07:49.744Z
Learnt from: egorikftp
Repo: ComposeGears/Valkyrie PR: 750
File: tools/gradle-plugin/src/main/kotlin/io/github/composegears/valkyrie/gradle/internal/task/GenerateImageVectorsTask.kt:71-85
Timestamp: 2025-12-07T20:07:49.744Z
Learning: In the Valkyrie Gradle plugin (Kotlin), the `useFlatPackage` flag in `IconPackExtension` is only applicable when nested packs are configured. For single icon packs (without nested packs), the flag is intentionally not propagated to `ImageVectorGeneratorConfig` as there is no package hierarchy to flatten.
Applied to files:
tools/gradle-plugin/src/test/kotlin/io/github/composegears/valkyrie/gradle/FullQualifiedNamesTest.kttools/gradle-plugin/src/main/kotlin/io/github/composegears/valkyrie/gradle/internal/task/GenerateImageVectorsTask.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build (ubuntu-latest)
🔇 Additional comments (8)
tools/gradle-plugin/CHANGELOG.md (1)
3-9: LGTM! Documentation is clear.The changelog entry accurately describes the new feature and follows the existing format.
tools/gradle-plugin/src/test/kotlin/io/github/composegears/valkyrie/gradle/FullQualifiedNamesTest.kt (3)
20-51: LGTM! Test coverage for Brush icon is solid.The test correctly verifies both the log output and that the generated file omits the direct import statement.
53-84: LGTM! Test coverage for Color icon is solid.Reusing
ic_brush.xmlcontent for different icon names is acceptable here since the tests focus on import behavior rather than icon rendering.
86-117: LGTM! Test coverage for Offset icon is solid.The test suite comprehensively covers all three reserved Compose qualifiers (Brush, Color, Offset).
tools/gradle-plugin/src/main/kotlin/io/github/composegears/valkyrie/gradle/internal/task/GenerateImageVectorsTask.kt (4)
6-7: LGTM! Required imports for the feature.The imports support the conflict detection and configuration logic.
Also applies to: 16-16
104-114: LGTM! Conflict detection logic is correct.The implementation efficiently detects icon names that conflict with reserved Compose qualifiers and provides clear user feedback via logging.
121-129: LGTM! Clean data flow.The fullQualifiedNames are correctly propagated to both icon generation paths.
205-219: LGTM! Config creation is correct.The implementation properly sets
fullQualifiedImportsbased on detected conflicts and includes the icon pack name in the configuration.
0f86553 to
5580fce
Compare
Will be generated following code: