1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'org.xapek.yvesf:gradle-download-task:0.1-SNAPSHOT'
}
}
task download(type: org.xapek.yvesf.gradle.DownloadTask) {}
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.destFile)
}
tasks.activator.dependsOn('untar')
task downloadCertGrid(type: org.xapek.yvesf.gradle.DownloadTask) {
source 'https://cafiles.cern.ch/cafiles/certificates/CERN%20Grid%20Certification%20Authority.crt'
sha256sum 'dce1eedad3edef466ecaeebfd711291e3b86f72ca8e6b0bba65162fd07a3e642'
}
task downloadCertRoot2(type: org.xapek.yvesf.gradle.DownloadTask) {
source 'https://cafiles.cern.ch/cafiles/certificates/CERN%20Root%20Certification%20Authority%202.crt'
sha256sum '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 tasks.downloadCertGrid.outputs
inputs.file tasks.downloadCertRoot2.outputs
}
keytoolTask.dependsOn(tasks.untar, tasks.downloadCertGrid)
keytoolTask << {
keytool('cern_grid_ca', tasks.downloadCertGrid.destFile)
keytool('cern_root2_ca', tasks.downloadCertRoot2.destFile)
}
tasks.activator.dependsOn(keytoolTask)
|