google / protobuf-gradle-plugin

Protobuf Plugin for Gradle
Other
1.77k stars 274 forks source link

protoc resolve weirdness #140

Open bootstraponline opened 7 years ago

bootstraponline commented 7 years ago
task setupProtocEnvironment << {
  test.setEnvironment(PROTOC_COMPILER: project.protobuf.tools.protoc.path)
}

project.protobuf.tools.protoc.path is always null. I have to explicitly resolve the configuration:

project.configurations.protobufToolsLocator_protoc.resolve().getAt(0)

is there a better way?

zhangkun83 commented 7 years ago

There isn't currently no better way. The path to the downloaded protoc isn't meant to be exposed. Why do you need it?

bootstraponline commented 7 years ago

The googleapis/toolkit relies on setting an environment variable PROTOC_COMPILER to the path of the protoc executable. Previously project.protobuf.tools.protoc.path worked, however when I updated the plugin the result is always null.

zhangkun83 commented 7 years ago

Is this the proper reference?

Neither project.protobuf.tools.protoc.path nor project.configurations.protobufToolsLocator_protoc.resolve().getAt(0) are good ideas. If a local protoc was set via project.protobuf.tools.protoc.path, project.configurations.protobufToolsLocator_protoc.resolve().getAt(0) wouldn't work.

We may be able to provide a public accessor of the protoc, but we may have to tweak the timing of protoc downloads, thus it's not a trivial change, and I currently don't have time to do it.

bootstraponline commented 7 years ago

Is this the proper reference?

Nope, it's this

project.protobuf.tools.protoc.path which works on an older version of the protobuf-gradle-plugin broke upon updating. I've switched to project.configurations.protobufToolsLocator_protoc.resolve().getAt(0). We'll never use a local protoc.

We may be able to provide a public accessor of the protoc, but we may have to tweak the timing of protoc downloads, thus it's not a trivial change, and I currently don't have time to do it.

That would be nice. I don't think there's any rush as we have a work around that's good enough.