-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
182 lines (144 loc) · 5.08 KB
/
build.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
apply plugin: 'war'
apply plugin: 'pl.allegro.tech.build.axion-release'
apply plugin: 'org.hidetake.ssh'
apply plugin: 'com.bmuschko.cargo'
project.ext.set("glueVersion", "1.1.107")
ssh.settings { knownHosts = allowAnyHosts }
project.version = scmVersion.version
remotes {
btvglue_cvr {
host = 'btv-glue.cvr.gla.ac.uk'
user = 'am589p'
identity = file('/Users/imacadmin/.ssh/btv_glue_id_rsa')
}
}
repositories {
mavenLocal()
// cargo
mavenCentral()
}
configurations {
gluetoolsWebWar
gluetoolsWsWar
gluetoolsCore
}
dependencies {
gluetoolsWebWar group: 'cvr.ac.uk', name: 'gluetools-web', version: project.glueVersion, transitive: false
gluetoolsWsWar group: 'cvr.ac.uk', name: 'gluetools-ws', version: project.glueVersion, transitive: false
gluetoolsCore group: 'cvr.ac.uk', name: 'gluetools-core', version: project.glueVersion, transitive: false
cargo group: 'org.codehaus.cargo', name: 'cargo-core-uberjar', version: '1.7.4'
cargo group: 'org.codehaus.cargo', name: 'cargo-ant', version: '1.7.4'
}
buildscript {
repositories {
// for ssh-deploy stuff, cargo
jcenter()
// for axion-release
mavenCentral()
}
dependencies {
classpath group: 'org.hidetake', name: 'gradle-ssh-plugin', version: '1.1.3'
classpath group: 'commons-io', name: 'commons-io', version: '1.3.2'
classpath group: 'pl.allegro.tech.build', name: 'axion-release-plugin', version: '1.9.3'
classpath group: 'com.bmuschko', name: 'gradle-cargo-plugin', version:'2.6'
}
}
task deployDeps(dependsOn: ['copyGluetoolsWebWar',
'gluetoolsWsWithContextWar', 'deployGluetoolsConfigBtvGlueCVR'])
cargoRedeployRemote.dependsOn deployDeps
cargo {
containerId = 'tomcat7x'
port = 80
deployable {
file = new File(buildDir, 'runtimeWars/gluetools-ws.war')
context = '/gluetools-ws'
}
deployable {
file = new File(buildDir, 'runtimeWars/gluetools-web.war')
context = '/gluetools-web'
}
// btvGlue war has context path /
deployable {
context = '/'
}
remote {
hostname = 'btv-glue.cvr.gla.ac.uk'
// credentials in ~/.gradle/gradle.properties
username = System.getProperty("btv_glue.tomcat.mgmt.username")
password = System.getProperty("btv_glue.tomcat.mgmt.password")
}
}
war {
webAppDirName = 'WebContent'
archiveName 'btvGlue.war'
}
task copyGluetoolsJar(type: Copy) {
from configurations.gluetoolsCore
into "$buildDir/runtimeJars"
rename('gluetools-core-'+project.glueVersion+'.jar', 'gluetools-core.jar')
}
task copyGluetoolsWebWar(type: Copy) {
from configurations.gluetoolsWebWar
into "$buildDir/runtimeWars"
rename('gluetools-web-'+project.glueVersion+'.war', 'gluetools-web.war')
}
task copyGluetoolsWsWar(type: Copy) {
from configurations.gluetoolsWsWar
into "$buildDir/runtimeWars"
rename('gluetools-ws-'+project.glueVersion+'.war', 'gluetools-ws-without-context.war')
}
task gluetoolsWsWithContextWar(type: Jar, dependsOn: copyGluetoolsWsWar) {
destinationDir = new File(buildDir, 'runtimeWars')
archiveName = 'gluetools-ws.war'
from zipTree(new File(buildDir, 'runtimeWars/gluetools-ws-without-context.war'))
from(file("btvglue_cvr/gluetools-ws-context.xml")) {
into ('META-INF')
rename("gluetools-ws-context.xml", "context.xml")
}
}
task deployAll(dependsOn: ['cargoRedeployRemote'])
// gluetools xml config for CVR vm
task deployGluetoolsConfigBtvGlueCVR() {
ext.file = new File(projectDir, '/btvglue_cvr/btv-glue-gluetools-config.xml')
ext.touchfile = new File(buildDir, '/deployGluetoolsConfigBtvGlueCVR.touchfile')
inputs.file file
outputs.file touchfile
doLast {
println "Uploading "+file.name
ssh.run {
session(remotes.btvglue_cvr) {
put from: file.absolutePath, into: '/tmp/btv-glue-gluetools-config.xml'
execute 'mv /tmp/btv-glue-gluetools-config.xml /opt/gluetools/conf'
}
}
touchfile.delete()
buildDir.mkdirs()
touchfile.createNewFile()
}
}
def glueConfigFile = 'remote-gluetools-config.xml'
task wipeBtvGlueDB(type: Exec) {
commandLine "bash", "-c", "echo 'DROP DATABASE IF EXISTS BTV_GLUE; create database BTV_GLUE character set UTF8;' | mysql -u btvglue --password=btvglue"
}
task buildBtvGlueDB(type: JavaExec, dependsOn: 'copyGluetoolsJar') {
classpath "build/runtimeJars/gluetools-core.jar"
main 'uk.ac.gla.cvr.gluetools.core.console.Console'
args '-c', glueConfigFile, '-i', 'run', 'file', 'btvProject.glue'
}
def scmCustomKey = '/Users/imacadmin/.ssh/github_id_rsa'
scmVersion {
hooks {
pre 'fileUpdate', [file: 'glue/btvProjectSettings.glue', pattern: {v, c -> /set setting project-version $v/}, replacement: {v, c -> "set setting project-version $v"}]
pre 'fileUpdate', [file: 'WebContent/btvAppDependencies.html', pattern: {v, c -> /btvGlueVersion=$v/}, replacement: {v, c -> "btvGlueVersion=$v"}]
pre 'commit', {v, p -> "Release version $v"}
}
scmVersion {
versionCreator 'versionWithBranch'
repository {
customKey = file(scmCustomKey)
}
tag {
prefix = 'BTV-GLUE'
}
}
}