Upgrading from previous versions
From versions 0.5.x or older
If you had
build.gradle (legacy)
grabatool {
tool('go') {
uri { GrabaToolDescriptor cfg ->
String platform
String ext = 'tar.gz'
if (cfg.os.isWindows()) {
ext = 'zip'
if (cfg.os.arch == OperatingSystem.Arch.X86) {
platform = 'windows-386'
} else if (cfg.os.arch == OperatingSystem.Arch.X86_64) {
platform = 'windows-amd64'
} else {
throw new GradleException("${cfg.os.arch} is not a supported configuration for Windows")
}
} else if (cfg.os.isLinux()) {
if (cfg.os.arch == OperatingSystem.Arch.X86) {
platform = 'linux-386'
} else if (cfg.os.arch == OperatingSystem.Arch.X86_64) {
platform = 'linux-amd64'
} else {
throw new GradleException("${cfg.os.arch} is not a supported configuration for Linux")
}
} else if (cfg.os.isMacOsX()) {
platform = 'darwin-amd64'
} else {
throw new GradleException("${cfg.os} is not supported")
}
"https://dl.google.com/go/go${cfg.version}.${platform}.${ext}".toURI()
}
entrypoint { GrabaToolEntryPointDescriptor ep ->
String ext = ep.os.isWindows() ? '.exe' : ''
new File(ep.distributionRoot, "bin/${ep.name}${ext}")
}
}
}
It will need to change to
build.gradle
grabatool {
tool('go') {
execPatterns 'bin/*'
uri { cfg ->
}
entrypoint('go') { cfg ->
cfg.windows ? 'bin/go.exe' : 'bin/go'
}
}
}
In addition to this, in the older version you would have then got hold of the entrypoint via something like
build.gradle (legacy)
String go = grabatool.get('go').version('1.10').entrypoint('').absolutePath
Now you only have to do
build.gradle
Provider<File> go = grabatool.tools.named('go').map { it.entrypoints.get()['go'] } (1)
Provider<File> gofmt = grabatool.tools.go.entrypoints.map { it['gofmt'] } (2)
| 1 | Used the named approach |
| 2 | Instantiate the tool reference early but delay the download until the point that it is required. |