forked from opengeospatial/teamengine-docker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
304 lines (269 loc) · 7.84 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:4.10.0'
classpath "org.ajoberstar.grgit:grgit-gradle:3.1.1"
}
}
apply plugin: 'com.bmuschko.docker-remote-api'
apply plugin: 'org.ajoberstar.grgit'
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.DockerPushImage
repositories {
mavenCentral()
maven {
url 'https://jitpack.io'
}
}
ext {
variants = [
/*
* Production versions
*/
production: [
teamEngine: '5.3',
'ets-wcs10': '1.13',
'ets-wcs11': '1.12',
'ets-wcs20': '1.12',
'ets-wfs10': '1.11',
'ets-wfs11': '1.29',
'ets-wfs20': '1.26',
'ets-wms11': '1.15',
'ets-wms13': '1.22',
'ets-wmts10': '1.0',
'ets-csw202': '1.16',
'ets-cat30': '1.0',
'ets-gml32': '1.25',
'ets-gpkg10': '1.0',
'ets-gpkg12': '1.0',
'ets-kml22': '1.12',
'ets-sfs11': '1.6',
'ets-sfs12': '1.4',
// 'ets-sos10': '1.13', XXX disabled because build fails - see https://jitpack.io/com/github/opengeospatial/ets-sos10/1.13/build.log
'ets-sos20': '1.13',
'ets-sps10': '1.7',
'ets-sps20': '1.10',
'ets-sta10': '1.0',
'ets-wms-client13': '1.2'
],
/*
* Beta versions
*/
beta: [
teamEngine: '5.3',
'ets-wcs10': '1.15',
'ets-wcs11': '1.12',
'ets-wcs20': '1.14',
'ets-wfs10': '1.12',
'ets-wfs11': '1.32',
'ets-wfs20': '1.30',
'ets-wfs30': '0.2',
'ets-wms11': '1.18',
'ets-wms13': '1.24',
'ets-wmts10': '1.2',
'ets-csw202': '1.18',
'ets-cat30': '1.2',
'ets-gml32': '1.26',
'ets-gpkg10': '1.1',
'ets-gpkg12': '1.0',
'ets-kml22': '1.13',
'ets-kml2': '0.5',
'ets-owc10': '0.1',
'ets-sensorml10': '0.9',
'ets-sensorml20': '0.8',
'ets-sfs11': '1.6',
'ets-sfs12': '1.4',
'ets-sos10': '1.14',
'ets-sos20': '1.13',
'ets-sps10': '1.7',
'ets-sps20': '1.11',
'ets-sta10': '1.2',
'ets-wms-client13': '1.3',
'ets-wps10': '0.6',
// 'ets-wfs20-dgiwg': '0.4', XXX disabled because build fails - see https://jitpack.io/com/github/opengeospatial/ets-wfs20-dgiwg/0.4/build.log
// 'ets-wms13-dgiwg': '0.4', XXX disabled because build fails - see https://jitpack.io/com/github/opengeospatial/ets-wms13-dgiwg/0.4/build.log
// 'ets-wms13-nsg': '0.2', XXX disabled because build fails - see https://jitpack.io/com/github/opengeospatial/ets-wms13-nsg/0.2/build.log
// 'ets-wfs20-nsg': '0.3', XXX disabled because build fails - see https://jitpack.io/com/github/opengeospatial/ets-wfs20-nsg/0.3/build.log
// 'ets-wmts10-nsg': '0.3', XXX disabled because build fails - see https://jitpack.io/com/github/opengeospatial/ets-wmts10-nsg/0.3/build.log
'ets-gpkg12-nsg': '0.5',
'ets-cat20-dgiwg10': '0.2', // was originally: '0.1-SNAPSHOT'
'ets-om20': '0.3', // was originally '1.1'
'ets-swecommon20': '0.3'
]
]
}
configurations {
teamEngine
tests
}
// helper for determining variant to build
def variant = {
return project.findProperty('variant') ?: 'production'
}
// helper for retrieving version
def withVersion = { context, closure ->
def vars = project.ext.variants[variant()]
def version = vars[context]
if (version) {
closure(version)
}
}
// helper to iterate over test modules
def modules = { closure ->
def vars = project.ext.variants[variant()]
vars.each { name, version ->
if (name != 'teamEngine') {
def clone = closure.clone()
clone(name, version)
}
}
}
// current Git version
def versionId = {
def head = grgit.head()
def headTag = grgit.tag.list().find {
it.commit == head
}
if (headTag) {
headTag.name
}
else {
head.abbreviatedId
}
}()
// helper for determining image repo
def imageRepo = {
project.findProperty('imageRepo') ?: 'wetransform/teamengine'
}
def contextFolder = new File(buildDir, 'docker')
dependencies {
withVersion('teamEngine') {
teamEngine "org.opengis.cite.teamengine:teamengine-web:$it@war"
teamEngine "org.opengis.cite.teamengine:teamengine-web:$it:common-libs@zip"
teamEngine "org.opengis.cite.teamengine:teamengine-console:$it:base@zip"
}
// Test modules
modules { name, version ->
// add each from jitpack.io
tests "com.github.opengeospatial:$name:$version:ctl@zip"
// the dependencies ZIP may or may not exist, depending on module and version -> test if file can be retrieved via jitpack directly
def code = new URL("https://jitpack.io/com/github/opengeospatial/$name/$version/$name-$version-deps.zip").openConnection().with {
requestMethod = 'HEAD'
connect()
responseCode
}
if (code != 404) {
tests "com.github.opengeospatial:$name:$version:deps@zip"
}
}
}
tasks.register('clean') {
doFirst {
contextFolder.deleteDir()
}
}
task copyTeamEngine(type: Copy) {
from configurations.teamEngine
into contextFolder
}
task copyTests(type: Copy) {
from configurations.tests
into contextFolder
}
task copyDockerfile(type: Copy) {
from file('Dockerfile.prototype')
into contextFolder
rename '\\.prototype', ''
}
task buildImage(type: DockerBuildImage, dependsOn: ['copyTests', 'copyTeamEngine', 'copyDockerfile']) {
pull = true
inputDir = contextFolder
tags = ["wetransform/teamengine:${variant()}-${versionId}", "wetransform/teamengine:${variant()}"]
// labels
def buildTime = java.time.ZonedDateTime.now().format(java.time.format.DateTimeFormatter.ISO_INSTANT);
def repo = grgit.remote.list().find {
it.name == 'upstream' // prefer upstream repo
}
if (!repo) {
repo = grgit.remote.list().find {
it.name == 'origin' // or origin
}
}
if (!repo && grgit.remote.list()) {
repo =grgit.remote.list()[0] // or any
}
if (repo) {
repo = repo.url
}
else {
repo = 'https://github.com/wetransform-os/teamengine-docker'
}
def dirty = !grgit.status().clean
def revision = grgit.head().id
if (dirty) {
revision = "$revision-dirty"
}
labels = [
// OCI annotations
'org.opencontainers.image.source': repo,
'org.opencontainers.image.revision': revision,
'org.opencontainers.image.version': versionId,
'org.opencontainers.image.created': buildTime
]
}
def pushTasks = []
project.tasks.buildImage.tags.get().each { imageTag ->
def localTag = imageTag.split(':')[1]
def repo = imageTag.split(':')[0]
def taskName = 'pushImage-' + localTag
pushTasks << taskName
tasks.register(taskName, DockerPushImage) {
group = "Push docker images"
dependsOn buildImage
imageName = repo
tag = localTag
}
}
tasks.register('pushImages') {
group = "Push docker images"
dependsOn pushTasks
}
project.ext.variants.each { name, vars ->
task("build-$name", type: GradleBuild) {
description "Builds the Docker image for the $name variant"
group "Variant $name"
startParameter.projectProperties.variant = name
def taskList = ['clean', 'buildImage']
tasks = taskList
}
task("push-$name", type: GradleBuild) {
description "Builds and pushes the Docker image for the $name variant"
group "Variant $name"
startParameter.projectProperties.variant = name
def taskList = ['clean', 'pushImages']
tasks = taskList
}
}
task("buildAll", type: GradleBuild) {
description "Builds the Docker images for all variants"
group "All variants"
def taskList = []
project.ext.variants.each { name, vars ->
taskList << ("build-$name" as String)
}
tasks = taskList
}
task("pushAll", type: GradleBuild) {
description "Builds and pushes the Docker images for all variants"
group "All variants"
def taskList = []
project.ext.variants.each { name, vars ->
taskList << ("push-$name" as String)
}
tasks = taskList
}
wrapper {
gradleVersion = '5.5.1'
}