gradle protobuf 插件无法运行
gradle protobuf plugin not functioning
我在一个项目中使用下面提到的 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 在不同的项目中按原样工作。如果您有任何关于如何进一步解决此问题的想法,我们将不胜感激。
应该是artifact
,不是Artifact
。后者是您尝试分配给它的 class,前者是您分配给的 属性。
我在一个项目中使用下面提到的 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 在不同的项目中按原样工作。如果您有任何关于如何进一步解决此问题的想法,我们将不胜感激。
应该是artifact
,不是Artifact
。后者是您尝试分配给它的 class,前者是您分配给的 属性。