gradle - gradle protobuf插件不起作用

标签 gradle build.gradle gradle-plugin

我在一个项目中使用下面提到的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。后者是您尝试分配给它的类,它将不起作用,前者是您分配给它的属性。

关于gradle - gradle protobuf插件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43186174/

相关文章:

android - 找不到方法 'org.gradle.api.artifacts.result.ComponentSelectionReason.getDescription()Ljava/lang/String;'

java - Android注释处理-为不同的构建风格生成不同的代码

intellij-idea - 无法刷新IntelliJ中的gradle项目

android - 极慢的gradle构建

android - 无法解析com.google.android.gms.play-service:8.1.0

gradle - 无法让 checkstyle 在 intellij 中与 gradle 一起使用

gradle - 如何集中Gradlebuild设置?

maven - 在 gradle 中重用 maven uber.pom

android - 将广告依赖项更新到最新版本后出现构建错误

jenkins - Jenkins使用Gradle守护程序构建失败