forked from getodk/aggregate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packer.gradle
61 lines (52 loc) · 3.65 KB
/
packer.gradle
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
import static org.opendatakit.aggregate.gradle.Util.setPropertiesValue
import static org.opendatakit.aggregate.gradle.Util.getVersionName
task packerClean() {
delete 'build/packer'
}
task packerDownloadPacker() {
doLast {
if (!file('packer/packer').exists()) {
println("Downloading Packer binary")
"curl -Lo packer/packer.zip ${packerZip}".execute().waitFor()
println("Unzipping Packer binary")
"unzip packer/packer.zip -d packer".execute().waitFor()
println("Cleaning Packer binary zip file")
"rm packer/packer.zip".execute().waitFor()
} else
println("Packer binary is already present")
}
}
task packerPrepareProject(dependsOn: [packerClean, packerDownloadPacker], type: Copy) {
into "${buildDir}/packer"
from fileTree(dir: 'packer')
into('ansible/roles/aggregate/files/ROOT') {
from zipTree("${buildDir}/libs/${archivesBaseName}-${version}.war")
}
doLast {
new File("${buildDir}/packer/ansible/roles/aggregate/files/aggregate-version").text = getVersionName()
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/jdbc.properties", "jdbc.url", "jdbc:postgresql:///aggregate?autoDeserialize=true")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/jdbc.properties", "jdbc.username", "aggregate")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/jdbc.properties", "jdbc.password", "aggregate")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/jdbc.properties", "jdbc.schema", "aggregate")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/security.properties", "security.server.realm.realmString", "ODK Aggregate")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/security.properties", "security.server.channelType", "ANY_CHANNEL")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/security.properties", "security.server.superUserUsername", "administrator")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/security.properties", "security.server.superUser", "")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/security.properties", "security.server.port", "10080")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/security.properties", "security.server.securePort", "10443")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/security.properties", "security.server.deviceAuthentication", "digest")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/security.properties", "security.server.hostname", "")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/security.properties", "security.server.secureChannelType", "ANY_CHANNEL")
setPropertiesValue("${buildDir}/packer/ansible/roles/aggregate/files/ROOT/WEB-INF/classes/security.properties", "security.help.about", "auto-generated on 1970-01-01T00:00:00+0000 for ODK Aggregate VM")
}
}
task packerCreateWAR(dependsOn: [packerPrepareProject], type: Zip) {
from "${buildDir}/packer/ansible/roles/aggregate/files/ROOT/"
include '**/*'
archiveName "ROOT.war"
destinationDir file("${buildDir}/packer/ansible/roles/aggregate/files/")
}
task packerBuild(dependsOn: [build, packerCreateWAR], type: Exec) {
workingDir "${buildDir}/packer"
commandLine "./packer", "build", "-force", "-only=virtualbox-iso", "aggregate.json"
}