[GRADLE-2679] UnsupportedOperationException in ExternalResourceResolver Created: 12/Feb/13  Updated: 02/Feb/17  Resolved: 02/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: 1.4
Fix Version/s: None

Type: Bug
Reporter: Stephane Gallès Assignee: Unassigned
Resolution: Fixed Votes: 0


 Description   

Regression in Gradle 1.4 related to the configuration API :

How to reproduce :

1) test fixture : create a simple project with an http ivy repository.
2) publish some artifacts in the http ivy repository
3) execute this task :


task displayCurrentVersion << {
	
	Project sandBox = org.gradle.testfixtures.ProjectBuilder.builder().withName('dummyName').build()
	sandBox.repositories.addAll(project.repositories)
	sandBox.configurations {
		selfConf {
			transitive = false
		}
	}
	sandBox.dependencies {
		selfConf group:project.group, name:project.name, version:'latest.integration'
	}
	String currentVersion
	sandBox.configurations.selfConf.resolvedConfiguration.firstLevelModuleDependencies.each { ResolvedDependency dep ->
		currentVersion = dep.moduleVersion
	}
	println currentVersion
	
}

This used to work in gradle 1.2 or 1.3 (ie the latest published version number is shown), but with Gradle 1.4 we get :

Caused by: java.lang.UnsupportedOperationException
        at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.getDependency(ExternalResourceResolver.java:148)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.IvyDependencyResolverAdapter.getDependency(IvyDependencyResolverAdapter.java:49)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CacheLockingModuleVersionRepository$1.run(CacheLockingModuleVersionRepository.java:50)
        at org.gradle.testfixtures.internal.InMemoryCacheFactory$InMemoryCache.longRunningOperation(InMemoryCacheFactory.java:111)
        at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.longRunningOperation(DefaultCacheLockingManager.java:49)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CacheLockingModuleVersionRepository.getDependency(CacheLockingModuleVersionRepository.java:48)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleVersionRepository.getDependency(CachingModuleVersionRepository.java:88)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.IvyContextualiser$1.invoke(IvyContextualiser.java:44)
        at $Proxy31.getDependency(Unknown Source)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain$RepositoryResolveState.resolve(UserResolverChain.java:185)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.findLatestModule(UserResolverChain.java:97)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.findLatestModule(UserResolverChain.java:80)
        at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.resolve(UserResolverChain.java:54)


 Comments   
Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 02/Feb/17 ]

The following works fine for me with 3.3:

Project sandBox = org.gradle.testfixtures.ProjectBuilder.builder().withName('dummyName').build()
sandBox.repositories {
    mavenCentral()
}
sandBox.configurations {
	selfConf {
		transitive = false
	}
}
sandBox.dependencies {
	selfConf group:'log4j', name:'log4j', version:'latest.integration'
}
String currentVersion
sandBox.configurations.selfConf.resolvedConfiguration.firstLevelModuleDependencies.each { ResolvedDependency dep ->
	currentVersion = dep.moduleVersion
}
println currentVersion
Generated at Wed Jun 30 12:28:30 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.