Skip to content

Cannot resolve external dependency com.google.googlejavaformat:google-java-format:1.3 #120

@arulrajnet

Description

@arulrajnet

Recently I have upgraded to spotless 3.4.0. Gradle 3.5 and Java 1.8
My spotless config

buildscript {
  repositories {
    mavenCentral()
    maven { url 'https://plugins.gradle.org/m2/' }
  }
  dependencies {
    classpath 'com.diffplug.spotless:spotless-plugin-gradle:3.4.0'
    classpath 'com.google.googlejavaformat:google-java-format:1.3'
  }
}

apply plugin: com.diffplug.gradle.spotless.SpotlessPlugin

spotless {
  java {
    googleJavaFormat('1.3')
    custom 'Lambda fix', { it.replace('} )', '})').replace('} ,', '},') }
    importOrder(['java', 'javax', 'org', 'com'])
    trimTrailingWhitespace()
    removeUnusedImports()
  }
  format 'misc', {
    target '**/.gitignore', '**/*.gradle', '**/*.md', '**/*.sh'
    indentWithSpaces(2)
    trimTrailingWhitespace()
    endWithNewline()
  }
}

I am getting following error.

:spotlessJava
You probably need to add a repository containing the '[com.google.googlejavaformat:google-java-format:1.3]' artifact, e.g.: 'buildscript { repositories { mavenCentral() }}'
org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':detachedConfiguration1'.
        at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.rethrowFailure(DefaultLenientConfiguration.java:192)
        at 
 (tons more)

If I downgrade to 3.0.0 its just working fine for the same config.


EDIT by @nedtwigg: this is a long thread, but the resolution was that the buildscript block above must appear in build.gradle, it's not enough for it to be appear in a separate file, such as spotless.gradle, which gets included.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions