Might be something obvious, but this issue got me stuck for a while.
Some of the libraries require com.google.guava:guava:21.0
as the dependency, however gradle fails to fetch it from the maven repository. it's a legacy project, so versions are not the latest.
Error log:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find guava-21.0-cdi1.0.jar (com.google.guava:guava:21.0).
Searched in the following locations:
https://repo.maven.apache.org/maven2/com/google/guava/guava/21.0/guava-21.0-cdi1.0.jar
guava-21.0.jar
(without -cdi1.0
suffix) exists on that path. Why does gradle ads the -cdi1.0
suffix to the filename and is it possible to disable this feature? or i simply misunderstanding something and there is something else in play?
i tried to specify guava
dep separately compile(group: 'com.google.guava', name: 'guava', version: '21.0')
, however it doesn't affect anything.
build.gradle: (generated by gradle init
from maven pom.xml)
plugins {
id 'java'
id 'maven-publish'
}
repositories {
mavenCentral()
maven {
url = 'http://repo.maven.apache.org/maven2'
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web:1.4.1.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-jdbc:1.4.1.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-actuator:1.4.1.RELEASE'
... etc other deps
}
group = 'com.springapp'
version = '1.0-SNAPSHOT'
description = 'someproj'
java.sourceCompatibility = JavaVersion.VERSION_1_8
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
from gradle --debug build
:
2021-01-31T10:59:27.736-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for com.google.guava:guava:30.1-jre using repositories [MavenRepo, maven]
2021-01-31T10:59:27.736-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Using cached module metadata for module 'com.google.guava:guava:30.1-jre' in 'MavenRepo'
2021-01-31T10:59:27.737-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Using com.google.guava:guava:30.1-jre from Maven repository 'MavenRepo'
2021-01-31T10:59:27.737-0300 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] Candidate com.google.guava:guava:30.1-jre configuration compile doesn't have attribute org.gradle.dependency.bundling
2021-01-31T10:59:27.737-0300 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] Candidate com.google.guava:guava:30.1-jre configuration compile doesn't have attribute org.gradle.jvm.version
2021-01-31T10:59:27.737-0300 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] Candidate com.google.guava:guava:30.1-jre configuration runtime doesn't have attribute org.gradle.dependency.bundling
2021-01-31T10:59:27.737-0300 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] Candidate com.google.guava:guava:30.1-jre configuration runtime doesn't have attribute org.gradle.jvm.version
2021-01-31T10:59:27.738-0300 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] Candidate com.google.guava:guava:30.1-jre configuration platform-compile attribute org.gradle.category value {org.gradle.category=platform, org.gradle.status=release, org.gradle.usage=java-api} doesn't requested value library
2021-01-31T10:59:27.738-0300 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] Candidate com.google.guava:guava:30.1-jre configuration platform-runtime attribute org.gradle.category value {org.gradle.category=platform, org.gradle.status=release, org.gradle.usage=java-runtime} doesn't requested value library
2021-01-31T10:59:27.738-0300 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] Candidate com.google.guava:guava:30.1-jre configuration enforced-platform-compile attribute org.gradle.category value {org.gradle.category=enforced-platform, org.gradle.status=release, org.gradle.usage=java-api} doesn't requested value library
2021-01-31T10:59:27.738-0300 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] Candidate com.google.guava:guava:30.1-jre configuration enforced-platform-runtime attribute org.gradle.category value {org.gradle.category=enforced-platform, org.gradle.status=release, org.gradle.usage=java-runtime} doesn't requested value library
2021-01-31T10:59:27.738-0300 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected matches [com.google.guava:guava:30.1-jre configuration compile] from candidates [com.google.guava:guava:30.1-jre configuration compile, com.google.guava:guava:30.1-jre configuration runtime, com.google.guava:guava:30.1-jre configuration platform-compile, com.google.guava:guava:30.1-jre configuration platform-runtime, com.google.guava:guava:30.1-jre configuration enforced-platform-compile, com.google.guava:guava:30.1-jre configuration enforced-platform-runtime] for {org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.version=8, org.gradle.libraryelements=classes, org.gradle.usage=java-api}
and then later:
2021-01-31T10:59:27.938-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Found artifact 'guava-30.1-jre.jar (com.google.guava:guava:30.1-jre)' in resolver cache: /Users/hopa/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/30.1-jre/d0c3ce2311c9e36e73228da25a6e99b2ab826f/guava-30.1-jre.jar
2021-01-31T10:59:27.940-0300 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of artifact 'guava-30.1-jre-cdi1.0.jar (com.google.guava:guava:30.1-jre)' in resolver cache
this is the only time when cdi classifier is mentioned in debug log Detected non-existence of artifact 'guava-30.1-jre-cdi1.0.jar (com.google.guava:guava:30.1-jre)' in resolver cache
, except for the build fail message