forked from kestra-io/kestra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
842 lines (712 loc) · 30.8 KB
/
Copy pathbuild.gradle
File metadata and controls
842 lines (712 loc) · 30.8 KB
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
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
import net.e175.klaus.zip.ZipPrefixer
import org.owasp.dependencycheck.gradle.extension.AnalyzerExtension
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "net.e175.klaus:zip-prefixer:0.4.0"
}
}
plugins {
// micronaut
id "java"
id 'java-library'
id "idea"
id "com.gradleup.shadow" version "9.6.1"
id "application"
// test
id "com.adarshr.test-logger" version "4.0.0"
id "org.sonarqube" version "7.4.0.8496"
id 'jacoco-report-aggregation'
// release
id 'net.researchgate.release' version '3.1.0'
id "com.gorylenko.gradle-git-properties" version "4.0.1"
id 'signing'
id "com.vanniktech.maven.publish" version "0.37.0"
// OWASP dependency check
id "org.owasp.dependencycheck" version "12.2.2" apply false
// Formatting
id "io.kestra.gradle.spotless-conventions" version "1.2.6"
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
/**********************************************************************************************************************\
* Main
**********************************************************************************************************************/
final mainClassName = "io.kestra.cli.Kestra"
application {
mainClass = mainClassName
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
dependencies {
implementation project(":cli")
testImplementation project(":cli")
}
/**********************************************************************************************************************\
* Dependencies
**********************************************************************************************************************/
allprojects {
tasks.withType(GenerateModuleMetadata).configureEach {
suppressedValidationErrors.add('enforced-platform')
}
if (it.name != 'platform') {
group = "io.kestra"
// Formatting
apply plugin: "io.kestra.gradle.spotless-conventions"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
repositories {
mavenCentral()
mavenLocal()
}
// micronaut
apply plugin: "java"
apply plugin: "java-library"
apply plugin: "idea"
apply plugin: "jacoco"
configurations {
developmentOnly // for dependencies that are needed for development only
micronaut
}
// dependencies
dependencies {
// Platform
annotationProcessor enforcedPlatform(project(":platform"))
implementation enforcedPlatform(project(":platform"))
api enforcedPlatform(project(":platform"))
micronaut enforcedPlatform(project(":platform"))
// lombok
annotationProcessor "org.projectlombok:lombok"
compileOnly 'org.projectlombok:lombok'
// micronaut
annotationProcessor "io.micronaut:micronaut-inject-java"
annotationProcessor "io.micronaut.validation:micronaut-validation-processor"
micronaut "io.micronaut:micronaut-inject"
micronaut "io.micronaut.validation:micronaut-validation"
micronaut "io.micronaut.beanvalidation:micronaut-hibernate-validator"
micronaut "io.micronaut:micronaut-runtime"
micronaut "io.micronaut:micronaut-retry"
micronaut "io.micronaut:micronaut-jackson-databind"
micronaut "io.micronaut.data:micronaut-data-model"
micronaut "io.micronaut:micronaut-management"
micronaut "io.micrometer:micrometer-core"
micronaut "io.micronaut.micrometer:micronaut-micrometer-registry-prometheus"
micronaut "io.micronaut:micronaut-http-client"
micronaut "io.micronaut.reactor:micronaut-reactor-http-client"
micronaut "io.micronaut.tracing:micronaut-tracing-opentelemetry-http"
// logs
implementation "org.slf4j:slf4j-api"
implementation "ch.qos.logback:logback-classic"
implementation "org.codehaus.janino:janino"
implementation "org.apache.logging.log4j:log4j-to-slf4j"
implementation "org.slf4j:jul-to-slf4j"
implementation "org.slf4j:jcl-over-slf4j"
implementation "org.fusesource.jansi:jansi"
// OTEL
implementation "io.opentelemetry:opentelemetry-exporter-otlp"
// jackson
implementation "com.fasterxml.jackson.core:jackson-core"
implementation "com.fasterxml.jackson.core:jackson-databind"
implementation "com.fasterxml.jackson.core:jackson-annotations"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml"
implementation "com.fasterxml.jackson.module:jackson-module-parameter-names"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-guava"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
implementation "com.fasterxml.uuid:java-uuid-generator"
// kestra
implementation "com.devskiller.friendly-id:friendly-id"
implementation ("net.thisptr:jackson-jq") {
exclude group: 'com.fasterxml.jackson.core'
}
// exposed utils
api "com.google.guava:guava"
api "commons-io:commons-io"
api "org.apache.commons:commons-lang3"
api "io.swagger.core.v3:swagger-annotations"
api "com.google.code.findbugs:jsr305" // brings @CheckReturnValue and already in path in core
}
}
}
/**********************************************************************************************************************\
* Test
**********************************************************************************************************************/
subprojects {subProj ->
if (subProj.name != 'platform' && subProj.name != 'jmh-benchmarks') {
apply plugin: "com.adarshr.test-logger"
apply plugin: 'jacoco'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
configurations {
mockitoAgent
// Exposes this project's compiled test classes/resources to other projects, replacing the
// Gradle 9.5-incompatible `project(':x').sourceSets.test.output` cross-project script access.
testArtifacts {
canBeConsumed = true
canBeResolved = false
}
}
artifacts {
sourceSets.test.output.files.each { dir ->
testArtifacts(dir) { builtBy tasks.named('testClasses') }
}
}
dependencies {
// Platform
testAnnotationProcessor enforcedPlatform(project(":platform"))
testImplementation enforcedPlatform(project(":platform"))
// lombok
testAnnotationProcessor "org.projectlombok:lombok:"
testCompileOnly 'org.projectlombok:lombok'
// micronaut
testAnnotationProcessor "io.micronaut:micronaut-inject-java"
testAnnotationProcessor "io.micronaut.validation:micronaut-validation-processor"
testImplementation "io.micronaut.test:micronaut-test-junit5"
testImplementation "org.junit.jupiter:junit-jupiter-engine"
testImplementation "org.junit.jupiter:junit-jupiter-params"
testImplementation "org.junit-pioneer:junit-pioneer"
testImplementation 'org.mockito:mockito-junit-jupiter'
mockitoAgent("org.mockito:mockito-core:5.23.0") {
transitive = false // just the core
}
// hamcrest
testImplementation 'org.hamcrest:hamcrest'
testImplementation 'org.hamcrest:hamcrest-library'
testImplementation 'org.exparity:hamcrest-date'
//assertj
testImplementation 'org.assertj:assertj-core'
// awaitility
testImplementation 'org.awaitility:awaitility'
}
def commonTestConfig = { Test t ->
t.timeout = java.time.Duration.ofMinutes(
(System.getenv('GRADLE_TEST_TIMEOUT_MIN') ?: '30').toInteger()
)
t.finalizedBy jacocoTestReport
t.doFirst {
logger.lifecycle("[TASK START] ${t.path}")
}
t.doLast {
logger.lifecycle("[TASK END] ${t.path}")
}
// set Xmx for test workers
t.maxHeapSize = '4g'
// configure en_US default locale for tests
t.systemProperty 'user.language', 'en'
t.systemProperty 'user.country', 'US'
t.environment 'SECRET_MY_SECRET', "{\"secretKey\":\"secretValue\"}".bytes.encodeBase64().toString()
t.environment 'SECRET_NEW_LINE', "cGFzc3dvcmR2ZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2ZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2\nZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2ZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2ZXJ5dmVyeXZl\neXJsb25n"
t.environment 'SECRET_WEBHOOK_KEY', "secretKey".bytes.encodeBase64().toString()
t.environment 'SECRET_NON_B64_SECRET', "some secret value"
t.environment 'SECRET_PASSWORD', "cGFzc3dvcmQ="
t.environment 'ENV_TEST1', "true"
t.environment 'ENV_TEST2', "Pass by env"
}
tasks.register('integrationTest', Test) { Test t ->
description = 'Runs integration tests'
group = 'verification'
useJUnitPlatform {
includeTags 'integration'
}
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
reports {
junitXml.required = true
junitXml.outputPerTestCase = true
junitXml.mergeReruns = true
junitXml.includeSystemErrLog = true
junitXml.outputLocation = layout.buildDirectory.dir("test-results/test")
}
// Integration tests typically not parallel (but you can enable)
maxParallelForks = 1
commonTestConfig(t)
}
tasks.register('unitTest', Test) { Test t ->
description = 'Runs unit tests'
group = 'verification'
useJUnitPlatform {
excludeTags 'flaky', 'integration'
}
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
reports {
junitXml.required = true
junitXml.outputPerTestCase = true
junitXml.mergeReruns = true
junitXml.includeSystemErrLog = true
junitXml.outputLocation = layout.buildDirectory.dir("test-results/test")
}
commonTestConfig(t)
}
tasks.register('flakyTest', Test) { Test t ->
group = 'verification'
description = 'Runs tests tagged @Flaky but does not fail the build.'
useJUnitPlatform {
includeTags 'flaky'
}
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
reports {
junitXml.required = true
junitXml.outputPerTestCase = true
junitXml.mergeReruns = true
junitXml.includeSystemErrLog = true
junitXml.outputLocation = layout.buildDirectory.dir("test-results/flakyTest")
}
commonTestConfig(t)
t.ignoreFailures = true
t.filter { failOnNoMatchingTests = false }
t.outputs.doNotCacheIf("Flaky tests are non-deterministic") { true }
t.mustRunAfter(tasks.named('test'))
}
// test task (default)
tasks.named('test', Test) { Test t ->
group = 'verification'
description = 'Runs all non-flaky tests.'
useJUnitPlatform {
excludeTags 'flaky'
}
reports {
junitXml.required = true
junitXml.outputPerTestCase = true
junitXml.mergeReruns = true
junitXml.includeSystemErrLog = true
junitXml.outputLocation = layout.buildDirectory.dir("test-results/test")
}
commonTestConfig(t)
jvmArgs "-javaagent:${configurations.mockitoAgent.singleFile}"
}
tasks.named('check') {
dependsOn(tasks.named('test'))// default behaviour
dependsOn(tasks.named('flakyTest'))
}
testlogger {
theme = 'mocha-parallel'
showExceptions = true
showFullStackTraces = true
showCauses = true
slowThreshold = 2000
showStandardStreams = true
showPassedStandardStreams = false
showSkippedStandardStreams = true
}
}
}
// Collect test task outcomes as they execute (for test-metadata.json)
def testTaskOutcomes = new java.util.concurrent.ConcurrentHashMap<String, String>()
gradle.taskGraph.afterTask { Task task ->
if (task instanceof Test) {
def state = task.state
String outcome
if (state.noSource) {
outcome = 'NO_SOURCE'
} else if (state.failure != null) {
outcome = 'FAILED'
} else if (state.didWork) {
outcome = 'SUCCESS'
} else if (state.upToDate) {
outcome = 'UP_TO_DATE'
} else if (state.skipped) {
outcome = 'SKIPPED'
} else {
outcome = 'FROM_CACHE'
}
testTaskOutcomes.put(task.project.name + ':' + task.name, outcome)
}
}
// Workaround for https://github.com/gradle/gradle/issues/36699
// Gradle's test task `timeout` kills the JVM hard, so JUnit XML reports are never
// generated for timed-out modules. This task captures per-module task states so that
// kestra-devtools can detect missing results and report them in PR comments.
// Remove this task once Gradle supports graceful test task timeouts.
tasks.register('generateTestMetadata') {
group = 'verification'
description = 'Generates build/test-metadata.json with per-module test task states for CI reporting.'
mustRunAfter(subprojects.collectMany { it.tasks.withType(Test) })
def outputFile = layout.buildDirectory.file('test-metadata.json')
outputs.file(outputFile)
outputs.upToDateWhen { false }
doLast {
def timeoutMin = (System.getenv('GRADLE_TEST_TIMEOUT_MIN') ?: '30').toInteger()
def modules = new LinkedHashMap<String, Object>()
subprojects.each { sub ->
def hasTestSources = sub.file('src/test/java').isDirectory() &&
sub.fileTree('src/test/java').files.size() > 0
if (!hasTestSources && sub.file('src/test/kotlin').isDirectory()) {
hasTestSources = sub.fileTree('src/test/kotlin').files.size() > 0
}
def xmlDir = sub.file("build/test-results/test")
def hasXmlResults = xmlDir.isDirectory() &&
sub.fileTree(dir: xmlDir, includes: ['TEST-*.xml']).files.size() > 0
def state = testTaskOutcomes.getOrDefault(sub.name + ':test', 'NOT_RUN')
modules.put(sub.name, [
state: state,
hasTestSources: hasTestSources,
hasXmlResults: hasXmlResults
])
}
def metadata = [
modules: modules,
timeoutMinutes: timeoutMin
]
def json = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(metadata))
outputFile.get().asFile.parentFile.mkdirs()
outputFile.get().asFile.text = json
logger.lifecycle("Test metadata written to ${outputFile.get().asFile.path}")
}
}
// Finalize every Test task (not just `check`) with generateTestMetadata. When a module's
// test task exceeds its timeout, Gradle aborts the build before `check` runs, so a finalizer
// of `check` is skipped and the metadata file is never written — leaving kestra-devtools to
// silently report success for the timed-out module. A finalizer of the Test task itself still
// runs on timeout (same as jacocoTestReport above), guaranteeing test-metadata.json is written.
subprojects {
tasks.withType(Test).configureEach {
finalizedBy rootProject.tasks.named('generateTestMetadata')
}
}
tasks.named('check') {
dependsOn tasks.named('testCodeCoverageReport', JacocoReport)
dependsOn(tasks.named('flakyTest'))
finalizedBy jacocoTestReport
finalizedBy tasks.named('generateTestMetadata')
}
tasks.register('unitTest') {
// No jacocoTestReport here, because it depends by default on :test,
// and that would make :test being run twice in our CI.
// In practice the report will be generated later in the CI by :check.
}
tasks.register('integrationTest') {
dependsOn tasks.named('testCodeCoverageReport', JacocoReport)
finalizedBy jacocoTestReport
}
tasks.register('flakyTest') {
dependsOn tasks.named('testCodeCoverageReport', JacocoReport)
finalizedBy jacocoTestReport
}
tasks.named('testCodeCoverageReport') {
dependsOn ':core:copyGradleProperties'
}
/**********************************************************************************************************************\
* Allure Reports
**********************************************************************************************************************/
subprojects {
plugins.withId('java') {
dependencies {
testImplementation "io.qameta.allure:allure-junit5"
}
test {
// allure-junit5 writes results as a side effect of the test JVM, invisible to Gradle's
// dependency tracking. Without declaring it as a task output, a build-cache hit on :test
// (org.gradle.caching=true) restores build/test-results/ but skips the JVM entirely, so
// no allure-results are ever produced for that run.
def allureResultsDir = layout.buildDirectory.dir("allure-results")
systemProperty 'allure.results.directory', allureResultsDir.get().asFile.absolutePath
outputs.dir(allureResultsDir)
}
}
}
/**********************************************************************************************************************\
* Sonar
**********************************************************************************************************************/
subprojects {
sonar {
properties {
property "sonar.coverage.jacoco.xmlReportPaths", "$projectDir.parentFile.path/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml,$projectDir.parentFile.path/build/reports/jacoco/test/testCodeCoverageReport.xml"
}
}
}
sonar {
properties {
property "sonar.projectKey", "kestra-io_kestra"
property "sonar.organization", "kestra-io"
property "sonar.host.url", "https://sonarcloud.io"
}
}
/**********************************************************************************************************************\
* OWASP Dependency check
**********************************************************************************************************************/
apply plugin: 'org.owasp.dependencycheck'
dependencyCheck {
// fail only on HIGH and CRITICAL vulnerabilities, we may want to lower to 5 (mid-medium) later
failBuildOnCVSS = 7
// disable the .NET assembly analyzer as otherwise it wants to analyze EXE file
analyzers(new Action<AnalyzerExtension>() {
@Override
void execute(AnalyzerExtension analyzerExtension) {
analyzerExtension.assemblyEnabled = false
}
})
// configure a suppression file
suppressionFile = "$projectDir/owasp-dependency-suppressions.xml"
nvd.apiKey = System.getenv("NVD_API_KEY")
}
/**********************************************************************************************************************\
* Micronaut
**********************************************************************************************************************/
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
options.compilerArgs.add("-Xlint:all")
options.compilerArgs.add("-Xlint:-processing")
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
}
run.classpath += configurations.developmentOnly
test.classpath += configurations.developmentOnly
run.jvmArgs(
"-noverify",
"-XX:TieredStopAtLevel=1",
"-Dcom.sun.management.jmxremote",
'-Dmicronaut.environments=dev,override',
// Silence the sun.misc.Unsafe memory-access startup warning (JEP 498) triggered by
// com.google.protobuf.UnsafeUtil (pulled in by gRPC), see https://github.com/kestra-io/kestra/issues/16513
'--sun-misc-unsafe-memory-access=allow'
)
/**********************************************************************************************************************\
* Jar
**********************************************************************************************************************/
jar {
manifest {
attributes(
"Main-Class": mainClassName,
"X-Kestra-Name": project.name,
"X-Kestra-Title": project.name,
"X-Kestra-Group": project.group,
"X-Kestra-Version": project.version
)
}
}
shadowJar {
archiveClassifier.set(null)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
mergeServiceFiles()
zip64 = true
}
distZip.dependsOn shadowJar
distTar.dependsOn shadowJar
startScripts.dependsOn shadowJar
startShadowScripts.dependsOn jar
shadowJar.dependsOn jar
/**********************************************************************************************************************\
* Executable Jar
**********************************************************************************************************************/
def executableDir = layout.buildDirectory.dir("executable")
def executable = layout.buildDirectory.file("executable/${project.name}-${project.version}").get().asFile
tasks.register('writeExecutableJar') {
group = "build"
description = "Write an executable jar from shadow jar"
dependsOn = [shadowJar]
final shadowJarFile = tasks.shadowJar.outputs.files.singleFile
inputs.file shadowJarFile
outputs.file executable
outputs.cacheIf { true }
doFirst {
executableDir.get().asFile.mkdirs()
}
doLast {
executable.setBytes(shadowJarFile.readBytes())
ByteArrayOutputStream executableBytes = new ByteArrayOutputStream()
executableBytes.write("\n: <<END_OF_KESTRA_SELFRUN\r\n".getBytes())
executableBytes.write(file("gradle/jar/selfrun.bat").readBytes())
executableBytes.write("\r\n".getBytes())
executableBytes.write("END_OF_KESTRA_SELFRUN\r\n\n".getBytes())
executableBytes.write(file("gradle/jar/selfrun.sh").readBytes())
ZipPrefixer.applyPrefixBytesToZip(executable.toPath(), executableBytes.toByteArray())
executable.setExecutable(true)
}
}
tasks.register('executableJar', Zip) {
group = "build"
description = "Zip the executable jar"
dependsOn = [writeExecutableJar]
archiveFileName = "${project.name}-${project.version}.zip"
destinationDirectory = layout.buildDirectory.dir('archives')
from executableDir
archiveClassifier.set(null)
}
/**********************************************************************************************************************\
* Standalone
**********************************************************************************************************************/
tasks.register('runLocal') {
group = "application"
description = "Run Kestra as server local"
dependsOn ':cli:runLocal'
}
tasks.register('runStandalone') {
group = "application"
description = "Run Kestra as server standalone (plugin directory: -PstandalonePlugins=<dir>, default '../local/plugins')"
dependsOn ':cli:runStandalone'
}
/**********************************************************************************************************************\
* Publish
**********************************************************************************************************************/
subprojects {subProject ->
if (subProject.name != 'jmh-benchmarks' && subProject.name != rootProject.name) {
apply plugin: 'signing'
apply plugin: "com.vanniktech.maven.publish"
javadoc {
options {
locale = 'en_US'
encoding = 'UTF-8'
addStringOption("Xdoclint:none", "-quiet")
}
}
tasks.register('sourcesJar', Jar) {
dependsOn = [':core:copyGradleProperties']
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
sourcesJar.dependsOn ':core:copyGradleProperties'
tasks.register('javadocJar', Jar) {
archiveClassifier.set('javadoc')
from javadoc
}
tasks.register('testsJar', Jar) {
group = 'build'
description = 'Build the tests jar'
archiveClassifier.set('tests')
if (sourceSets.matching { it.name == 'test'}) {
from sourceSets.named('test').get().output
}
}
//These modules should not be published
def unpublishedModules = ["jdbc-mysql", "jdbc-postgres", "webserver"]
if (subProject.name in unpublishedModules){
return
}
mavenPublishing {
publishToMavenCentral(true)
signAllPublications()
coordinates(
"${rootProject.group}",
subProject.name == "cli" ? rootProject.name : subProject.name,
"${rootProject.version}"
)
pom {
name = project.name
description = "${project.group}:${project.name}:${rootProject.version}"
url = "https://github.com/kestra-io/${rootProject.name}"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "tchiotludo"
name = "Ludovic Dehon"
email = "ldehon@kestra.io"
}
}
scm {
connection = 'scm:git:'
url = "https://github.com/kestra-io/${rootProject.name}"
}
}
}
afterEvaluate {
publishing {
publications {
withType(MavenPublication).configureEach { publication ->
if (subProject.name == "platform") {
// Clear all artifacts except the BOM
publication.artifacts.clear()
}
}
}
}
}
if (subProject.name == 'cli') {
/* Make sure the special publication is wired *after* every plugin */
subProject.afterEvaluate {
/* 1. Remove the default java component so Gradle stops expecting
the standard cli-*.jar, sources, javadoc, etc. */
components.removeAll { it.name == "java" }
/* 2. Replace the publication’s artifacts with shadow + exec */
publishing.publications.withType(MavenPublication).configureEach { pub ->
pub.artifacts.clear()
// main shadow JAR built at root
pub.artifact(rootProject.tasks.named("shadowJar").get()) {
extension = "jar"
}
// executable ZIP built at root
pub.artifact(rootProject.tasks.named("executableJar").get().archiveFile) {
classifier = "exec"
extension = "zip"
}
pub.artifact(tasks.named("sourcesJar").get())
pub.artifact(tasks.named("javadocJar").get())
}
/* 3. Disable Gradle-module metadata for this publication to
avoid the “artifact removed from java component” error. */
tasks.withType(GenerateModuleMetadata).configureEach { it.enabled = false }
/* 4. Make every publish task in :cli wait for the two artifacts */
tasks.matching { it.name.startsWith("publish") }.configureEach {
dependsOn rootProject.tasks.named("shadowJar")
dependsOn rootProject.tasks.named("executableJar")
}
}
}
if (subProject.name != 'platform' && subProject.name != 'cli') {
// only if a test source set actually exists (avoids empty artifacts)
def hasTests = subProject.extensions.findByName('sourceSets')?.findByName('test') != null
if (hasTests) {
// wire the artifact onto every Maven publication of this subproject
publishing {
publications {
withType(MavenPublication).configureEach { pub ->
// keep the normal java component + sources/javadoc already configured
pub.artifact(subProject.tasks.named('testsJar').get())
}
}
}
// make sure publish tasks build the tests jar first
tasks.matching { it.name.startsWith('publish') }.configureEach {
dependsOn subProject.tasks.named('testsJar')
}
}
}
}
}
/**********************************************************************************************************************\
* Version
**********************************************************************************************************************/
release {
preCommitText = 'chore(version):'
preTagCommitMessage = 'update to version'
tagCommitMessage = 'tag version'
newVersionCommitMessage = 'update snapshot version'
tagTemplate = 'v${version}'
buildTasks = ['classes']
git {
requireBranch.set('develop')
}
// Dynamically set properties with default values
failOnSnapshotDependencies = providers.gradleProperty("release.failOnSnapshotDependencies")
.map(val -> Boolean.parseBoolean(val))
.getOrElse(true)
pushReleaseVersionBranch = providers.gradleProperty("release.pushReleaseVersionBranch")
.getOrElse(null)
}