I have a build file that retrieves a config file dependency and renames it during copy. I would like to extract the version number from the file name. File names are in the format “config-1.2.3-myname.tgz”. Ideally, I would like to end up with the version “1.2.3” in the local variable configVersion. I am renaming it as below but I’m not sure the best way to extract the version to a variable.
String configVersion
task retrieveConfig(type: Copy) {
group 'Docker'
description "retrieve config and extract version"
from (configurations.myconfig) {
rename 'config-([^-]*)-.*', 'config-$1.tgz'
}
into myfolder
}