Provide suggested versions in all Gradle compatibility error messages#188522
Provide suggested versions in all Gradle compatibility error messages#188522mboetger wants to merge 1 commit into
Conversation
…all Gradle compatibility error messages - Refactored KGP/Gradle and AGP/KGP compatibility checks in gradle_utils.dart into declarative constant lists. - Implemented bidirectional suggestion helper functions to find compatible ranges for Java, Gradle, AGP, and KGP. - Updated project.dart validation to output clear version suggestions for all compatibility violations. - Refactored warning accumulation to prevent descriptions from being overwritten. - Added comprehensive unit and integration tests covering the compatibility suggestions.
There was a problem hiding this comment.
Code Review
This pull request refactors the Kotlin Gradle Plugin (KGP), Gradle, and Android Gradle Plugin (AGP) compatibility validation logic in gradle_utils.dart by replacing hardcoded conditional blocks with structured data classes and lists. It also updates project.dart to provide detailed version range suggestions in error messages when incompatibilities are detected, and introduces new unit tests to verify these suggestions. The reviewer feedback suggests utilizing the existing oldestDocumentedKgpCompatabilityVersion constant instead of hardcoding a version string, and simplifying the test setup by removing unused template and package configuration code.
There was a problem hiding this comment.
To adhere to the repository style guide of avoiding duplicating state, consider using the existing oldestDocumentedKgpCompatabilityVersion constant instead of hardcoding '1.6.20'.
| KgpGradleCompat( | |
| kgpMin: '1.6.20', | |
| kgpMax: '1.7.0', | |
| gradleMin: '6.1.1', | |
| gradleMax: '7.0.2', | |
| inclusiveMaxKgp: false, | |
| ), | |
| KgpGradleCompat( | |
| kgpMin: oldestDocumentedKgpCompatabilityVersion, | |
| kgpMax: '1.7.0', | |
| gradleMin: '6.1.1', | |
| gradleMax: '7.0.2', | |
| inclusiveMaxKgp: false, | |
| ), |
References
- Avoid duplicating state: Keep only one source of truth. (link)
There was a problem hiding this comment.
The compatibility checks being tested do not use or require the Flutter templates or the package config setup for flutter_tools. Removing this block makes the test faster, cleaner, and completely hermetic by avoiding unnecessary host file system reads.
References
- Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)

Fixes: #167931
Pre-launch Checklist
///).