-
Notifications
You must be signed in to change notification settings - Fork 93
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
Replace consumer methods with Gradle Action #253
Conversation
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
Thanks for the interest in the library! While Gradle builds are the biggest consumer (probably) of grgit, it is not meant to be "Gradle-centric". I want to ensure that grgit-core is still usable outside of Gradle to allow for other use cases. Not being very familiar with Kotlin myself, are there other options to provide the syntax improvement without adding a hard Gradle dependency to core? |
Not unless you want to add a dependency to Kotlin and write a compiler extension. 😉 What if we added back the consumer overloads, but suffixed with |
Sorry for the delay... I'm not sure about the splitting option, but that might be worth looking into. If we can put this Action specific transform in the gradle module, maybe that would work out. |
@ajoberstar Holy crap, I think I actually figured it out! 😁 This PR is about to get way bigger so I apologize in advance. |
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@ajoberstar So here's the gist of it:
|
@SUPERCILEX Thanks for all of the work you put into this! However, I think I may have misread your previous comment (emphasis mine).
I was hoping there would be some way to introduce something to the Gradle module that provides the necessary extensions there without having to necessitate significant change to the existing core module. With the updated PR, I'm concerned the structure with base, java, and gradle modules will add a larger amount of overhead to future changes than I'm comfortable with taking on. As a library targeted at providing Groovy bindings to JGit (often in the context of Gradle), Gradle's Kotlin support has me unsure of if/how to change to accommodate. If we generate Action bindings (in addition to Consumer ones) do calls fail due to ambiguity of the two interfaces? |
OMG, your comment sparked an idea and it worked. I feel really stupid now 🤦♂️. I guess I learned a lot. 😁 Anyway, TL;DR is that this PR will only be a few lines of code in the end. 👍 |
…licitReceiver Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@ajoberstar I'm running into a weird error with failing tests whenever I added the
I've added a hack in the meantime. |
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@ajoberstar I correctly fixed the test errors ( |
Apologies for the delayed response. That error message is a Groovy 2.5 incompatibility (which is the reason I had to split the code into two modules). With the I do like the idea to introduce a new interface that can have that However, I want to retain the Groovy 2.5 support, so we'll need to find another way to have both One other note... There are a lot of extraneous changes in the PR right now (some formatting changes and code cleanup). There's nothing wrong with those on their own, but since they're unrelated to the code that needs changing, I'd like them removed from the PR.. |
@ajoberstar Cool, makes sense. 👍 For the extraneous changes, I've moved them to #257. I'll look into the Groovy 2.5 issues. |
…cumvent compile-time safety Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
@ajoberstar Ok, I got it working by injecting the annotation in an AST transformation. 😁 Will remove the extraneous changes once #257 goes through. |
Sorry for the delay. This new approach seems pretty promising. Could you cut this down to a single commit with just the OpSyntax change, new Configurable annotation, and related AST? I'd like to include it for the 3.0 release I hope to cut soon. |
@ajoberstar Awesome! Could you merge |
For now, all I'd like to pull in is the change in the AST generated method. I've made a new PR #262, which takes just those changes without the cleanup. I appreciate all the work you did on this, so I made sure to mark you as the author of the commit. I'll be closing this PR in favor of the new one. Thanks again! |
@ajoberstar Wow, thanks for doing all that work and keeping me as the author! ❤️ |
Motivation
The
Action
interface is universal across Gradle API (Consumer
is not) and this library is supposed to be Gradle centric. This matters becauseAction
s are annotated with@HasImplicitReceiver
, thus improving syntax for languages like Kotlin.Old:
New: