forked from Consensys/teku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
657 lines (562 loc) · 21.1 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
import java.text.SimpleDateFormat
plugins {
id 'com.diffplug.gradle.spotless' version '3.26.0'
id 'com.jfrog.bintray' version '1.8.4'
id 'com.github.ben-manes.versions' version '0.27.0'
id 'com.github.hierynomus.license' version '0.15.0'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'net.ltgt.errorprone' version '1.1.1' apply false
id 'net.researchgate.release' version '2.8.1'
id 'me.champeau.gradle.jmh' version '0.5.0' apply false
id 'de.undercouch.download' version '4.0.1'
id 'org.ajoberstar.grgit' version '4.0.2'
}
apply plugin: 'application'
defaultTasks 'build','checkLicenses'
def buildAliases = [
'dev': [
'compileJava',
'compileTestJava',
'compileJmhJava',
'compileIntegrationTestJava',
'compileCompatibilityTestJava',
'compileReferenceTestJava',
'spotlessApply',
'build',
'checkLicenses',
// TODO - Fix javadoc task
/*'javadoc'*/],
'mash': [
'clean',
'spotlessApply',
'build',
'test']
]
def expandedTaskList = []
gradle.startParameter.taskNames.each {
expandedTaskList << (buildAliases[it] ? buildAliases[it] : it)
}
gradle.startParameter.taskNames = expandedTaskList.flatten() as Iterable<String>
def userHome = System.getProperty("user.home")
apply plugin: 'com.jfrog.bintray'
def bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
def bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_KEY')
def bintrayPackage = bintray.pkg {
repo = 'pegasys-repo'
name = 'teku'
userOrg = 'consensys'
desc = 'Java Implementation of the Ethereum 2.0 Beacon Chain'
licenses = ['Apache-2.0']
websiteUrl = 'https://github.com/PegaSysEng/teku'
issueTrackerUrl = 'https://github.com/PegaSysEng/teku/issues'
vcsUrl = 'https://github.com/PegaSysEng/teku.git'
version {
name = project.version
released = new Date()
}
}
allprojects {
apply plugin: 'java-library'
apply plugin: 'java-test-fixtures'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
apply plugin: 'net.ltgt.errorprone'
apply from: "${rootDir}/gradle/versions.gradle"
apply from: "${rootDir}/gradle/check-licenses.gradle"
version = rootProject.version
jacoco { toolVersion = '0.8.5' }
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
sourceCompatibility = '11'
targetCompatibility = '11'
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url "https://hyperledger-org.bintray.com/besu-repo/" }
maven { url "https://consensys.bintray.com/pegasys-repo/" }
}
dependencies {
errorprone("com.google.errorprone:error_prone_core")
}
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
java {
// This path needs to be relative to each project
target fileTree('.') {
include '**/*.java'
exclude '**/.gradle/**'
exclude 'web3j'
//Excluding tech.pegasys.teku.datastructures due to preferred formatting overwritten by plugin in getConstantsAsString.
exclude '**/src/main/java/tech/pegasys/teku/Constants.java'
exclude '**/proto'
exclude '**/resources'
}
importOrder 'tech.pegasys', 'net.consensys', 'java', ''
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile "${rootDir}/gradle/spotless.java.license"
googleJavaFormat('1.7')
}
}
tasks.withType(JavaCompile) {
options.compilerArgs += [
'-Xlint:unchecked',
'-Xlint:cast',
'-Xlint:rawtypes',
'-Xlint:overloads',
'-Xlint:divzero',
'-Xlint:finally',
'-Xlint:static',
'-Werror',
]
options.errorprone {
disableWarningsInGeneratedCode
// Our equals need to be symmetric, this checker doesn't respect that.
check('EqualsGetClass', net.ltgt.gradle.errorprone.CheckSeverity.OFF)
// We use the JSR-305 annotations instead of the Google annotations.
check('ImmutableEnumChecker', net.ltgt.gradle.errorprone.CheckSeverity.OFF)
check('FieldCanBeFinal', net.ltgt.gradle.errorprone.CheckSeverity.OFF)
check('InsecureCryptoUsage', net.ltgt.gradle.errorprone.CheckSeverity.WARN)
check('WildcardImport', net.ltgt.gradle.errorprone.CheckSeverity.WARN)
// This check is broken in Java 12. See https://github.com/google/error-prone/issues/1257
if (JavaVersion.current() == JavaVersion.VERSION_12) {
check('Finally', net.ltgt.gradle.errorprone.CheckSeverity.OFF)
}
// This check is broken after Java 12. See https://github.com/google/error-prone/issues/1352
if (JavaVersion.current() > JavaVersion.VERSION_12) {
check('TypeParameterUnusedInFormals', net.ltgt.gradle.errorprone.CheckSeverity.OFF)
}
}
options.encoding = 'UTF-8'
}
/*
* Pass some system properties provided on the gradle command line to test executions for
* convenience.
*
* The properties passed are:
* - 'test.ethereum.include': allows to run a single Ethereum reference tests. For instance,
* running a single general state test can be done with:
* ./gradlew :ethereum:tech.pegasys.teku.ethereum.vm:test -Dtest.single=GeneralStateTest -Dtest.ethereum.include=callcodecallcallcode_101-Frontier
* The meaning being that will be run only the tests for which the value passed as "include"
* (which can be a java pattern) matches parts of the test name. Knowing that tests names for
* reference tests are of the form:
* <name>(-<milestone>([<variant>])?)?
* where <name> is the test name as defined in the json file (usually the name of the json file
* as well), <milestone> is the Ethereum milestone tested (not all test use it) and <variant>
* is only use in some general state tests where for the same json file and same milestone,
* multiple variant of that test are run. The variant is a simple number.
* - 'test.ethereum.state.eip': for general state tests, allows to only run tests for the
* milestone specified by this value. So for instance,
* ./gradlew :ethereum:tech.pegasys.teku.ethereum.vm:test -Dtest.single=GeneralStateTest -Dtest.ethereum.state.eip=Frontier
* only run general state tests for Frontier. Note that this behavior could be achieved as well
* with the 'include' option above since it is a pattern, but this is a slightly more convenient
* option.
* - 'root.log.level' and 'evm.log.level': allow to control the log level used during the tests.
*/
test {
jvmArgs = [
'-Xmx4g',
'-XX:-UseGCOverheadLimit'
]
Set toImport = [
'test.ethereum.include',
'test.ethereum.state.eip',
'root.log.level',
'evm.log.level'
]
testLogging.showStandardStreams = true
for (String name : toImport) {
if (System.getProperty(name) != null) {
systemProperty name, System.getProperty(name)
}
}
}
// Normalize Xdoclint behaviour across JDKs (OpenJDK 8 is more lenient than Oracle JDK by default).
javadoc {
options.addStringOption('Xdoclint:all', '-quiet')
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
options.addStringOption('Xwerror', '-quiet')
} else {
options.addStringOption('Xwerror', '-html5')
}
options.encoding = 'UTF-8'
}
}
def refTestVersion = 'v0.11.1'
def refTestBaseUrl = 'https://github.com/ethereum/eth2.0-spec-tests/releases/download'
def refTestDownloadDir = "${buildDir}/refTests/${refTestVersion}"
def refTestExpandDir = "${project.rootDir}/eth-reference-tests/src/referenceTest/resources/eth2.0-spec-tests/"
task downloadRefTests(type: Download) {
src([
"${refTestBaseUrl}/${refTestVersion}/general.tar.gz",
"${refTestBaseUrl}/${refTestVersion}/minimal.tar.gz",
"${refTestBaseUrl}/${refTestVersion}/mainnet.tar.gz"
])
dest "${refTestDownloadDir}"
overwrite false
}
task cleanRefTestsGeneral(type: Delete) {
delete "${refTestExpandDir}/tests/general"
}
task expandRefTestsGeneral(type: Copy, dependsOn: [cleanRefTestsGeneral, downloadRefTests]) {
from tarTree("${refTestDownloadDir}/general.tar.gz")
into refTestExpandDir
}
task cleanRefTestsMainnet(type: Delete) {
delete "${refTestExpandDir}/tests/mainnet"
}
task expandRefTestsMainnet(type: Copy, dependsOn: [cleanRefTestsMainnet, downloadRefTests]) {
from tarTree("${refTestDownloadDir}/mainnet.tar.gz")
into refTestExpandDir
}
task cleanRefTestsMinimal(type: Delete) {
delete "${refTestExpandDir}/tests/minimal"
}
task expandRefTestsMinimal(type: Copy, dependsOn: [cleanRefTestsMinimal, downloadRefTests]) {
from tarTree("${refTestDownloadDir}/minimal.tar.gz")
into refTestExpandDir
}
task expandRefTests(dependsOn: [expandRefTestsGeneral, expandRefTestsMainnet, expandRefTestsMinimal])
task cleanRefTests(dependsOn: [cleanRefTestsGeneral, cleanRefTestsMainnet, cleanRefTestsMinimal])
task deploy() {}
installDist { }
distTar {
dependsOn checkLicenses
doFirst {
delete fileTree(dir: 'build/distributions', include: '*.tar.gz')
}
compression = Compression.GZIP
extension = 'tar.gz'
}
distZip {
dependsOn checkLicenses
doFirst {
delete fileTree(dir: 'build/distributions', include: '*.zip')
}
}
application {
applicationName = "teku"
mainClassName = "tech.pegasys.teku.Teku"
applicationDefaultJvmArgs = [
"-Djava.library.path=TEKU_HOME/native",
"-Dvertx.disableFileCPResolving=true",
"-Dteku.home=TEKU_HOME",
// We shutdown log4j ourselves, as otherwise his shutdown hook runs before our own and whatever
// happens during shutdown is not logged.
"-Dlog4j.shutdownHookEnabled=false"
]
}
// rename the top level dir from teku-<version> to teku and this makes it really
// simple for use in docker
tasks.register("dockerDistUntar") {
dependsOn distTar
def dockerBuildPath = "build/docker-teku/"
def distTarFile = distTar.outputs.files.singleFile
def distTarFileName = distTar.outputs.files.singleFile.name.replace(".tar.gz", "")
doFirst {
def dockerBuildDir = new File(dockerBuildPath)
dockerBuildDir.deleteDir()
dockerBuildDir.mkdir()
copy {
from tarTree(distTarFile)
into(dockerBuildPath)
}
def dockerDist = file("${dockerBuildPath}/${distTarFileName}")
dockerDist.renameTo("${dockerBuildPath}/teku")
}
}
task distDocker(type: Exec) {
dependsOn dockerDistUntar
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}"
def image = "pegasyseng/teku:develop"
def dockerBuildDir = "build/docker-teku/"
workingDir "${dockerBuildDir}"
doFirst {
copy {
from file("${projectDir}/docker/Dockerfile")
into(workingDir)
}
}
executable "sh"
args "-c", "docker build --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ."
}
subprojects {
tasks.withType(Test) {
// If GRADLE_MAX_TEST_FORKS is not set, use half the available processors
maxParallelForks = (System.getenv('GRADLE_MAX_TEST_FORKS') ?: (Runtime.runtime.availableProcessors().intdiv(2) ?: 1)).toInteger()
useJUnitPlatform()
reports {
junitXml.enabled = true
}
}
tasks.withType(JavaCompile) {
options.fork = true
options.incremental = true
}
sourceSets {
integrationTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/integration-test/java')
}
resources.srcDir file('src/integration-test/resources')
}
acceptanceTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/acceptance-test/java')
}
resources.srcDir file('src/acceptance-test/resources')
}
compatibilityTest {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDir file('src/compatibility-test/java')
}
resources.srcDir file('src/compatibility-test/resources')
}
referenceTest {
java {
srcDir file('src/referenceTest/java')
}
resources.srcDir file('src/referenceTest/resources')
}
}
def sourceSetIsPopulated = { sourceSetName ->
def result = project.sourceSets.names.contains(sourceSetName) && !project.sourceSets.getAt(sourceSetName).allSource.empty
logger.info("Project = " + project.name + " Has Source Set (" + sourceSetName + ") = " + result + "(" + project.sourceSets.names + ")")
return result
}
if (sourceSetIsPopulated("main") || sourceSetIsPopulated("testFixtures")) {
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
groupId "tech.pegasys.teku.internal"
version "${project.version}"
if (sourceSetIsPopulated("main")) {
from components.java
artifact sourcesJar
}
versionMapping {
usage('java-api') { fromResolutionOf('runtimeClasspath') }
usage('java-runtime') { fromResolutionResult() }
}
pom {
name = "Teku - ${project.name}"
url = 'https://github.com/PegaSysEng/teku'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
scm {
connection = 'scm:git:git://github.com/PegaSysEng/teku.git'
developerConnection = 'https://github.com/PegaSysEng/teku.git'
url = 'https://github.com/PegaSysEng/teku'
}
}
}
}
}
bintray {
user = bintrayUser
key = bintrayKey
publications = ['mavenJava']
override = version.endsWith('SNAPSHOT')
publish = true
pkg = bintrayPackage
}
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
acceptanceTestImplementation.extendsFrom testImplementation
compatibilityTestImplementation.extendsFrom testImplementation
referenceTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
acceptanceTestRuntimeOnly.extendsFrom testRuntimeOnly
compatibilityTestRuntimeOnly.extendsFrom testRuntimeOnly
referenceTestRuntimeOnly.extendsFrom testRuntimeOnly
}
def jarName = project.name
def parent = project.parent
while (parent != null) {
if (parent != rootProject || jarName != 'teku') {
jarName = parent.name + '-' + jarName
}
parent = parent.parent
}
jar {
baseName jarName
manifest {
attributes(
'Specification-Title': jarName,
'Specification-Version': project.version,
'Implementation-Title': jarName,
'Implementation-Version': calculateVersion()
)
}
}
dependencies {
implementation 'com.google.guava:guava'
implementation 'org.apache.commons:commons-lang3'
implementation 'org.apache.logging.log4j:log4j-api'
runtimeOnly 'org.apache.logging.log4j:log4j-core'
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl'
testImplementation 'org.apache.tuweni:tuweni-junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.junit.jupiter:junit-jupiter-params'
testRuntimeOnly testFixtures(project(':logging'))
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testFixturesImplementation 'org.assertj:assertj-core'
}
task integrationTest(type: Test, dependsOn:["compileIntegrationTestJava"]){
group = "verification"
description = "Runs the Teku integration tests"
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
}
task acceptanceTest(type: Test, dependsOn:["compileAcceptanceTestJava", rootProject.distDocker]){
group = "verification"
description = "Runs the Teku acceptance tests"
systemProperty "teku.testArtifactDir", new File(project.buildDir, "test-artifacts").getAbsolutePath()
testClassesDirs = sourceSets.acceptanceTest.output.classesDirs
classpath = sourceSets.acceptanceTest.runtimeClasspath
}
task compatibilityTest(type: Test, dependsOn:["compileCompatibilityTestJava"]){
group = "verification"
description = "Runs the Teku compatibility tests"
testClassesDirs = sourceSets.compatibilityTest.output.classesDirs
classpath = sourceSets.compatibilityTest.runtimeClasspath
}
task referenceTest(type: Test, dependsOn:["compileReferenceTestJava"]){
group = "verification"
description = "Runs the Teku reference tests"
testClassesDirs = sourceSets.referenceTest.output.classesDirs
classpath = sourceSets.referenceTest.runtimeClasspath
}
}
jar { enabled = false }
run {
if(project.hasProperty('generateFlow')){
def flowJVMArgs = [
"-javaagent:${userHome}/.flow/resources/javaagent.jar",
"-Dflow.agent.include=tech.pegasys.teku,tech.pegasys.teku.services.beaconchain,tech.pegasys.teku.statetransition,tech.pegasys.teku.statetransition.util",
"-Dflow.agent.exclude=tech.pegasys.teku.datastructures.state,tech.pegasys.teku.datastructures.blocks,tech.pegasys.teku.datastructures.operations,tech.pegasys.teku.datastructures.util.bitwise,tech.pegasys.teku.util.hashtree,tech.pegasys.teku.util.alogger,tech.pegasys.teku.storage,tech.pegasys.teku.util.bls,tech.pegasys.teku.util.mikuli,tech.pegasys.teku.networking.p2p,tech.pegasys.teku.validator.coordinator",
"-Dflow.agent.autostart",
"-Dflow.agent.execution-name=teku"
]
applicationDefaultJvmArgs.addAll(flowJVMArgs)
}
args project.hasProperty("teku.run.args") ? project.property("teku.run.args").toString().split("\\s+") : []
doFirst {
applicationDefaultJvmArgs = applicationDefaultJvmArgs.collect{it.replace('TEKU_HOME', "$buildDir/teku")}
}
}
startScripts {
doLast {
unixScript.text = unixScript.text.replace('TEKU_HOME', '\$APP_HOME').replace('APP_NAME=', 'export LD_LIBRARY_PATH="\$APP_HOME/native:\$LD_LIBRARY_PATH"\nAPP_NAME=')
windowsScript.text = windowsScript.text.replace('TEKU_HOME', '%~dp0..')
}
}
dependencies {
compile project(':teku')
errorprone 'com.google.errorprone:error_prone_core'
}
distributions {
main {
contents {
from("./LICENSE") { into "." }
from("build/reports/license/license-dependency.html") { into "." }
from("libs") { into "native" }
}
}
}
// http://label-schema.org/rc1/
// using the RFC3339 format "2016-04-12T23:20:50.52Z"
def buildTime() {
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
// Takes the version, and if -SNAPSHOT is part of it replaces SNAPSHOT
// with the git commit version.
def calculateVersion() {
String version = rootProject.version
if (version.endsWith("-SNAPSHOT")) {
version = version.replace("-SNAPSHOT", "-dev-" + getCheckedOutGitCommitHash())
}
return version
}
def getCheckedOutGitCommitHash() {
def takeFromHash = 8
grgit.head().id.take(takeFromHash)
}
task jacocoRootReport(type: JacocoReport) {
additionalSourceDirs.from = files(subprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories.from = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories.from = files(subprojects.sourceSets.main.output)
executionData.from = files(subprojects.jacocoTestReport.executionData) //how to exclude some package/classes com.test.**
reports {
xml.enabled true
csv.enabled true
html.destination file("build/reports/jacocoHtml")
}
onlyIf = { true }
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}
configurations { annotationProcessor }
// Prevent errorprone-checks being dependent upon errorprone-checks!
// However, ensure all subprojects comply with the custom rules.
configure(subprojects.findAll {it.name != 'errorprone-checks'}) {
dependencies { annotationProcessor project(":errorprone-checks") }
tasks.withType(JavaCompile) {
options.annotationProcessorPath = configurations.annotationProcessor
}
}
bintray {
user = bintrayUser
key = bintrayKey
filesSpec {
from distTar.destinationDir.path
from distZip.destinationDir.path
into '.'
}
publish = true
override = version.endsWith('SNAPSHOT')
pkg = bintrayPackage
}
bintrayUpload.mustRunAfter(distTar)
bintrayUpload.mustRunAfter(distZip)
task dockerUpload(type: Exec) {
dependsOn([distDocker])
def imageRepos = 'pegasyseng'
def imageName = "${imageRepos}/teku"
def image = "${imageName}:develop"
def cmd = []
def additionalTags = ["${rootProject.version}"]
if (project.hasProperty('branch') && project.property('branch') == 'master') {
additionalTags.add('develop')
}
if (!(version ==~ /.*-SNAPSHOT/)) {
additionalTags.add('latest')
additionalTags.add(version.split(/\./)[0..1].join('.'))
}
additionalTags.each { tag ->
cmd.add("docker tag '${image}' '${imageName}:${tag.trim()}' && docker push '${imageName}:${tag.trim()}'")
}
executable "sh"
args '-c', cmd.join(' && ')
}