Replace Consumer with HasImplicitReceiver support #262
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.
Gradle usage from Groovy build scripts can use the Closure methods
and get a clean delegation:
From Kotlin build scripts, they fell back to the Consumer variant, but
that required the receiver (roughly equivalent in this context to the
Groovy delegate) to be explicitly referenced:
Using an interface with @HasImplicitReceiver allows for use like the
above Groovy usage.
Gradle provides the Action interface to meet this need, but in order to
preserve some independence from Gradle's API, since grgit is meant to be
generically a Groovy Git binding, we can't have the Action class or the
HasImplicitReceiver annotation on the classpath during compile.
We're doing a workaround at the moment that adds the annotation as part
of an AST transformation.
This change was provided by Alex Saveau.
I don't intend Kotlin usage to be a core supported feature of this
project, so this is just a best effort for now. If it ever requires more
extensive changes or breaks, I will favor removing it to making any
significant changes.