-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(manager/gradle): rewrite and extend parser #18484
Conversation
Would be complicated to merge it by small steps, seems like parsing mechanism swapping is all-or-nothing? |
@zharinov, thank you so much for merging the two PRs into https://github.com/zharinov/good-enough-parser 👍 My initial idea was to parse a Gradle file twice in Another approach could be the following:
|
I think, |
…rewrite � Conflicts: � lib/modules/manager/gradle/parser.spec.ts � lib/modules/manager/gradle/parser.ts
…rewrite � Conflicts: � lib/modules/manager/gradle/parser.spec.ts � lib/modules/manager/gradle/parser.ts
…rewrite � Conflicts: � lib/modules/manager/gradle/parser.ts
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.
So will most of this PR be split off into a drop in refactor PR? It would be good if we can avoid any new PRs even if they are correct. That way we don't need to worry about rollbacks causing auto closes |
That was the idea with PR #18663. First, to transition all existing functionality to the new parser and then to have subsequent PRs bringing in new features, link issues they resolve and provide evidence via test repos. In case a PR needs to be reverted that brought in e.g.
Wouldn't this be the same situation if this fully-fledged PR here (or basically any PR that extracts more deps than before) was merged and needed to be rolled back? Test-wise the refactoring PR #18663 shows parity with the existing parser, so even if reverted, no auto close should happen as the current parser finds the very same set of deps. Related to that, I assume that separate PRs would simplify code reviews with smaller changesets and more obvious reasoning why some changes were made. In any case, I'm ready to advance as you prefer. P.S.: There are still 2-3 feature things that are not added yet here ATM (e.g. a solution for #8728) but where I thought subsequent PRs would be good enough. |
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.
so this has a behavior change and possibly closes PR's if some recursive applied files are not inside manager file list 🤔
That's correct. However, from a user perspective, if you already redefine |
…rewrite � Conflicts: � lib/modules/manager/gradle/parser.spec.ts � lib/modules/manager/gradle/parser.ts
Should this now be deconflicted off |
…rewrite � Conflicts: � lib/modules/manager/gradle/parser.spec.ts � lib/modules/manager/gradle/parser.ts � lib/modules/manager/gradle/parser/common.spec.ts � lib/modules/manager/gradle/parser/common.ts � lib/modules/manager/gradle/parser/handlers.ts
@rarkins, my plan would be as follows:
If that's fine for you too, we could close this PR right now. If you'd prefer just one PR (at least for the changes pushed here so far), I'd be fine too and would then simply restructure this PR. I'm working on further augmenting the parser implementation and currently have the following things on the radar (going into separate PRs I'd say):
|
…rewrite � Conflicts: � lib/modules/manager/gradle/parser.spec.ts
Changes
Tl;dr
dependencySet
,mapOf
andproperty("foo")
Where is the catch?
Matching template strings is currently tailored to existing tests but doesn't work with random combinations like"a${b}c${d}e${f}..."
Would require merge of feat: Add query support for string-values and symbols in string-trees zharinov/good-enough-parser#144 (pls @zharinov)Would enable more flexible matching, e.g."io.jsonwebtoken:jjwt-api:${property("jwtVersion")}"
or"io.jsonwebtoken:jjwt-api:${extra["jwtVersion"]}"
Code demonstrating this is already there but commented to give you an idea what to expect(Update: resolved)With the new parser, handler functions can't work async, so
apply from()
can't callawait parseGradle()
fs.getFileContentMap()
to load all Gradle files upfrontfs.readFilesSync()
seems less favorable to me but probably I'm overlooking something here and there is another approach I haven't thought about yet.apply from()
now plays nicely withignorePaths
Next steps
I'd very much appreciate your review of the concept itself, e.g. with regards to strict types
I'd hope for @zharinov to accept feat: Add query support for string-values and symbols in string-trees zharinov/good-enough-parser#144 and publish the lib with this extension(Update: done)fix: support for groovy variables with only one character zharinov/good-enough-parser#179 would be great too as otherwise single character variables like(Update: done)z = "1.2.3"
won't be matchedI've tested it extensively but, of course, it's hard to rule out all corner cases. So instead of a Big Bang merge, I'd suggest to do it piece-wise in co-existence with the existing parser
mapOf
Please don't hesitate to share your thoughts on this plan too. For now, I didn't remove the tokenizer and other things that are obsolete with this re-implementation.
What's new?
Improved support for Groovy's property syntax:
deps.support.design = '...'
and later be referenced asdeps["support"]["design"]
project
androotProject
prefix), e.g.:Support for Kotlin extra properties, e.g.:
Support for Groovy maps up to 3rd-level nesting, e.g.
Resolves:
Support for Kotlin's
mapOf
collections up to 3rd-level nesting, e.g.Support for repository URLs set via setUrl(), e.g.:
maven { setUrl("https://foo.bar/baz") }
Support for alias definitions with Gradle version catalogs, e.g.:
Support for
dependencySet
collections (grouped into a single update), e.g.:Support for implicit Gradle plugins like
pmd
orcheckstyle
, e.g.:Resolves:
${project.extensions.checkstyle.toolVersion}
is not (yet) supportedFurther Fixes
Repo detected in
publishing()
blockShould ignore publishing registries repositories #17067
Gradle variable ordering breaks detected dependencies
Gradle variable ordering breaks detected dependencies #18317
Future Work
Can be adapted (= reusing existing patterns) to match
object { ... }
definitions inbuildSrc/*.kt
files, see#13295, #9410, #12397, #5480
Context
Documentation (please check one with an [x])
How I've tested my work (please tick one)
I have verified these changes via: