将errorprone添加到gradle构建文件

时间:2017-03-27 19:00:16

标签: gradle errorprone

我正在尝试将errorprone添加到我的gradle构建文件中,如下所示:

build.gradle的相关部分

buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.9"
    }
}

plugins {
    id 'java'
    id 'application'
    id 'idea'
    id 'com.github.johnrengelman.shadow' version '1.2.4'
    id "net.ltgt.errorprone" version "0.0.9"
}

dependencies {
    classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.9'
}

configurations.errorprone {
    resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.19'
}
运行gradle clean

时,类路径行出现

错误

 Could not find method classpath() for arguments [net.ltgt.gradle:gradle-errorprone-plugin:0.0.9] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

对导致此问题的原因以及可能有助于解决此问题的任何想法?感谢

1 个答案:

答案 0 :(得分:1)

我通过进行以下更改让errorprone与gradle一起工作:

  1. 将其替换为依赖

    classpath net.ltgt.gradle:gradle-errorprone-plugin:0.0.9'

  2. <ns10:Location>
               <ns10:LocationId>
                  <ns5:RowId>7080013</ns5:RowId>
               </ns10:LocationId>
               <ns10:LocationDetails>
                  <ns10:AuditElement/>
                  <ns10:EffectiveDate/>
                  **<ns10:LocationName>REMOVEDEPENDENCY004</ns10:LocationName>**
                 <ns10:RailIncData/>
                  **<ns10:CustCity333Name>OAKLAND</ns10:CustCity333Name>**
                  <ns10:CustCity333Id>OAKLAND</ns10:CustCity333Id>
                  <ns10:CustCity333StateCode>TN</ns10:CustCity333StateCode>
                  <ns10:ParentCIFDetails/>
               </ns10:LocationDetails>
            </ns10:Location>
            <ns10:Location>
               <ns10:LocationId>
                  <ns5:RowId>7080018</ns5:RowId>
               </ns10:LocationId>
               <ns10:LocationDetails>
                  <ns10:AuditElement/>
                  <ns10:EffectiveDate/>
                  **<ns10:LocationName>REMOVEDEPENDENCY004</ns10:LocationName>**
                  <ns10:RailIncData/>
                  **<ns10:CustCity333Name>OAKLAND</ns10:CustCity333Name>**
                  <ns10:CustCity333Id>OAKLAND</ns10:CustCity333Id>
                  <ns10:CustCity333StateCode>TN</ns10:CustCity333StateCode>
                  <ns10:ParentCIFDetails/>
               </ns10:LocationDetails>
    
    1. 删除了配置行

      configurations.errorprone {     resolutionStrategy.force'com.google.errorprone:error_prone_core:2.0.19' }

    2. 这很有用。