To compile proto files i use protobuf-gradle-plugin:
plugins {
id 'com.google.protobuf'
}
...
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.12.3'
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.30.2'
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
}
I want to hide this setting in a custom plugin and get protoc
and protoc-gen-grpc-java
coordinates from bom:
// bom/build.gradle
plugins {
id 'java-platform'
}
dependencies {
constraints {
api 'io.grpc:protoc-gen-grpc-java:1.30.2'
api 'com.google.protobuf:protoc:3.12.3'
}
}
// app/build.gradle
plugins {
id 'com.google.protobuf'
id 'my-custom-plugin'
}
...
dependencies {
compileOnly platform('org.custom.bom:0.1.0-SNAPSHOT')
}
Can I somehow get the resolved coordinates (com.google.protobuf:protoc:3.12.3
and io.grpc:protoc-gen-grpc-java:1.30.2
) with the gradle API?
plugins.withType(ProtobufPlugin.class, protobufPlugin -> {
project.getConfigurations() ...
project.getDependencies() ...
ProtobufConvention protobufConvention =
project.getConvention().getPlugin(ProtobufConvention.class);
ProtobufConfigurator protobuf = protobufConvention.getProtobuf();
protobuf.protoc(ClosureInterop.of((ExecutableLocator locator) ->
locator.setArtifact('...')));
});