Is it possible to manually trigger a manual download of an artifact (using the group:name:version notation) as part of a custom task?
I’d like to download a maven repo zip file and unpack as part of a pre integration test.
To add to the complexity, the version number of the artifact needs to be discovered based upon a transitive dependency of the project itself:
-
org.springframework.data:spring-data-elasticsearch:3.0.8.RELEASE
org.elasticsearch:elasticsearch:5.6.9
I want to download org.elasticsearch.distribution.zip:elasticsearch:5.6.9:zip
, but the version number (5.6.9) is defined within the spring-data-elasticsearch top level dependency (and i’d rather not hardcode the version)
I’ve made a simple method to discover the version using configurations.compile.resolvedConfiguration.resolvedArtifacts.find { ... }
:
def getEsVersion() {
return configurations.compile.resolvedConfiguration.resolvedArtifacts.find {
return it.moduleVersion.id.group == 'org.elasticsearch'
&& it.moduleVersion.id.name == 'elasticsearch'
}.moduleVersion.id.version
}
I assume i need to interact with the repositories set, or the external resource resolver (hopefully pulling from the local repo after the first time its downloaded) - any ideas?
For some more context - i’d like to download the elasticsearch distribution zip as part of my integration tests setup, ensure its unzipped and start up a node for testing (yes, subjectively docker would be another / better solution).