Skip to content
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 with HasImplicitReceiver support #262

Merged
merged 1 commit into from Oct 6, 2018
Merged

Conversation

ajoberstar
Copy link
Owner

Gradle usage from Groovy build scripts can use the Closure methods
and get a clean delegation:

Grgit.open { currentDir = 'somewhere' }

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:

Grgit.open { it.currentDir = 'somewhere' }

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.

While Gradle usage from Groovy build scripts can use the Closure methods
and get a clean delgation:

  Grgit.open { currentDir = 'somewhere' }

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:

  Grgit.open { it.currentDir = 'somewhere' }

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.
@ajoberstar ajoberstar merged commit 7d3438b into master Oct 6, 2018
@ajoberstar ajoberstar deleted the kotlin branch October 6, 2018 01:30
@ajoberstar
Copy link
Owner Author

3.0.0-rc.2 is out. I may get the final out tonight too, but want to test it in another plugin first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants