task untar(type: Copy) { into file("${buildDir}/unpacked/dist/") eachFile { FileCopyDetails fcd -> fcd.path = fcd.path.substring(path.indexOf('/') + 1) } } tasks.untar.dependsOn(download) tasks.untar.doFirst { if (file("${buildDir}/unpacked/dist/").exists()) { file("${buildDir}/unpacked/dist/").deleteDir() } } ospackage { from untar.outputs.files } project.afterEvaluate { untar.from tarTree(download.dest) } tasks.activator.dependsOn('untar') final downloadCertGrid = makeDownloadTask( url: 'https://cafiles.cern.ch/cafiles/certificates/CERN%20Grid%20Certification%20Authority.crt', sha256: 'dce1eedad3edef466ecaeebfd711291e3b86f72ca8e6b0bba65162fd07a3e642' ) final downloadCertRoot2 = makeDownloadTask( url: 'https://cafiles.cern.ch/cafiles/certificates/CERN%20Root%20Certification%20Authority%202.crt', sha256: '187f4f7b1315ebd2b72547c1accf2ec4077d51c14a0ce574904a9fdaea8a320c' ) void keytool(String alias, File cert) { final bin = new File(project.buildDir, 'unpacked/dist/bin/keytool') final keystore = new File(project.buildDir, 'unpacked/dist/jre/lib/security/cacerts') project.exec { it.executable(bin) it.args( '-noprompt', '-import', '-trustcacerts', '-alias', alias, '-file', cert.absolutePath, '-keystore', keystore.absolutePath, '-storepass', 'changeit') } } final keytoolTask = tasks.create('keytool') { inputs.file downloadCertGrid.outputs inputs.file downloadCertRoot2.outputs } keytoolTask.dependsOn(tasks.untar, downloadCertGrid) keytoolTask << { keytool('cern_grid_ca', downloadCertGrid.dest) keytool('cern_root2_ca', downloadCertRoot2.dest) } tasks.activator.dependsOn(keytoolTask)