我在一个项目中使用下面提到的protobuf gradle插件,但是当我在另一个项目中引用相同的插件时,'gradle clean'一直给我下面复制的错误:
build.grade(v3.4)的相关部分
apply plugin: 'com.google.protobuf'
buildscript {
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
dependencies {
// classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.9"
// classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
}
}
def grpcVersion = '1.1.2'
dependencies {
compile "io.grpc:grpc-netty:${grpcVersion}"
compile "io.grpc:grpc-protobuf:${grpcVersion}"
compile "io.grpc:grpc-stub:${grpcVersion}"
}
protobuf {
protoc {
Artifact = 'com.google.protobuf:protoc:3.2.0'
}
plugins {
grpc {
Artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
all()*.plugins {
grpc {
// To generate deprecated interfaces and static bindService method,
// turn the enable_deprecated option to true below:
option 'enable_deprecated=false'
}
}
}
}
我运行gradle clean时错误
* What went wrong:
Could not compile build file '/xyz/xyz/build.gradle'.
> startup failed:
build file '/xyz/xyz/build.gradle': 102: you tried to assign a value to the class 'org.gradle.api.component.Artifact'
@ line 102, column 9.
Artifact = 'com.google.protobuf:protoc:3.2.0'
^
build file '/xyz/xyz/build.gradle': 106: you tried to assign a value to the class 'org.gradle.api.component.Artifact'
@ line 106, column 13.
Artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
我尝试过protobuf插件0.8.0。和0.8.1但都给出了同样的错误。 v0.8.0在不同的项目中工作。任何关于如何进一步解决这个问题的想法都将不胜感激。
答案 0 :(得分:2)
应该是artifact
,而不是Artifact
。后者是您尝试分配到哪个类不起作用的类,前者是您指定的属性。