Cannot resolve external dependency com.google.googlejavaformat:google-java-format:1.3
See original GitHub issueRecently 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 include
d.
Issue Analytics
- State:
- Created 6 years ago
- Comments:20 (19 by maintainers)
Top Results From Across the Web
Keep getting Cannot resolve external dependency com ...
I have an app that I have created. The app up until now has been able to login existing users and register new...
Read more >Cannot resolve external dependency com.android.tools.build ...
I do an update in my android studio, i have the following error. I know that the problem in build.gradle, how can i...
Read more >Re: Cannot resolve external maven dependencies with gradle ...
I'm not able to resolve external dependencies using gradle. I've created a brand new project, and edited the gradle.build file to be as...
Read more >Does the lifecycle of a build differ when called by buildship to ...
in this situation, buildship fails to import dependencies (a long list of “could not resolve” errors) whereas running a gradle task from eclipse...
Read more >Different Ways to fix Cannot resolve symbol ... - GeeksforGeeks
gradle(Module:app) file and in the dependencies section the appcompat one, you should see something like compile 'com.android.support:appcompat- ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry Ned, I am unsure now what your final word is. In your previous comment you stated that security concerns should not block for my proposal. And you mentioned CI. My experience with CI was actually the key point why I think my proposal is not a hack. My proxy config looks like this:
This is in my opinion how gradle wants a proxy to be configured. If the proxy can can not resolve the extensions and direct access of Maven Central is denied, than you get an error like you do now. I had the problem that my proxy forwards request to Maven Central. So when #99 was solved, I needed no changes in my build scripts. But when I committed the JUnit changes, JUnit Travis failed. This would not have happen with my proposed solution. When I said that disallowing access to all Maven Central versions (via proxy or not), I meant ‘rare’ in the sense that it only affect less than 5% of the users. 95% of the users would be able just to use
spotless
without any further configuration, regardless whether they use multi-project, or configuredspotless
in a dedicated gradle file. Just let me now what the final solution shall be.rootProject
is possible, but still does not help (at least according to my understanding of the Gradle Doc) if you useapply plugin
and have your spotless config in a separate script, which I think is quite common scenario. Let me look for the right hook and the solution will cover (I’ll add tests 😄 ) both scenarios.