forked from temporalio/sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
350 lines (304 loc) · 10.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
// Run 'gradle checkUpdates' to find out which dependencies have newer versions
buildscript {
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12'
}
}
plugins {
id 'com.github.sherter.google-java-format' version '0.9'
id 'com.google.protobuf' version '0.8.12'
id 'java-library'
id 'net.ltgt.errorprone' version '1.2.1'
id 'net.minecrell.licenser' version '0.4.1'
id 'com.palantir.git-version' version '0.12.3'
id 'maven-publish'
id 'signing'
id 'de.marcphilipp.nexus-publish' version '0.4.0'
id 'name.remal.check-updates' version '1.0.209'
}
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
mavenCentral()
}
apply plugin: 'com.github.sherter.google-java-format'
apply plugin: 'com.google.protobuf'
apply plugin: 'idea' // IntelliJ plugin to see files generated from protos
apply plugin: 'maven-publish'
apply plugin: 'de.marcphilipp.nexus-publish'
apply plugin: 'java'
if (hasProperty('signing.keyId')) {
apply plugin: 'signing'
signing {
sign configurations.archives
}
}
googleJavaFormat {
toolVersion '1.7'
include '**/*.java'
exclude '**/generated/*'
exclude '**/.idea/**'
}
// v0.20.0-2-g000a42a -> 0.20.0-2-g000a42a
ext.getTag = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags'
standardOutput = stdout
}
return stdout.toString().trim().substring(1)
}
// 0.20.0-2-g000a42a -> 0.20.0-SNAPSHOT
// 0.20.0 -> 0.20.0
// Used to name jar files
ext.getVersionName = { ->
def split = getTag().split('-')
if (split.size() > 1) {
return split[0] + '-SNAPSHOT'
}
return split[0]
}
// 0.20.0-SNAPSHOT -> 0.20.0
// 0.20.0 -> 0.20.0
// Stored int version.properties which is loaded
// and used as a value of temporal-client-version gRPC header.
ext.getClientVersionName = { ->
def split = getVersionName().split('-')
return split[0]
}
group = 'io.temporal'
version = getVersionName()
archivesBaseName = "temporal-sdk"
description = '''Temporal Workflow Java SDK'''
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
dependencies {
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
errorprone('com.google.errorprone:error_prone_core:2.4.0')
api group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
api group: 'com.uber.m3', name: 'tally-core', version: '0.6.1'
api group: 'io.micrometer', name: 'micrometer-core', version: '1.5.2'
api group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
api 'io.grpc:grpc-protobuf:1.31.1'
api 'io.grpc:grpc-stub:1.31.1'
implementation group: 'com.google.guava', name: 'guava', version: '29.0-jre'
implementation group: 'com.cronutils', name: 'cron-utils', version: '9.1.1'
implementation 'io.grpc:grpc-netty-shaded:1.31.1'
implementation group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.15.6'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.2'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.11.2'
if (!JavaVersion.current().isJava8()) {
implementation 'javax.annotation:javax.annotation-api:1.3.2'
}
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
testImplementation group: 'com.googlecode.junit-toolbox', name: 'junit-toolbox', version: '2.4'
testImplementation group: 'junit', name: 'junit', version: '4.13'
}
configurations.all {
// Conflicts with logback
exclude group: 'org.slf4j', module: 'slf4j-simple'
}
license {
header rootProject.file('license-header.txt')
exclude '**/*.puml'
}
task initSubmodules(type: Exec) {
description = 'Initializes submodules'
commandLine 'git', 'submodule', 'init'
}
task updateSubmodules(type: Exec) {
dependsOn initSubmodules
description = 'Update submodules'
commandLine 'git', 'submodule', 'update'
}
//TODO(maxim): For some reason the following doesn't exclude proto files from the lib jar.
// But it should according to https://github.com/google/protobuf-gradle-plugin/issues/390
jar {
exclude '**.proto'
includeEmptyDirs false
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.12.4'
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.31.1'
}
}
generateProtoTasks {
all().each { task -> task.dependsOn updateSubmodules }
all()*.plugins {
grpc {
outputSubDir = 'java'
}
}
}
}
clean {
delete protobuf.generatedFilesBaseDir
}
protobuf {
generatedFilesBaseDir = "$buildDir/generated"
}
idea {
module {
sourceDirs += file("$buildDir/generated/main/java")
sourceDirs += file("$buildDir/generated/main/grpc")
}
}
compileJava {
dependsOn 'googleJavaFormat'
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:none' << '-Xlint:deprecation' << '-Werror'
options.errorprone.excludedPaths = '.*/generated-sources/.*'
}
compileTestJava {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:none' << '-Xlint:deprecation' << '-Werror'
options.errorprone.excludedPaths = '.*/generated-sources/.*'
}
// Generation version.properties for value to be included into the request header
task createProperties(dependsOn: processResources) {
doLast {
def subdir = new File("$buildDir/resources/main/io/temporal/")
if (!subdir.exists()) {
subdir.mkdirs()
}
new File("$buildDir/resources/main/io/temporal/version.properties").withWriter { w ->
Properties p = new Properties()
p['temporal-client-version'] = getClientVersionName()
p.store w, null
}
}
}
classes {
dependsOn createProperties
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
javadoc {
options.encoding = 'UTF-8'
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
// Needed to include generated fils into the source jar
task sourceJar(type: Jar) {
from sourceSets.main.allSource, file("$buildDir/generated/main/java")
classifier "sources"
}
task registerNamespace(type: JavaExec) {
main = 'io.temporal.RegisterTestNamespace'
classpath = sourceSets.test.runtimeClasspath
}
test {
dependsOn 'registerNamespace'
dependsOn 'checkLicenseMain'
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
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Temporal Java SDK'
packaging = 'jar'
// optionally artifactId can be defined here
description = 'Temporal Workflow Java SDK'
url = 'https://github.com/temporalio/temporal-java-sdk'
scm {
connection = 'scm:git@github.com:temporalio/temporal-java-sdk.git'
developerConnection = 'scm:git@github.com:temporalio/temporal-java-sdk.git'
url = 'https://github.com/temporalio/temporal-java-sdk.git'
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'mfateev'
name = 'Maxim Fateev'
email = 'maxim@temporal.io'
}
developer {
id = 'samarabbas'
name = 'Samar Abbas'
email = 'samar@temporal.io'
}
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
// Uncomment to test local publishing and comment nexusPublishing
// repositories {
// maven {
// def releasesRepoUrl = "$System.env.HOME/repos/releases"
// def snapshotsRepoUrl = "$System.env.HOME/repos/snapshots"
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
// }
// }
}
nexusPublishing {
repositories {
sonatype {
username = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : ''
password = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : ''
}
}
}
// Logs list of failed tests after build is done.
allprojects {
// add a collection to track failedTests
ext.failedTests = []
// add a testlistener to all tasks of type Test
tasks.withType(Test) {
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 ""
}
}
}
//logging.captureStandardOutput LogLevel.INFO