Hi Team, There are some way to use the protofile ...
# protobufs
v
Hi Team, There are some way to use the protofile that is in another repository on
pact:proto
? For example, on my application
<http://github.com/x|github.com/x>
, I set a path to
<http://github.com/y/protos|github.com/y/protos>
?
r
If you are asking if it can fetch a proto file from a remote repo, the answer it no. You will need to fetch it before so it is local
1
a
that's not entirely true. I am able to fetch it from a remote repo, with the gradle dependency on that other repo, the plugin creates "$currentWorkingDir/build/extracted-include-protos" so I can use them from my custom gradle task which I've called contractTest like this:
Copy code
@Pact(consumer = "consumerService")
    fun createPact(builder: PactBuilder): V4Pact {
        val messageFile = loadFileFromJarResource("/events/messages/alert_event.proto")
        val currentWorkingDir = System.getProperty("user.dir")
        val absolutePath = "$currentWorkingDir/build/extracted-include-protos/contractTest"
        return builder
            .usingPlugin("protobuf")
            .expectsToReceive("an AlertEvent", "core/interaction/message")
            .with(
                mapOf(
                    "message.contents" to mapOf(
                        "pact:proto" to messageFile.path,
                        "pact:message-type" to "AlertEvent",
                        "pact:content-type" to "application/protobuf",
                        "pact:protobuf-config" to mapOf("additionalIncludes" to listOf(absolutePath)),