Don't consider references to catalogs in buildfiles #6878
Merged
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.
Fixes #6863.
Trully fixing this (as in, actually create correct PRs) was out of scope for the first MVP for Gradle Version Catalogs, and I don't want to continue with the business of parsing Kotlin/Java code in Ruby. The way to go for us is probably to leverage #1164.
So the way I approached this is to just avoid creating an incorrect PR by fixing the underlying bug that caused that.
Explanation of the fix:
We do support some bare version replacements in build files, for example,
What the code used to do was checking whether the version parsed was all "word characters" or not.
If all word characters, then it's considered a property name, a value for the property is looked up, and if a value cannot be found, then the dependency is ignored.
If not all word characters, then it's considered a version number, and the dependency is only ignored if the version number is not valid.
In this case,
libs.versions.<ref>
includes dots, which are not word characters, so it does not match the regexp to be considered a property reference. As a consequence, it's considered a version number, and accepted as a dependency becauselibs.versions.<ref>
is actually a valid maven version number.I could've tweaked the regexp to accept dots for property names, but I think it's a better criteria to check whether to matched value is quoted. If it is, it's a version number, otherwise it's a property.
So I implemented that.