google / google/protobuf-gradle-plugin
Missing extension functions for Kotlin DSL
- Dominant language
- Groovy
- Stars
- 1.8k
- Forks
- 288
- PR merge metrics
- No merged PRs in 30d
Description
Reported by @alexvas in #275:
As of plugin version of 0.8.8 I still need a pair of auxiliary functions:
```kotlin
fun ProtobufConfigurator.plugins(closure: NamedDomainObjectContainerScope.() -> Unit) {
plugins(closureOf> {
closure(NamedDomainObjectContainerScope.of(this))
})
}
fun GenerateProtoTask.plugins(configuration: NamedDomainObjectContainerScope.()-> Unit) {
plugins(closureOf> {
configuration(NamedDomainObjectContainerScope.of(this))
})
}
```
to make
```kotlin
protobuf {
protoc {
// The artifact spec for the Protobuf Compiler
artifact = Libs.protoc
}
plugins {
// Optional: an artifact spec for a protoc plugin, with "grpc" as
// the identifier, which can be referred to in the "plugins"
// container of the "generateProtoTasks" closure.
id("grpc") {
artifact = Libs.protoc_gen_grpc_java
}
}
generateProtoTasks {
ofSourceSet("main").forEach {
it.plugins {
// Apply the "grpc" plugin whose spec is defined above, without
// options. Note the braces cannot be omitted, otherwise the
// plugin will not be added. This is because of the implicit way
// NamedDomainObjectContainer binds the methods.
id("grpc")
}
}
}
}
```
work. Otherwise there is a gradle configuration error:
```
Line 31: id("grpc") {
^ Too many arguments for public open fun id(id: String): PluginDependencySpec defined in org.gradle.kotlin.dsl.PluginDependenciesSpecScope
Line 32: artifact = Libs.protoc_gen_grpc_java
^ Unresolved reference: artifact
2 errors
```
using Gradle 5.2.1
Contributor guide
Assessment
This issue has not been assessed yet.