Hi,
I was doing some performance optimizations including using detached configurations instead of non-detached ones.
It looks like resolving detached configuration by calling resolve()
method is not blocking and does not guarantee all files are resolved after the method calls finishes.
Used test code:
private static final Map<String, Configuration> artifactGAVToDetachedConfigurationMapper = new HashMap<>()
private void addExtractApolloNativeArtifactExtClosure(Project project) {
project.ext[APOLLO_EXTRACT_NATIVE_ARTIFACT_EXT_CLOSURE_NAME] = { args ->
...
String artifactGAV = "${args.group}:${args.name}:${args.version}${classifier}@zip"
def artifactDependency = project.dependencies.create(artifactGAV)
def detachedArtifactConfiguration = null
if (artifactGAVToDetachedConfigurationMapper.containsKey(artifactGAV))
detachedArtifactConfiguration = artifactGAVToDetachedConfigurationMapper.get(artifactGAV)
else {
project.logger.info "Creating detached configuration to download artifact '$artifactGAV'."
detachedArtifactConfiguration = project.rootProject.configurations.detachedConfiguration(artifactDependency)
artifactGAVToDetachedConfigurationMapper.put(artifactGAV, detachedArtifactConfiguration)
}
project.logger.info "Resolving detached configuration resolving artifact '$artifactGAV'."
def configurationFiles = detachedArtifactConfiguration.resolve()
if (configurationFiles.isEmpty())
throw new IllegalStateException("Resolved detached configuration for artifact '$artifactGAV' is empty!")
project.copy {
from configurationFiles.collect {
project.zipTree(it).matching({...})
}
}
}
}
The thrown exception:
Caused by: org.gradle.api.InvalidUserDataException: Cannot expand ZIP '/home/martin/.gradle/caches/modules-2/files-2.1/apollosoft.native.libs/gfxexport/16.07.04/76a11597ee36c0bee0c3255f801e72aa177e87c3/gfxexport-16.07.04-linux-32-release.zip' as it does not exist.
Which is correct as the file does not exist yet. So this looks like resolving detached configuration does not block till the artifact is resolved. Tested on Gradle 4.0-rc-2.
Can you please comment/verify?