version '3.1' final download = makeDownloadTask( url: "https://services.gradle.org/distributions/gradle-${project.version}-all.zip", sha256: '43be380834a13e28e9504c21f67fe1a8895ab54f314a6596601896dca7213482') task unpack(type: Copy) { from zipTree(download.dest) into file("${buildDir}/unpacked/dist") eachFile { FileCopyDetails fcd -> fcd.path = fcd.path.substring(path.indexOf('/') + 1) } } unpack.dependsOn(download) ospackage { into "/opt/${project.name}" from unpack.outputs.files }