[GRADLE-2920] Unable to resolve configuration with dependency to later version of current project Created: 10/Oct/13  Updated: 18/May/16  Resolved: 20/Oct/13

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 1.9-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Fixed Votes: 0


 Description   

I'm trying to find the latest version of the module I'm current builds, to determine what version I should use. There's some business logic around actually picking the next version, but first I have to get it. In Ivy, I could ask the RepositoryResolver to list of revisions. I'm trying to find a Gradle equivalent, so I created a detached configuration with a single dependency of the current project and tried to resolve it. Nope. That results in a "Unexpected root id" exception. I have plans to do jdiff like report based on the previous version of the current module, but I can never do that if I can't resolve a configuration to find it.

This seems like a bug. Below is a sample that shows that a detached conf works find for some other module, but not myself. findLatest will fail, and findLatestJunit will work fine.

repositories {
mavenCentral()
}

group = 'commons-logging'

task findLatest << {
def d = dependencies.create(group: project.group, name: project.name, version: '+')
def c = configurations.detachedConfiguration(d).setTransitive(false)
println c.resolvedConfiguration.firstLevelModuleDependencies
}

task findLatestJunit << {
def d = dependencies.create(group: 'junit', name: 'junit', version: '+')
def c = configurations.detachedConfiguration(d).setTransitive(false)
println c.resolvedConfiguration.firstLevelModuleDependencies
}

The exception:

Caused by: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration 'detachedConfiguration1'.
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.wrapException(ErrorHandlingArtifactDependencyResolver.java:57)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.access$000(ErrorHandlingArtifactDependencyResolver.java:34)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$ErrorHandlingResolvedConfiguration.getFirstLevelModuleDependencies(ErrorHandlingArtifactDependencyResolver.java:194)
at build_6s50q9miouadc8tvcp493ns1ue$_run_closure2.doCall(/Users/jryan/Projects/detachedproblem/build.gradle:11)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:496)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:477)
at org.gradle.api.internal.tasks.TaskStatusNagger$1.execute(TaskStatusNagger.java:77)
at org.gradle.api.internal.tasks.TaskStatusNagger$1.execute(TaskStatusNagger.java:73)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 70 more
Caused by: java.lang.RuntimeException: Problems reading data from Binary store in /private/var/folders/2q/nkf8g47s4k50hbn2q633q0ww_yp9s1/T/gradle8648575764113211065.bin (exist: true)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.DefaultBinaryStore$SimpleBinaryData.read(DefaultBinaryStore.java:119)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientResultsStore$3.create(TransientResultsStore.java:105)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientResultsStore$3.create(TransientResultsStore.java:102)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory$SimpleStore.load(CachedStoreFactory.java:95)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientResultsStore.load(TransientResultsStore.java:102)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.DefaultResolvedConfigurationBuilder.more(DefaultResolvedConfigurationBuilder.java:96)
at org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration.getFirstLevelModuleDependencies(DefaultLenientConfiguration.java:155)
at org.gradle.api.internal.artifacts.ivyservice.DefaultResolvedConfiguration.getFirstLevelModuleDependencies(DefaultResolvedConfiguration.java:50)
at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver$FilesAggregatingResolvedConfiguration.getFirstLevelModuleDependencies(SelfResolvingDependencyResolver.java:90)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver$ErrorHandlingResolvedConfiguration.getFirstLevelModuleDependencies(ErrorHandlingArtifactDependencyResolver.java:192)
... 77 more
Caused by: java.lang.IllegalStateException: Unexpected root id commons-logging:commons-logging:unspecified:detachedConfiguration1. Seen ids: []
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientResultsStore.deserialize(TransientResultsStore.java:138)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientResultsStore.access$100(TransientResultsStore.java:40)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientResultsStore$3$1.read(TransientResultsStore.java:107)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientResultsStore$3$1.read(TransientResultsStore.java:105)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.DefaultBinaryStore$SimpleBinaryData.read(DefaultBinaryStore.java:117)
... 86 more



 Comments   
Comment by Gradle Forums [ 10/Oct/13 ]

A little more proof that this is a bug, this method works:

task findLatestChangeGroup << {
def savedGroup = project.group
try {
project.group = 'fake-never-used'
def d = dependencies.create(group: savedGroup, name: project.name, version: '+')
def c = configurations.detachedConfiguration(d).setTransitive(false)
println c.resolvedConfiguration.firstLevelModuleDependencies
} catch(Exception e) {
project.group = savedGroup
}
}

As long as the project's group is different for a short time, it'll work.

Comment by Chris Hampton [ 18/May/16 ]

This is still an issue as of Gradle 2.13. I had to use the workaround above to get it to work.

Generated at Wed Jun 30 12:35:01 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.