forked from dapr/durabletask-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
283 lines (249 loc) · 9.15 KB
/
build.gradle
File metadata and controls
283 lines (249 loc) · 9.15 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
plugins {
id 'java-library'
id 'com.google.protobuf' version '0.8.16'
// Generate IntelliJ IDEA's .idea & .iml project files
id 'idea'
id 'maven-publish'
// id 'signing'
id 'com.github.spotbugs' version '5.2.1'
id 'org.jreleaser' version '1.18.0'
id 'org.gradle.test-retry' version '1.4.1'
}
group 'io.dapr'
version = '1.5.9'
archivesBaseName = 'durabletask-client'
def grpcVersion = '1.69.0'
def protocVersion = '3.25.5'
def jacksonVersion = '2.15.3'
// Java 11 is now the minimum required version for both compilation and testing
dependencies {
// https://github.com/grpc/grpc-java#download
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
implementation "io.grpc:grpc-stub:${grpcVersion}"
implementation 'com.google.protobuf:protobuf-java:3.25.5'
runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}"
compileOnly "org.apache.tomcat:annotations-api:6.0.53"
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jacksonVersion}"
testImplementation(platform('org.junit:junit-bom:5.7.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
// Netty dependencies for TLS
implementation "io.grpc:grpc-netty-shaded:${grpcVersion}"
implementation 'io.netty:netty-handler:4.1.119.Final'
implementation "io.netty:netty-tcnative-boringssl-static:2.0.59.Final"
// Add Netty dependencies to test classpath
testImplementation "io.grpc:grpc-netty-shaded:${grpcVersion}"
testImplementation 'io.netty:netty-handler:4.1.119.Final'
testImplementation "io.netty:netty-tcnative-boringssl-static:2.0.59.Final"
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.70'
testImplementation 'org.bouncycastle:bcpkix-jdk15on:1.70'
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
task downloadProtoFiles {
ext.branch = project.hasProperty('protoBranch') ? project.protoBranch : 'main'
doLast {
def protoDir = file("${rootProject.projectDir}/internal/durabletask-protobuf/protos")
def protoFile = new File(protoDir, 'orchestrator_service.proto')
def commitHashFile = new File("${rootProject.projectDir}/internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH")
protoDir.mkdirs()
// Download the proto file
new URL("https://raw.githubusercontent.com/dapr/durabletask-protobuf/${ext.branch}/protos/orchestrator_service.proto")
.withInputStream { i ->
protoFile.withOutputStream { it << i }
}
try {
def commitApiUrl = new URL("https://api.github.com/repos/dapr/durabletask-protobuf/commits?path=protos/orchestrator_service.proto&sha=${ext.branch}&per_page=1")
def connection = commitApiUrl.openConnection()
connection.setRequestProperty('Accept', 'application/vnd.github.v3+json')
connection.setRequestProperty('User-Agent', 'durabletask-java-build')
// Add GitHub token if available (automatically provided in GitHub Actions)
if (System.env.GITHUB_TOKEN) {
connection.setRequestProperty('Authorization', "token ${System.env.GITHUB_TOKEN}")
}
def commitHash = new groovy.json.JsonSlurper().parse(connection.inputStream)[0].sha
commitHashFile.text = commitHash
logger.info("Successfully updated proto commit hash: ${commitHash}")
} catch (Exception e) {
logger.error("Failed to fetch commit hash from GitHub API: ${e.message}")
}
}
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${protocVersion}"
}
plugins {
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
}
generateProtoTasks {
all()*.plugins { grpc {} }
all()*.dependsOn downloadProtoFiles
}
}
sourceSets {
main {
proto {
srcDir '../internal/durabletask-protobuf/protos'
}
java {
srcDirs 'build/generated/source/proto/main/grpc'
srcDirs 'build/generated/source/proto/main/java'
}
}
}
test {
useJUnitPlatform {
// Skip tests tagged as "integration" since those are slower
// and require external dependencies.
excludeTags "integration"
}
retry {
maxRetries = 2
maxFailures = 5
}
}
// Unlike normal unit tests, some tests are considered "integration tests" and shouldn't be
// run during a build. We instead tag them as "integration" tests and only run them as part
// of this custom integrationTest task. Normal builds won't execute this, but CI builds will
// by running "gradle check" (see the dependsOn() further down).
task integrationTest(type: Test) {
useJUnitPlatform {
includeTags 'integration'
}
dependsOn build
shouldRunAfter test
testLogging.showStandardStreams = true
ignoreFailures = false
// Add retry capability for flaky integration tests
retry {
maxRetries = 3
maxFailures = 10
}
}
publishing {
repositories {
maven {
url = rootProject.layout.buildDirectory.dir('staging-deploy')
}
}
publications {
mavenJava(MavenPublication) {
from components.java
artifactId = archivesBaseName
pom {
name = 'Durable Task Client SDK for Java'
description = 'This package contains classes and interfaces for building Durable Task orchestrations in Java.'
url = "https://github.com/dapr/durabletask-java/tree/main/client"
licenses {
license {
name = "MIT License"
url = "https://opensource.org/licenses/MIT"
distribution = "repo"
}
}
developers {
developer {
id = "Dapr"
name = "Dapr"
}
}
scm {
connection = "scm:git:https://github.com/dapr/durabletask-java"
developerConnection = "scm:git:git@github.com:dapr/durabletask-java"
url = "https://github.com/dapr/durabletask-java/tree/main/client"
}
// use below script to include compile-only dependencies when generated pom file.
// This is pain point when we onboard API docs as the missing compile-only dependencies crash the
// API doc's team onboarding pipeline.
withXml {
project.configurations.compileOnly.allDependencies.each { dependency ->
asNode().dependencies[0].appendNode("dependency").with {
it.appendNode("groupId", dependency.group)
it.appendNode("artifactId", dependency.name)
it.appendNode("version", dependency.version)
it.appendNode("scope", "provided")
}
}
}
}
}
}
}
java {
withSourcesJar()
withJavadocJar()
}
tasks.named('sourcesJar').configure {
dependsOn tasks.named('generateProto')
}
spotbugs {
toolVersion = '4.9.2'
effort = 'max'
reportLevel = 'high'
ignoreFailures = true
excludeFilter = file('spotbugs-exclude.xml')
}
spotbugsMain {
reports {
html {
required = true
stylesheet = 'fancy-hist.xsl'
}
xml {
required = true
}
}
}
spotbugsTest {
reports {
html {
required = true
stylesheet = 'fancy-hist.xsl'
}
xml {
required = true
}
}
}
jreleaser {
project {
name = "durabletask-java"
description = "This package contains classes and interfaces for building Durable Task orchestrations in Java."
authors = ["Dapr"]
tags = ['dapr']
maintainers = ['Dapr']
license = 'MIT'
inceptionYear = "2025"
}
signing {
gitRootSearch = true
active = 'ALWAYS'
armored = true
verify = false
}
deploy {
maven {
nexus2 {
'maven-central' {
active = 'ALWAYS'
url = 'https://ossrh-staging-api.central.sonatype.com/service/local'
closeRepository = true
releaseRepository = true
applyMavenCentralRules = true
stagingRepository('../build/staging-deploy')
}
}
}
}
}