Hi,
Using Gradle 2.4, I’m facing the following Could not resolve <dependency>
when building my project:
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve myGroup:myArtifact:1.0.0.
Required by:
:GradleQuickTests:unspecified
> Could not resolve myGroup:myArtifact:1.0.0.
> Could not parse POM file:/C:/workspace/maven-3.0.4/repository/myGroup/myArtifact/1.0.0/myArtifact-1.0.0.pom
> Unable to resolve version for dependency 'net.sf.ehcache:ehcache-core:ejb'
Here is my project configuration:
-
I use first maven local repo, and, then, a Nexus one:
repositories { mavenLocal() maven { url 'http://myServer/nexus/content/groups/public/' } }
-
In
myArtifact
pom.xml, theehcache-core
dependency is declared without its version, this last being declared in the pom of myArtifact parent, which is of type pom (meaning NO JAR for the parent).
After several tests and searches, I finally found that this issue was caused by the use of a local maven repo combined with a dependency of type “pom” as parent for myArtifact
.
Here are the low level exceptions returned by the debug mode:
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve myGroup:myArtifact:1.0.0.
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.resolveComponentMetaData(
ErrorHandlingModuleComponentRepository.java:91)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentMetaDataResolveState.process(ComponentMetaDataResolveState.java:66)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentMetaDataResolveState.resolve(ComponentMetaDataResolveState.java:45)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.findBestMatch(RepositoryChainDependencyResolver.java:114)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.findBestMatch(RepositoryChainDependencyResolver.java:97)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.resolve(RepositoryChainDependencyResolver.java:70)
... 91 more
Caused by: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.MetaDataParseException: Could not parse POM file:/C:/workspace/maven-3.0.4/repository/myGroup/
myArtifact/1.0.0/myArtifact-1.0.0.pom
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.AbstractModuleDescriptorParser.parseDescriptor(AbstractModuleDescriptorParser.java:48)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.AbstractModuleDescriptorParser.parseMetaData(AbstractModuleDescriptorParser.java:39)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver.parseMetaDataFromResource(MavenResolver.java:199)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.parseMetaDataFromArtifact(ExternalResourceResolver.java:174)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenLocalResolver.parseMetaDataFromArtifact(MavenLocalResolver.java:48)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.resolveStaticDependency(ExternalResourceResolver.java:147)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver.doResolveComponentMetaData(MavenResolver.java:93)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.resolveComponentMetaData(ExternalResourceResolver.java:414)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.LocalModuleComponentRepository$LocalAccess.resolveComponentMetaData(LocalModuleComponentRepository.java:63)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.BaseModuleComponentRepositoryAccess.resolveComponentMetaData(BaseModuleComponentRepositoryAccess.java:42)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedModuleComponentRepository$CachedAccess.resolveComponentMetaData(
InMemoryCachedModuleComponentRepository.java:75)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.resolveComponentMetaData(
ErrorHandlingModuleComponentRepository.java:89)
... 96 more
Caused by: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.UnresolvedDependencyVersionException: Unable to resolve version for dependency 'net.sf.ehcache:ehcache-
core:ejb'
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.GradlePomModuleDescriptorBuilder.determineVersion(GradlePomModuleDescriptorBuilder.java:351)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.GradlePomModuleDescriptorBuilder.addDependency(GradlePomModuleDescriptorBuilder.java:217)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.GradlePomModuleDescriptorParser.doParsePom(GradlePomModuleDescriptorParser.java:137)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.GradlePomModuleDescriptorParser.doParseDescriptor(GradlePomModuleDescriptorParser.java:70)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.GradlePomModuleDescriptorParser.doParseDescriptor(GradlePomModuleDescriptorParser.java:46)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.AbstractModuleDescriptorParser.parseDescriptor(AbstractModuleDescriptorParser.java:44)
... 107 more
When I only use a Nexus repo, I don’t encounter this issue.
Moreover, if I build the project successfully (using only my Nexus repo), which implies an update of the Gradle cache, then the project builds successfully even if using the local maven repo.
I think that this issue is related to Gradle issue 2709: “Dependency in Maven local with POM and no JAR file results in dependency resolve failure”, but it is indicated as fixed in version 1.9-rc1.
If someone knows how to solve this issue:
- with still using a local maven repo
- and still using a pom only parent dependency
it would be greatly appreciated.