square / wire

gRPC and protocol buffers for Android, Kotlin, Swift and Java.
https://square.github.io/wire/
Apache License 2.0
4.23k stars 572 forks source link

`srcDir` should accept `TaskProvider` #2933

Closed JakeWharton closed 1 month ago

JakeWharton commented 3 months ago

If someone is sourcing protos from an external source, you currently have to wire (heh) directories like this:

schemas {
  get {
    saveTo("./src/main/proto")
    file("squareup/cash/whatever/api.proto")
  }
}

tasks.matching { it.name == "generateCommonMainProtos" }.configureEach {
  dependsOn("getSchemas")
}

wire {
  sourcePath {
    srcDir("src/main/proto")
  }
}

This is error prone and counter to Gradle best practices.

In the same way that Kotlin-producing tasks can be added directly as a srcDir with which Gradle resolves the @OutputDirectory, I should be able to add proto-producing tasks (or rather, TaskProviders) to Wire's srcDir.