forked from line/armeria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
221 lines (186 loc) · 7.7 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
import java.util.concurrent.atomic.AtomicBoolean
plugins {
id 'com.google.osdetector' version '1.6.2' apply false
id 'cz.alenkacz.gradle.scalafmt' version '1.16.2' apply false
// If you want to change `org.jetbrains.kotlin.jvm` version,
// you also need to change `org.jetbrains.kotlin:kotlin-allopen` version in `dependencies.yml`.
id 'org.jetbrains.kotlin.jvm' version '1.5.10' apply false
id 'org.jlleitschuh.gradle.ktlint' version '10.1.0' apply false
id 'net.ltgt.errorprone' version '2.0.2' apply false
}
allprojects {
repositories {
mavenCentral()
}
}
ext {
// Set the artifactId of 'armeria-core' to 'armeria'.
artifactIdOverrides = [':core': rootProject.name]
}
apply from: "${rootDir}/gradle/scripts/build-flags.gradle"
// Fail the build if the console contains 'LEAK:'.
def hasLeak = new AtomicBoolean()
gradle.buildFinished({ result ->
if (hasLeak.get()) {
throw new TestExecutionException('Found a leak while testing. ' +
"Specify '-Pleak' option to record the detail and " +
'find it using the following command: \n\n' +
" find . -type f -name 'TEST-*.xml' -exec grep -Fl 'LEAK: ' {} ';'\n")
}
})
allprojects {
// Add common JVM options such as max memory and leak detection.
tasks.withType(JavaForkOptions) {
maxHeapSize = '512m'
if (rootProject.ext.testJavaVersion >= 9) {
jvmArgs '--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED'
}
// Enable leak detection when '-Pleak' option is specified.
if (rootProject.hasProperty('leak')) {
systemProperties 'io.netty.leakDetectionLevel': 'paranoid'
systemProperties 'io.netty.leakDetection.targetRecords': '256'
}
}
tasks.withType(Test) {
// Do not omit stack frames for easier tracking.
jvmArgs '-XX:-OmitStackTraceInFastThrow'
// Use verbose exception/response reporting for easier debugging.
systemProperty 'com.linecorp.armeria.verboseExceptions', 'true'
systemProperty 'com.linecorp.armeria.verboseResponses', 'true'
// Pass special system property to tell our tests that we are measuring coverage.
if (project.hasFlags('coverage')) {
systemProperty 'com.linecorp.armeria.testing.coverage', 'true'
}
// Parallelize if --parallel is on.
if (gradle.startParameter.parallelProjectExecutionEnabled) {
maxParallelForks = gradle.startParameter.maxWorkerCount
}
// Fail the build at the end if there was any leak.
// We do not fail immediately so that we collect as many leaks as possible.
doFirst {
addTestOutputListener({ descriptor, event ->
if (event.message.contains('LEAK: ')) {
hasLeak.set(true)
}
})
}
}
}
// Configure all Java projects
configure(projectsWithFlags('java')) {
// Error Prone compiler
if (!rootProject.hasProperty('noLint')) {
apply plugin: 'net.ltgt.errorprone'
dependencies {
errorprone 'com.google.errorprone:error_prone_core'
}
tasks.withType(JavaCompile) {
options.errorprone.excludedPaths = '.*/gen-src/.*'
}
}
// Common dependencies
dependencies {
// All projects currently require ':core' (except itself)
if (project != project(':core')) {
api project(':core')
}
// Testing utilities
testImplementation project(':testing-internal')
// completable-futures
implementation 'com.spotify:completable-futures'
// Errorprone
compileOnly 'com.google.errorprone:error_prone_annotations'
testImplementation 'com.google.errorprone:error_prone_annotations'
// FastUtil
implementation 'it.unimi.dsi:fastutil'
implementation 'it.unimi.dsi:fastutil-core'
implementation 'it.unimi.dsi:fastutil-extra'
// Guava
implementation 'com.google.guava:guava'
// J2ObjC annotations
compileOnly 'com.google.j2objc:j2objc-annotations'
// JSR305
implementation 'com.google.code.findbugs:jsr305'
// JCTools
implementation 'org.jctools:jctools-core'
// Jetty ALPN support
compileOnly 'org.eclipse.jetty.alpn:alpn-api'
// Logging
implementation 'org.slf4j:slf4j-api'
testImplementation 'org.slf4j:jul-to-slf4j'
testImplementation 'ch.qos.logback:logback-classic'
['jcl-over-slf4j', 'log4j-over-slf4j'].each {
testRuntimeOnly "org.slf4j:$it"
}
// Reflections
implementation 'org.reflections:reflections'
// Test-time dependencies
testImplementation 'com.google.guava:guava-testlib'
testImplementation 'junit:junit'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.junit.jupiter:junit-jupiter-params'
testRuntimeOnly 'org.junit.platform:junit-platform-commons'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
testImplementation 'net.javacrumbs.json-unit:json-unit'
testImplementation 'net.javacrumbs.json-unit:json-unit-fluent'
testImplementation 'org.awaitility:awaitility'
testRuntimeOnly 'org.checkerframework:checker-compat-qual' // Required by guava-testlib
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.apache.httpcomponents:httpclient'
testImplementation 'org.hamcrest:hamcrest'
testImplementation 'org.hamcrest:hamcrest-library'
}
tasks.withType(JavaCompile) { task ->
if (task.path.startsWith(':examples:')) {
// Target Java 11 for examples.
options.release.set(11)
// IntelliJ fails to compile example projects with IntelliJ compiler because of a wrong target
// bytecode version which is marked as Java 8 without the following options.
// See https://github.com/line/armeria/pull/3712
sourceCompatibility = '11'
targetCompatibility = '11'
} else {
// Target Java 8 for the rest of them.
options.release.set(8)
}
}
// Configure the default DuplicatesStrategy for such as:
// - c.l.armeria.versions.properties
// - thrift/cassandra.json
// - and so on
tasks.sourcesJar.duplicatesStrategy = DuplicatesStrategy.INCLUDE
tasks.withType(Copy) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}
allprojects {
tasks.all { task ->
// Disables all tasks in examples when we use a JDK version under 11.
if (rootProject.ext.testJavaVersion < 11 && task.path.startsWith(':examples:')) {
task.enabled = false
}
}
// Configure the Javadoc tasks of all projects.
tasks.withType(Javadoc) {
options {
// Groups
group 'Server', 'com.linecorp.armeria.server*'
group 'Client', 'com.linecorp.armeria.client*'
group 'Common', 'com.linecorp.armeria.common*'
// Exclude the machine-generated or internal-only classes
exclude '**/Tomcat*ProtocolHandler.java'
exclude '**/internal/**'
exclude '**/thrift/v1/**'
exclude '**/reactor/core/scheduler/**'
}
}
}
// Require to use JDK 16 when releasing.
tasks.release.doFirst {
if (JavaVersion.current() != JavaVersion.VERSION_16) {
throw new IllegalStateException("You must release using JDK 16.");
}
}