[GRADLE-1109] Dependencies within multiple configurations, containing classifiers, fail to resolve and fail to show an error when attempting to copy the files Created: 11/Aug/10 Updated: 04/Jan/13 Resolved: 08/Sep/11 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 0.9 |
Fix Version/s: | 1.0-milestone-5 |
Type: | Bug | ||
Reporter: | Russ Rollins | Assignee: | Daz DeBoer |
Resolution: | Fixed | Votes: | 2 |
Attachments: | build.gradle |
Description |
This problem didn't occur in 0.9-preview-3 but is present in 0.9-rc1. The problem is trying to copy dependencies that have multiple configurations. My specific example has a classifier and was a zip file but I've also reproduced it with jars. The file wouldn't copy but the task finished without error. However, closer examination of the debugging log indicated that it couldn't resolve the file. I'm attaching a testcase that illustrates the issue (task is copyFail). Note that in the log below the filename doesn't include the classifier and thus doesn't properly resolve (which is obvious when looking at the log, but again, it doesn't indicate to the end user that there was an error in retrieving the file):
|
Comments |
Comment by Hans Dockter [ 15/Aug/10 ] |
I can reproduce this problem. The following snippet exposes this as well: apply plugin: 'groovy' apply plugin: 'maven' repositories { mavenCentral() } configurations { compile.transitive = false deptester.transitive = false } dependencies { compile group:"org.testng", name:"testng", version:"4.7", classifier:"jdk15" deptester group:"org.testng", name:"testng", version:"4.7", classifier:"jdk15" } task show << { configurations.compile.each { println it } println '-----------' configurations.deptester.each { println it } } The show task will show the correct transitive dependencies but does not resolve the actual testng artifact for the deptester configuration. If you choose a different testng version in deptester (e.g. 5.7) everything works as expected. As soon as I have time (I'm on holidays right now) I will look into this. Some comments related to your example script but not to the bug.
WorkaroundAn ugly workaround that might work for you is: task copyFail(type: Copy) { doFirst { from(configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.collect { dep -> dep.moduleArtifacts.collect { it.file } }) } def tempDir = new File("${projectDir}/temp") tempDir.mkdirs() into(tempDir) } This only copies the artifacts of the dependencies you have declared into the temp directory. Transitive dependencies are ignored. The from is only executed at execution time to avoid unnecessary resolving (e.g. when doing a clean). Even resolving from cache takes some time with Ivy (0.x secs). Having configuration statement in actions is something we usually try to avoid. It hides configurations information from other task that might be interested in that information at configuration time. |
Comment by Luke Daley [ 30/Aug/11 ] |
Daz, assigning to you in case this relates to the classifier work you are doing. If not, just unassign it again. |