I need to run a task that depends on a file from an artifact repository, say
https://artifact-repository.de.com/artifacts/base/org/myModule/1680/myModule-1680-class.zip
If the file isn’t present, the Task should be skipped (and the remainder of much build will continue, as sort of a “partial build”).
The following snippet downloads and caches the file as expected:
repositories {
ivy {
url 'https://artifact-repository.de.com/artifacts/'
patternLayout {
artifact '/base/[organisation]/[module]/[revision]/[module]-[revision]-[classifier].[ext]'
}
metadataSources { artifact() }
}
}
configurations {
myConf
}
dependencies {
// Pattern: [organisation]:[module]:[revision]:[classifier]@[ext]
myConf "org:myModule:1680:class@zip"
}
tasks.register('processFile') {
def myConfClasspath = configurations.myConf.asPath
doLast {
println("####### ${myConfClasspath}")
}
}
Neat!
But if the dependency doesn’t exist in the server, my build breaks right away.
I’m not finding a way to skip this processFile
Task in this case. Is it possible at all?
If not, I think I’ll probably have to resort to exec+curl
or ant.get
, but I went for this approach first because in reality I’ll have a bunch of files to solve and this way sounded more “correct”.
EDIT: I should mention the source of my implementation: http - gradle - download and unzip file from url - Stack Overflow