如何解决解决来自自定义Gradle插件的平台依赖性
要编译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 举报,一经查实,本站将立刻删除。