gradleerrorprone

adding errorprone to gradle build file


I am trying to add errorprone to my gradle build file as follows:

relevant parts of 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'
}

error from classpath line when I run 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.

Any thoughts on what is causing this issue and what might help resolve this? Thanks


Solution

  • I got errorprone to work with gradle by making the following changes:

    1. replaced this from dependencies:

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

    with

     errorprone "com.google.errorprone:error_prone_core:latest.release"
    
    1. and removed the configurations line:

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

    This worked.