问题描述
要编译proto文件,我使用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 {}
}
}
}
我想将此设置隐藏在自定义插件中,并从Bom获取protoc
和protoc-gen-grpc-java
坐标:
// 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')
}
我可以通过gradle API以某种方式获取解析的坐标(com.google.protobuf:protoc:3.12.3
和io.grpc:protoc-gen-grpc-java:1.30.2
)吗?
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('...')));
});
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)