So I managed to have something working but it looks very hackish:
private File computeDependency(Object module) {
def oldGroup = project.group
def result = null
try {
project.group = 'virtual_group_for_japicmp'
// convenience wrapping for single file
def depModule = module instanceof File ? project.files(module) : module
def configuration = project.configurations.detachedConfiguration(
project.dependencies.create(depModule) {
if (hasProperty('transitive')) {
transitive = false
}
}
)
result = configuration.singleFile
} finally {
project.group = oldGroup
}
result
}
Note how I am forced to change the group of the project. Now it allows me to write:
task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask) {
baseline = 'org.codehaus.groovy:groovy:2.3.5'
to = 'org.codehaus.groovy:groovy:2.3.6'
// ...
}
or:
task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask) {
baseline = 'org.codehaus.groovy:groovy:2.3.5'
to = jar.archivePath
}
But (and I’m not sure if it is relevant), this will fail:
task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask) {
baseline = 'org.codehaus.groovy:groovy:2.3.5'
to = project
}
Error is: Module version virtual_group_for_japicmp:groovy:2.4.0-SNAPSHOT, configuration ‘detachedConfiguration3’ declares a dependency on configuration ‘default’ which is not declared in the module descriptor for virtual_group_for_japicmp:groovy:2.4.0-SNAPSHOT