Open hadrienk opened 3 years ago
Have you tried with exclusive false?
wire {
kotlin {
rpcRole = "client"
// True if types emitted for this target should not also be emitted for other
// targets. Use this to cause multiple outputs to be emitted for the same input
// type.
exclusive = false
}
kotlin {
rpcRole = "server"
exclusive = false
}
kotlin {
rpcRole = "server"
rpcCallStyle = "blocking"
}
}
It looks like it tries but fail because the messages are being generated many time:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generateMainProtos'.
> Same type is getting generated by different messages:
Input at [...]/ test.proto:7:1
Input at [...]/ test.proto:7:1
Can I use the excludes property to avoid generating the messages more than once?
You should be able to. Common types should be generated once only indeed.
I haven't had any success using exclusive
or excludes
- I still get the "same file is getting generated by different messages" error.
You should not see that if you're using exclusive = false
. If you can write a small repro config, please share it.
Here is a branch that fails to assemble https://github.com/Breefield/wire-playground/tree/bh/failed-exclusive
wire {
custom {
// Be sure that `server-generator` is on the classpath for Gradle to resolve
// `GrpcServerSchemaHandler`.
schemaHandlerFactory = com.squareup.wire.kotlin.grpcserver.GrpcServerSchemaHandler.Factory()
options = mapOf(
// Defaults to `true` if absent. Any other value than `true` is considered false.
"singleMethodServices" to "false",
// Defaults to `suspending` if absent. Any other value than `suspending` is considered
// non-suspending.
"rpcCallStyle" to "blocking",
)
// We set the custom block exclusivity to false so that the next `kotlin {}` block can also
// generate the protobuf Messages.
exclusive = false
}
sourcePath {
srcDir("src/main/protos")
}
kotlin {
exclusive = false
rpcRole = "client"
}
kotlin {
exclusive = false
rpcCallStyle = "blocking"
rpcRole = "server"
}
}
Gives me:
Same file /Users/bree/Desktop/square-wire/build/generated/source/wire/com/bree/dinosaurs/Dinosaur.kt is getting generated by different messages:
Dinosaur at /Users/bree/Desktop/square-wire/src/main/protos/example/dinosaur.proto:6:1
Dinosaur at /Users/bree/Desktop/square-wire/src/main/protos/example/dinosaur.proto:6:1
This is a bit of a blocker for me because I have a single repo where I define my protobufs, and then we've set up gradle to build various languages/clients/servers and publish them to artifactories/etc so our various repos don't all have to setup their own build pipelines.
You need to configure your generator blocks in order to make it so that only one of them generate Dinosaur.kt
Is there a way to compile the proto files with multiple configurations?
I tried this way but without success: