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

Gradle Kotlin DSL changed method signature of NamedDomainObjectContainerExtensionsKt.invoke #444

Closed
andrewparmet opened this issue Nov 3, 2020 · 5 comments

Comments

@andrewparmet
Copy link

In KtDslCompatibilityUtils.java the plugin calls NamedDomainObjectContainerExtensionsKt.invoke(container, block) with block being a Function1<? super NamedDomainObjectContainerScope<T>, Unit>. In the latest Gradle build (6.8-milestone-2), that signature has been changed to Action<NamedDomainObjectContainerScope<T>>: gradle/gradle@593001e, so builds using the Kotlin DSL fail using new builds.

@Shakezulla57
Copy link

Is there a work around for this?

@hua0512
Copy link

hua0512 commented Dec 20, 2020

A workaround is to rewrite the KtDslCompatibilityUtils.configureNamedDomainObjectContainer and therefore functions that depends on it.
Then your have:

configureNamedDomainObjectContainer:

fun <T : Any> configureNamedDomainObjectContainer( container: NamedDomainObjectContainer<T>, action: Action<NamedDomainObjectContainerScope<T>> ): NamedDomainObjectContainer<T> { return container.invoke(action) }

id:

fun <T : Any> NamedDomainObjectContainerScope<T>.id(id: String, action: (Action<T>)? = null) { action?.let { create(id, action) } ?: create(id) }

plugins:

fun ProtobufConfigurator.plugins(action: NamedDomainObjectContainerScope<ExecutableLocator>.() -> Unit) { plugins(closureOf<NamedDomainObjectContainer<ExecutableLocator>> { configureNamedDomainObjectContainer<ExecutableLocator>(this, action) }) }

task builtins:

fun GenerateProtoTask.builtins(action: NamedDomainObjectContainerScope<GenerateProtoTask.PluginOptions>.() -> Unit) { builtins(closureOf<NamedDomainObjectContainer<GenerateProtoTask.PluginOptions>> { configureNamedDomainObjectContainer<GenerateProtoTask.PluginOptions>(this, action) }) }

task plugins:

fun GenerateProtoTask.plugins(action: NamedDomainObjectContainerScope<GenerateProtoTask.PluginOptions>.() -> Unit) { plugins(closureOf<NamedDomainObjectContainer<GenerateProtoTask.PluginOptions>> { configureNamedDomainObjectContainer<GenerateProtoTask.PluginOptions>(this, action) }) }

Actually you just have to change configureNamedDomainObjectContainer and id if you are able to build your local protobuf gradle plugin.

@ejona86
Copy link
Collaborator

ejona86 commented Mar 29, 2021

CC @EdGue42 for grpc/grpc-java#8027

@voidzcy
Copy link
Collaborator

voidzcy commented Apr 22, 2021

Gradle has reverted the API deletion at gradle/gradle#15508. Try upgrading Gradle to 6.8 RC3 or later if you are experiencing this issue.

We will still try to migrate to Action-based API, but currently we are not able to find newer releases of org.gradle:gradle-kotlin-dsl containing the new API. Filed gradle/gradle#16884 to see if anyone from Gradle can give a pointer.

@iNikem
Copy link

iNikem commented Dec 6, 2021

Seems to be solved by #531

@ejona86 ejona86 closed this as completed Dec 6, 2021
@ejona86 ejona86 removed this from the Next milestone May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants