-
Notifications
You must be signed in to change notification settings - Fork 32
/
build.gradle
699 lines (583 loc) · 28.6 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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
import org.gradle.internal.os.OperatingSystem
plugins {
id "de.undercouch.download" version "4.1.1"
}
ext {
ossrhUsername = project.findProperty('ossrh.username')
ossrhPassword = project.findProperty('ossrh.password')
pgVersionParam = project.findProperty('pgVersion') ?: ("${project.version}" - '-SNAPSHOT')
pgBinVersionParam = project.findProperty('pgBinVersion') ?: "${pgVersionParam}-1"
postgisVersionParam = project.findProperty('postgisVersion') ?: ''
archNameParam = project.findProperty('archName') ?: ''
distNameParam = project.findProperty('distName') ?: ''
dockerImageParam = project.findProperty('dockerImage') ?: ''
qemuPathParam = project.findProperty('qemuPath') ?: ''
pgMajorVersionParam = (pgVersionParam =~ /(\d+).+/).with { matches() ? it[0][1].toInteger() : null }
pgMinorVersionParam = (pgVersionParam =~ /\d+\.(\d+).*/).with { matches() ? it[0][1].toInteger() : null }
}
allprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
group 'io.zonky.test.postgres'
version += postgisVersionParam ? "-postgis-$postgisVersionParam" : ''
archivesBaseName = 'embedded-postgres-binaries'
sourceCompatibility = 1.6
repositories {
mavenCentral()
}
configurations {
bundles
}
}
task validateInputs {
doFirst {
println "version: ${project.version}"
println "pgVersion: $pgVersionParam"
println "pgBinVersion: $pgBinVersionParam"
if (!project.version || project.version == 'unspecified') {
throw new GradleException("The 'version' property must be set")
}
if (distNameParam && distNameParam != 'alpine') {
throw new GradleException("Currently only the 'alpine' distribution is supported")
}
if (archNameParam && !(archNameParam ==~ /^[a-z0-9]+$/)) {
throw new GradleException("The 'archName' property must contain only alphanumeric characters")
}
}
}
task downloadQemuExecutables(type: Download, dependsOn: validateInputs) {
onlyIfModified true
onlyIf { !qemuPathParam && OperatingSystem.current().isLinux() && OperatingSystem.current().getArch() == 'amd64' }
src(['arm', 'aarch64', 'ppc64le'].collect { arch ->
"https://github.com/multiarch/qemu-user-static/releases/download/v2.12.0/qemu-$arch-static"
})
overwrite false
dest file("$temporaryDir/downloads")
}
task prepareQemuExecutables(type: Copy, dependsOn: downloadQemuExecutables) {
from downloadQemuExecutables.dest
into file("$temporaryDir/executables")
fileMode = 0755
}
def repackedPlatforms = [
['name':'darwin', 'arch':'amd64'],
['name':'windows', 'arch':'amd64']
]
if (pgMajorVersionParam > 14
|| (pgMajorVersionParam == 14 && pgMinorVersionParam >= 1)) {
repackedPlatforms << ['name':'darwin', 'arch':'arm64v8']
}
if (pgMajorVersionParam < 11) {
repackedPlatforms << ['name':'windows', 'arch':'i386']
if (pgVersionParam != '9.5.19') {
repackedPlatforms << ['name':'linux', 'arch':'i386']
repackedPlatforms << ['name':'linux', 'arch':'amd64']
}
}
def debianPlatforms = [
// ['arch':'arm32v6', 'image':'resin/rpi-raspbian:jessie'],
['arch':'arm32v7'],
['arch':'arm64v8'],
['arch':'ppc64le']
]
if (pgMajorVersionParam >= 11 || pgVersionParam == '9.5.19') {
debianPlatforms << ['arch':'i386']
debianPlatforms << ['arch':'amd64']
}
def alpinePlatforms = [
['arch':'i386'],
['arch':'amd64'],
['arch':'arm32v6'],
['arch':'arm64v8'],
['arch':'ppc64le']
]
def alpineVariants = [
['name':'', 'opt':'', 'enabled': true],
['name':'lite', 'opt':'-l', 'enabled': pgMajorVersionParam >= 10 && pgMajorVersionParam < 16]
]
project(':repacked-platforms') {
if (!distNameParam && !archNameParam && !dockerImageParam && !postgisVersionParam) {
repackedPlatforms.each { platform ->
task "build${platform.arch.capitalize()}${platform.name.capitalize()}Bundle"(group: "build (${platform.arch})", type: Exec, dependsOn: validateInputs) {
inputs.property('pgBinVersionParam', pgBinVersionParam)
inputs.property('platformName', platform.name)
inputs.property('archName', platform.arch)
inputs.file("$rootDir/scripts/repack-postgres.sh")
outputs.dir("$temporaryDir/bundle")
workingDir temporaryDir
commandLine 'sh', "$rootDir/scripts/repack-postgres.sh", '-v', "$pgBinVersionParam", '-p', "${platform.name}", '-a', "${platform.arch}"
}
task "${platform.arch}${platform.name.capitalize()}Jar"(group: "build (${platform.arch})", type: Jar) {
from tasks.getByName("build${platform.arch.capitalize()}${platform.name.capitalize()}Bundle")
include "postgres-${platform.name}-${normalizeArchName(platform.arch)}.txz"
appendix = "${platform.name}-${platform.arch}"
}
task "test${platform.arch.capitalize()}${platform.name.capitalize()}Jar"(group: "build (${platform.arch})", type: LazyExec, dependsOn: [validateInputs, "${platform.arch}${platform.name.capitalize()}Jar"]) {
onlyIf {
def system = OperatingSystem.current()
return gradle.startParameter.taskNames.any { taskName -> taskName.endsWith(name) } ||
(system.isLinux() && platform.name == 'linux' && platform.arch == system.getArch()) ||
(system.isMacOsX() && platform.name == 'darwin' && platform.arch == system.getArch()) ||
(system.isWindows() && platform.name == 'windows')
}
def qemuBindings = { resolveQemuBindings() }
def dockerImage = { defaultDebianImage(platform.arch, qemuBindings()) }
inputs.property('pgVersion', pgVersionParam)
inputs.property('platformName', platform.name)
inputs.property('archName', platform.arch)
if (platform.name == 'linux') {
inputs.property('dockerImage', dockerImage)
}
inputs.file("$rootDir/scripts/test-postgres-${platform.name}.sh")
workingDir tasks.getByName("${platform.arch}${platform.name.capitalize()}Jar").destinationDirectory
if (platform.name == 'linux') {
commandLine 'sh', "$rootDir/scripts/test-postgres-${platform.name}.sh",
'-j', "embedded-postgres-binaries-${platform.name}-${platform.arch}-${version}.jar",
'-z', "postgres-${platform.name}-${normalizeArchName(platform.arch)}.txz",
'-v', "$pgVersionParam", '-i', dockerImage, '-o', qemuBindings
} else {
commandLine 'sh', "$rootDir/scripts/test-postgres-${platform.name}.sh",
'-j', "embedded-postgres-binaries-${platform.name}-${platform.arch}-${version}.jar",
'-z', "postgres-${platform.name}-${normalizeArchName(platform.arch)}.txz",
'-v', "$pgVersionParam"
}
}
artifacts.add('bundles', tasks.getByName("${platform.arch}${platform.name.capitalize()}Jar"))
}
}
}
project(':debian-platforms') {
if (!distNameParam && !archNameParam && !dockerImageParam && !postgisVersionParam) {
debianPlatforms.each { platform ->
task "build${platform.arch.capitalize()}DebianBundle"(group: "build (${platform.arch})", type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables]) {
def qemuBindings = { resolveQemuBindings() }
def dockerImage = { platform.image ?: defaultDebianImage(platform.arch, qemuBindings) }
doFirst {
println "dockerImage: ${dockerImage()}"
println "qemuBindings: ${qemuBindings()}"
println ''
}
inputs.property('pgVersion', pgVersionParam)
inputs.property('archName', platform.arch)
inputs.property('dockerImage', dockerImage)
inputs.file("$rootDir/scripts/build-postgres-debian.sh")
outputs.dir("$temporaryDir/bundle")
workingDir temporaryDir
commandLine 'sh', "$rootDir/scripts/build-postgres-debian.sh", '-v', "$pgVersionParam", '-i', dockerImage, '-o', qemuBindings
}
task "${platform.arch}DebianJar"(group: "build (${platform.arch})", type: Jar) {
from tasks.getByName("build${platform.arch.capitalize()}DebianBundle")
include "postgres-linux-debian.txz"
rename "postgres-linux-debian.txz", "postgres-linux-${normalizeArchName(platform.arch)}.txz"
appendix = "linux-${platform.arch}"
}
task "test${platform.arch.capitalize()}DebianJar"(group: "build (${platform.arch})", type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables, "${platform.arch}DebianJar"]) {
def qemuBindings = { resolveQemuBindings() }
def dockerImage = { platform.image ?: defaultDebianImage(platform.arch, qemuBindings) }
inputs.property('pgVersion', pgVersionParam)
inputs.property('archName', platform.arch)
inputs.property('dockerImage', dockerImage)
inputs.file("$rootDir/scripts/test-postgres-linux.sh")
workingDir tasks.getByName("${platform.arch}DebianJar").destinationDirectory
commandLine 'sh', "$rootDir/scripts/test-postgres-linux.sh",
'-j', "embedded-postgres-binaries-linux-${platform.arch}-${version}.jar",
'-z', "postgres-linux-${normalizeArchName(platform.arch)}.txz",
'-i', dockerImage, '-v', "$pgVersionParam", '-g', postgisVersionParam, '-o', qemuBindings
}
artifacts.add('bundles', tasks.getByName("${platform.arch}DebianJar"))
}
}
}
alpineVariants.each { variant ->
project(":alpine${variant.name ? '-' + variant.name : ''}-platforms") {
if (!distNameParam && !archNameParam && !dockerImageParam && !postgisVersionParam && variant.enabled) {
alpinePlatforms.each { platform ->
task "build${platform.arch.capitalize()}Alpine${variant.name.capitalize()}Bundle"(group: "build (${platform.arch})", type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables]) {
def qemuBindings = { resolveQemuBindings() }
def dockerImage = { platform.image ?: defaultAlpineImage(platform.arch, qemuBindings) }
doFirst {
println "dockerImage: ${dockerImage()}"
println "qemuBindings: ${qemuBindings()}"
println ''
}
inputs.property('pgVersion', pgVersionParam)
inputs.property('archName', platform.arch)
inputs.property('dockerImage', dockerImage)
inputs.file("$rootDir/scripts/build-postgres-alpine.sh")
outputs.dir("$temporaryDir/bundle")
workingDir temporaryDir
commandLine 'sh', "$rootDir/scripts/build-postgres-alpine.sh", '-v', "$pgVersionParam", '-i', dockerImage, '-o', qemuBindings, "${variant.opt}"
}
task "${platform.arch}Alpine${variant.name.capitalize()}Jar"(group: "build (${platform.arch})", type: Jar) {
from tasks.getByName("build${platform.arch.capitalize()}Alpine${variant.name.capitalize()}Bundle")
include "postgres-linux-alpine_linux.txz"
rename "postgres-linux-alpine_linux.txz", "postgres-linux-${normalizeArchName(platform.arch)}-alpine_linux.txz"
appendix = "linux-${platform.arch}-alpine${variant.name ? '-' + variant.name : ''}"
}
task "test${platform.arch.capitalize()}Alpine${variant.name.capitalize()}Jar"(group: "build (${platform.arch})", type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables, "${platform.arch}Alpine${variant.name.capitalize()}Jar"]) {
def qemuBindings = { resolveQemuBindings() }
def dockerImage = { platform.image ?: defaultAlpineImage(platform.arch, qemuBindings) }
inputs.property('pgVersion', pgVersionParam)
inputs.property('archName', platform.arch)
inputs.property('dockerImage', dockerImage)
inputs.file("$rootDir/scripts/test-postgres-alpine.sh")
workingDir tasks.getByName("${platform.arch}Alpine${variant.name.capitalize()}Jar").destinationDirectory
commandLine 'sh', "$rootDir/scripts/test-postgres-alpine.sh",
'-j', "embedded-postgres-binaries-linux-${platform.arch}-alpine${variant.name ? '-' + variant.name : ''}-${version}.jar",
'-z', "postgres-linux-${normalizeArchName(platform.arch)}-alpine_linux.txz",
'-i', dockerImage, '-v', "$pgVersionParam", '-g', postgisVersionParam, '-o', qemuBindings
}
artifacts.add('bundles', tasks.getByName("${platform.arch}Alpine${variant.name.capitalize()}Jar"))
}
}
}
}
project(':custom-debian-platform') {
if (!distNameParam && (archNameParam || dockerImageParam || postgisVersionParam)) {
def archName = archNameParam ?: 'amd64'
task buildCustomDebianBundle(group: 'build (custom)', type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables]) {
def qemuBindings = { resolveQemuBindings() }
def dockerImage = { dockerImageParam ?: defaultDebianImage(archName, qemuBindings()) }
doFirst {
println "archName: $archName"
println "distName: debian-like"
println "dockerImage: ${dockerImage()}"
println "qemuBindings: ${qemuBindings()}"
println ''
if (postgisVersionParam) {
println '===== Extensions ====='
println "postgisVersion: $postgisVersionParam"
println '======================'
println ''
}
}
inputs.property('pgVersion', pgVersionParam)
inputs.property('archName', archName)
inputs.property('dockerImage', dockerImage)
inputs.property('postgisVersion', postgisVersionParam)
inputs.file("$rootDir/scripts/build-postgres-debian.sh")
outputs.dir("$temporaryDir/bundle")
workingDir temporaryDir
commandLine 'sh', "$rootDir/scripts/build-postgres-debian.sh", '-v', "$pgVersionParam", '-i', dockerImage, '-g', postgisVersionParam, '-o', qemuBindings
}
task customDebianJar(group: 'build (custom)', type: Jar) {
from buildCustomDebianBundle
include "postgres-linux-debian.txz"
rename "postgres-linux-debian.txz", "postgres-linux-${normalizeArchName(archName)}.txz"
appendix = "linux-${archName}"
}
task testCustomDebianJar(group: 'build (custom)', type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables, customDebianJar]) {
def qemuBindings = { resolveQemuBindings() }
def dockerImage = { dockerImageParam ?: defaultDebianImage(archName, qemuBindings()) }
inputs.property('pgVersion', pgVersionParam)
inputs.property('archName', archName)
inputs.property('dockerImage', dockerImage)
inputs.property('postgisVersion', postgisVersionParam)
inputs.file("$rootDir/scripts/test-postgres-linux.sh")
workingDir customDebianJar.destinationDirectory
commandLine 'sh', "$rootDir/scripts/test-postgres-linux.sh",
'-j', "embedded-postgres-binaries-linux-${archName}-${version}.jar",
'-z', "postgres-linux-${normalizeArchName(archName)}.txz",
'-i', dockerImage, '-v', "$pgVersionParam", '-g', postgisVersionParam, '-o', qemuBindings
}
artifacts.add('bundles', tasks.getByName('customDebianJar'))
}
}
alpineVariants.each { variant ->
project(":custom-alpine${variant.name ? '-' + variant.name : ''}-platform") {
if (distNameParam == 'alpine' && variant.enabled) {
def archName = archNameParam ?: 'amd64'
task "buildCustomAlpine${variant.name.capitalize()}Bundle"(group: 'build (custom)', type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables]) {
def qemuBindings = { resolveQemuBindings() }
def dockerImage = { dockerImageParam ?: defaultAlpineImage(archName, qemuBindings) }
doFirst {
println "archName: $archName"
println "distName: alpine"
println "dockerImage: ${dockerImage()}"
println "qemuBindings: ${qemuBindings()}"
println ''
if (postgisVersionParam) {
println '===== Extensions ====='
println "postgisVersion: $postgisVersionParam"
println '======================'
println ''
}
}
inputs.property('pgVersion', pgVersionParam)
inputs.property('archName', archName)
inputs.property('dockerImage', dockerImage)
inputs.property('postgisVersion', postgisVersionParam)
inputs.file("$rootDir/scripts/build-postgres-alpine.sh")
outputs.dir("$temporaryDir/bundle")
workingDir temporaryDir
commandLine 'sh', "$rootDir/scripts/build-postgres-alpine.sh", '-v', "$pgVersionParam", '-i', dockerImage, '-g', postgisVersionParam, '-o', qemuBindings, "${variant.opt}"
}
task "customAlpine${variant.name.capitalize()}Jar"(group: 'build (custom)', type: Jar) {
from tasks.getByName("buildCustomAlpine${variant.name.capitalize()}Bundle")
include "postgres-linux-alpine_linux.txz"
rename "postgres-linux-alpine_linux.txz", "postgres-linux-${normalizeArchName(archName)}-alpine_linux.txz"
appendix = "linux-${archName}-alpine${variant.name ? '-' + variant.name : ''}"
}
task "testCustomAlpine${variant.name.capitalize()}Jar"(group: 'build (custom)', type: LazyExec, dependsOn: [validateInputs, prepareQemuExecutables, "customAlpine${variant.name.capitalize()}Jar"]) {
def qemuBindings = { resolveQemuBindings() }
def dockerImage = { dockerImageParam ?: defaultAlpineImage(archName, qemuBindings) }
inputs.property('pgVersion', pgVersionParam)
inputs.property('archName', archName)
inputs.property('dockerImage', dockerImage)
inputs.property('postgisVersion', postgisVersionParam)
inputs.file("$rootDir/scripts/test-postgres-alpine.sh")
workingDir tasks.getByName("customAlpine${variant.name.capitalize()}Jar").destinationDirectory
commandLine 'sh', "$rootDir/scripts/test-postgres-alpine.sh",
'-j', "embedded-postgres-binaries-linux-${archName}-alpine${variant.name ? '-' + variant.name : ''}-${version}.jar",
'-z', "postgres-linux-${normalizeArchName(archName)}-alpine_linux.txz",
'-i', dockerImage, '-v', "$pgVersionParam", '-g', postgisVersionParam, '-o', qemuBindings
}
artifacts.add('bundles', tasks.getByName("customAlpine${variant.name.capitalize()}Jar"))
}
}
}
subprojects {
task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
classifier = 'javadoc'
}
publishing {
publications {
configurations.bundles.artifacts.all { archive ->
def publicationName = archive.archiveTask.name - 'Jar'
"$publicationName"(MavenPublication) {
artifactId "${archive.name}"
configurePom(pom, artifactId, 'A lightweight bundle of PostgreSQL database with reduced size')
artifact archive
artifact sourcesJar
artifact javadocJar
}
}
}
}
}
publishing {
publications {
if (!distNameParam && !archNameParam && !dockerImageParam) {
bom(MavenPublication) {
artifactId 'embedded-postgres-binaries-bom'
configurePom(pom, artifactId, 'Bill of Materials')
pom.withXml {
def root = asNode()
root.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
dependencyManagement {
dependencies {
project.subprojects.collectMany { it.configurations.bundles.artifacts }
.sort { archive ->
archive.name.replaceFirst(/^embedded-postgres-binaries-([^-]+-([^-]+).*)$/, { all, suffix, arch ->
['amd64', 'i386'].indexOf(arch).with { it != -1 ? it : 9 } + suffix
})
}
.each { archive ->
dependency {
groupId "${project.group}"
artifactId "${archive.name}"
version "${project.version}"
if (!archive.name.contains('amd64') || archive.name.contains('lite')) {
optional 'true'
}
}
}
}
}
}
}
}
}
}
}
allprojects {
publishing {
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("publish") }
def signingKey = findProperty("signingKey")
def signingKeyId = findProperty("signingKeyId")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
publishing.publications.all { publication ->
sign publication
}
}
task install(group: 'publishing') {}
configurations.bundles.artifacts.all { archive ->
def publicationName = archive.archiveTask.name - 'Jar'
jar.dependsOn "${archive.archiveTask.name}"
test.dependsOn "test${archive.archiveTask.name.capitalize()}"
install.dependsOn "publish${publicationName.capitalize()}PublicationToMavenLocal"
}
task uploadArchives(group: 'publishing') {
dependsOn publish
}
tasks.whenTaskAdded { task ->
if (task.name == 'publishBomPublicationToMavenLocal') {
install.dependsOn task
}
}
}
def configurePom(pom, artifact, desc) {
pom.withXml {
def root = asNode()
root.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name artifact
description desc
url 'https://github.com/zonkyio/embedded-postgres-binaries'
scm {
connection 'scm:git:git://github.com/zonkyio/embedded-postgres-binaries.git'
developerConnection 'scm:git:ssh://github.com:zonkyio/embedded-postgres-binaries.git'
url 'https://github.com/zonkyio/embedded-postgres-binaries/tree/master'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
name 'Tomas Vanek'
email 'tomix26@gmail.com'
}
developer {
name 'Zonky Developers'
email 'developers@zonky.cz'
}
}
}
}
}
def resolveQemuBindings() {
def bindings = fileTree(dir:"${qemuPathParam ? qemuPathParam : '/usr/bin'}", includes:['qemu-*-static']).getFiles()
if (!bindings && !qemuPathParam) {
bindings = fileTree(dir:prepareQemuExecutables.destinationDir, includes:['qemu-*-static']).getFiles()
}
return bindings.collect { "-v ${it.path}:/usr/bin/${it.name}" }.join(' ')
}
static def defaultDebianImage(archName, useEmulation) {
def system = OperatingSystem.current()
if (archName == system.getArch()) {
return 'ubuntu:18.04'
} else if (system.isMacOsX() || useEmulation) {
return "$archName/ubuntu:18.04"
} else if (system.isLinux()) {
def archMappings = ['arm32v6':'armel', 'arm32v7':'armhf', 'arm64v8':'arm64', 'ppc64le':'ppc64el']
return "multiarch/ubuntu-core:${archMappings[archName] ?: archName}-bionic"
} else {
throw new GradleException("Cross-building is not supported on the current platform: $system")
}
}
static def defaultAlpineImage(archName, useEmulation) {
def system = OperatingSystem.current()
if (archName == system.getArch()) {
return 'alpine:3.6'
} else if (system.isMacOsX() || useEmulation) {
return "$archName/alpine:3.6"
} else if (system.isLinux()) {
def archMappings = ['arm32v5':'armel', 'arm32v6':'armhf', 'arm64v8':'arm64']
return "multiarch/alpine:${archMappings[archName] ?: archName}-v3.6"
} else {
throw new GradleException("Cross-building is not supported on the current platform: $system")
}
}
static def normalizeArchName(String input) {
String arch = input.toLowerCase(Locale.US).replaceAll('[^a-z0-9]+', '')
if (arch ==~ /^(x8664|amd64|ia32e|em64t|x64)$/) {
return 'x86_64'
}
if (arch ==~ /^(x8632|x86|i[3-6]86|ia32|x32)$/) {
return 'x86_32'
}
if (arch ==~ /^(ia64w?|itanium64)$/) {
return 'itanium_64'
}
if (arch == 'ia64n') {
return 'itanium_32'
}
if (arch ==~ /^(sparcv9|sparc64)$/) {
return 'sparc_64'
}
if (arch ==~ /^(sparc|sparc32)$/) {
return 'sparc_32'
}
if (arch ==~ /^(aarch64|armv8|arm64).*$/) {
return 'arm_64'
}
if (arch ==~ /^(arm|arm32).*$/) {
return 'arm_32'
}
if (arch ==~ /^(mips|mips32)$/) {
return 'mips_32'
}
if (arch ==~ /^(mipsel|mips32el)$/) {
return 'mipsel_32'
}
if (arch == 'mips64') {
return 'mips_64'
}
if (arch == 'mips64el') {
return 'mipsel_64'
}
if (arch ==~ /^(ppc|ppc32)$/) {
return 'ppc_32'
}
if (arch ==~ /^(ppcle|ppc32le)$/) {
return 'ppcle_32'
}
if (arch == 'ppc64') {
return 'ppc_64'
}
if (arch == 'ppc64le') {
return 'ppcle_64'
}
if (arch == 's390') {
return 's390_32'
}
if (arch == 's390x') {
return 's390_64'
}
throw new GradleException("Unsupported architecture: $arch")
}
class LazyExec extends AbstractExecTask<LazyExec> {
LazyExec() {
super(LazyExec.class)
}
@Override
LazyExec commandLine(Object... arguments) {
return super.commandLine(arguments.collect { argument ->
if (argument instanceof Closure) {
Closure closure = (Closure) argument;
return new Object() {
@Override
String toString() {
return closure()
}
}
} else {
return argument
}
}) as LazyExec
}
}