Add module rules baseline plugin - #340
Merged
Merged
Conversation
Record module structure rule violations (hilt, impl, layer) in module-rules.txt with the moop.module.rules root plugin: moduleRulesBaseline writes the file and moduleRules fails when it is out of date. Run moduleRules in CI and check.sh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Upxj1FvQeDpycupKdPQHUZ
Apply moop.module.rules at the end of the root plugins block without a comment, and drop mustRunAfter and the missing-baseline fallback that nothing uses. Follow Gradle's task authoring guidance: declare cacheability (@UntrackedTask, @DisableCachingByDefault) and input normalization so strict validatePlugins passes, set update and baselineFile through lazy properties instead of Task.project, and describe the tasks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Upxj1FvQeDpycupKdPQHUZ
The per-module task writes the module's rule violations, not module info, so name the task, its class and its output after that. Also move declaredDependencies into ModuleRulesPlugin, its only user. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Upxj1FvQeDpycupKdPQHUZ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of fornewid/baseline-sample#4, trimmed to what Moop uses.
moop.module.rules, applied to the root project, records module structure rule violations inmodule-rules.txt, one sorted line each:hilt: <module>: Hilt applied outside:appand:implmodules.impl: <module> -> <impl module>: a module other than:appdepends on an:implmodule.layer: <module> -> <module>: a lower layer depends on a higher one (core < data < feature < app; modules outside the layers, such as:testing, are ignored)../gradlew moduleRulesBaselinewrites the file, and./gradlew moduleRulesfails with+/-lines and a re-baseline hint when it is out of date.moduleRulesruns in CI andcheck.sh, andCHECK.mdlists both commands.Each module gets a
moduleRulesViolationstask that writes its own violations. The root tasks depend on these tasks by path, so every module is configured even withorg.gradle.configureondemand=true.Current baseline:
Left out compared to baseline-sample#4:
moduleRules { }extension (baseline file and layer order are fixed; the file ismodule-rules.txtinstead ofmodule-rules-baseline.txt)ModuleInfotext format (each module writes its own violation lines instead)Baselinehelper and#comments in the baselinechecklifecycle hook (the root project has nochecktask)com.android.application,-implsuffixes and the second Hilt plugin id (Moop has:app,:implmodules and one Hilt id)Verification
./gradlew -p build-logic :module-rules:test: 4 unit tests pass (CI doesn't run build-logic tests)../gradlew -p build-logic :module-rules:validatePluginspasses with stricter validation enabled (cacheability and input normalization declared)../gradlew moduleRulesBaselinewrites the same 4 lines as the unmodified port of baseline-sample#4, whose 45 tests passed in Moop../gradlew moduleRulespasses and reuses the configuration cache on the second run../gradlew :moduleRules(root only, configure-on-demand, no configuration cache) recomputes all 36 module outputs after they were deleted.hilt: :testingfrommodule-rules.txtfails with+ hilt: :testingand the re-baseline hint.π€ Generated with Claude Code
https://claude.ai/code/session_01Upxj1FvQeDpycupKdPQHUZ