-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathjava.gradle
More file actions
91 lines (81 loc) · 3.37 KB
/
java.gradle
File metadata and controls
91 lines (81 loc) · 3.37 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
subprojects {
if (name == 'temporal-bom') {
return
}
apply plugin: 'java-library'
java {
// graal only supports java 8, 11, 16, 17, 21, 23
sourceCompatibility = project.hasProperty("edgeDepsTest") || project.hasProperty("nativeBuild") ? JavaVersion.VERSION_21 : JavaVersion.VERSION_1_8
targetCompatibility = project.hasProperty("edgeDepsTest") || project.hasProperty("nativeBuild") ? JavaVersion.VERSION_21 : JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:none' << '-Xlint:deprecation' << '-Werror' << '-parameters'
if (!project.hasProperty("edgeDepsTest") && !project.hasProperty("nativeBuild")) {
// https://stackoverflow.com/a/43103115/525203
options.compilerArgs.addAll(['--release', '8'])
}
}
compileTestJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:none' << '-Xlint:deprecation' << '-Werror' << '-parameters'
if (!project.hasProperty("edgeDepsTest") && !project.hasProperty("nativeBuild")) {
// https://stackoverflow.com/a/43103115/525203
options.compilerArgs.addAll(['--release', '8'])
}
}
javadoc {
options.encoding = 'UTF-8'
options.addStringOption('Xdoclint:reference', '-quiet')
options.addBooleanOption('Werror', true)
options.addBooleanOption('html5', true)
}
// add a collection to track failedTests
ext.failedTests = []
test {
if (project.hasProperty("testJavaVersion")) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(project.property("testJavaVersion") as int)
}
}
testLogging {
events 'passed', 'skipped', 'failed'
exceptionFormat 'full'
// Uncomment the following line if you want to see test logs in gradlew run.
showStandardStreams true
}
forkEvery = 1
var coresDivider = project.hasProperty("jacoco") ? 4 : 2 // penalize jacoco build to reduce load and random timeouts
maxParallelForks = Math.max(Runtime.runtime.availableProcessors().intdiv(coresDivider), 1) ?: 1
// Captures the list of failed tests to log after build is done.
afterTest { TestDescriptor descriptor, TestResult result ->
if (result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE) {
failedTests << ["${descriptor.className}::${descriptor.name}"]
}
}
}
// print out tracked failed tests when the build has finished
gradle.buildFinished {
if (!failedTests.empty) {
println "Failed tests for ${project.name}:"
failedTests.each { failedTest ->
println failedTest
}
println ""
}
}
afterEvaluate { subproject ->
jar {
manifest {
attributes(
"Implementation-Title": subproject.description,
"Implementation-Version": subproject.version,
"Implementation-Vendor": "Temporal Technologies Inc.",
'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
)
}
}
}
}