use*_*618 8 protocol-buffers gradle
我的目录结构是src/ps/proto.我的build.gradle文件位于src目录中.我已将sourceSets设置为
sourceSets {
ps {
proto {
srcDir 'ps/proto'
}
}
}
Run Code Online (Sandbox Code Playgroud)
然而,一个gradlew generatePsProto给了我一大堆错误,其中一个是我的源目录是src/src/ps/proto.
Execution failed for task ':generatePsProto'.
> protoc: stdout: . stderr: /home/build/tree/src/src/ps/proto: warning: directory does not exist.
[libprotobuf WARNING google/protobuf/compiler/parser.cc:546] No syntax specified for the proto file: cldb.proto. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
ps/proto/security.proto: File not found.
ps/proto/common.proto: File not found.
ps/proto/cli.proto: File not found.
ps/proto/volumemirrorcommon.proto: File not found.
ps/proto/metrics.proto: File not found.
cldb.proto: Import "ps/proto/security.proto" was not found or had errors.
cldb.proto: Import "ps/proto/common.proto" was not found or had errors.
mldb.proto: Import "ps/proto/cli.proto" was not found or had errors.
mldb.proto:214:12: "CredentialsMsg" is not defined.
mldb.proto:218:12: "CredentialsMsg" is not defined.
[...]
mldb.proto:3614:12: "Key" is not defined.
mldb.proto:3618:12: "CredentialsMsg" is not defined.
mldb.proto:3619:12: "ServerKeyType" is not defined.
Run Code Online (Sandbox Code Playgroud)
我不想要src/ps/proto的Gradle默认值.我想要ps/proto.可以这样做吗?我的目标是删除对protoc的硬编码exec调用,并使用protobuf pluging将*.proto文件编译成各自的*.h,*.cc,最终编译成*.o文件.
Gradle 4.7构建时间:2018-04-18 09:09:12 UTC修订:
b9a962bf70638332300e7f810689cb2febbd4a6cGroovy:2.4.12 Ant:2017年2月2日编译的Apache Ant(TM)版本1.9.9 JVM:1.8.0_144(Oracle Corporation 25.144-b01)操作系统:Linux 3.10.0-514.el7.x86_64 amd64
的build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5'
}
}
apply plugin: 'c'
apply plugin: 'cpp'
apply plugin: 'java'
apply plugin: 'com.google.protobuf'
repositories {
mavenCentral()
}
dependencies {
compile "com.google.protobuf:protobuf-java:2.4.1"
}
sourceSets {
ps {
proto {
srcDir 'ps/proto'
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:2.4.1'
}
generateProtoTasks {
all().each { task ->
task.plugins {
cpp {}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
您似乎打错了“fs”或“ps”。
问题是导入。因为你有例如
cldb.proto:导入“ps/proto/security.proto”
mldb.proto:导入“ps/proto/cli.proto”
编辑:
您必须将每个 .proto 文件放入 src/yourCustomSourceSetName/proto/ps/proto/ 并添加
sourceSets {
yourCustomSourceSetName {}
}
dependencies {
compile ... // dependencies for compileJava task
yourCustomSourceSetNameCompile ... // dependencies for custom sourceSet
compile sourceSets.yourCustomSourceSetName.output // compileJava uses output of the custom sourceSet
}
Run Code Online (Sandbox Code Playgroud)
然后导入将在正确的位置查找其他 .proto 文件。
| 归档时间: |
|
| 查看次数: |
657 次 |
| 最近记录: |