-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild.gradle
More file actions
244 lines (216 loc) · 8.03 KB
/
build.gradle
File metadata and controls
244 lines (216 loc) · 8.03 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
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.gradle.test-retry' version '1.4.1'
}
group 'com.microsoft'
version = '1.6.1'
archivesBaseName = 'durabletask-client'
def grpcVersion = '1.59.0'
def protocVersion = '3.12.0'
def jacksonVersion = '2.15.3'
def openTelemetryVersion = '1.25.0'
def azureCoreVersion = '1.45.0'
def azureIdentityVersion = '1.11.1'
// When build on local, you need to set this value to your local jdk11 directory.
// Java11 is used to compile and run all the tests.
// Example for Windows: C:/Program Files/Java/openjdk-11.0.12_7/
def PATH_TO_TEST_JAVA_RUNTIME = System.env.JDK_11 ?: System.getProperty("java.home")
dependencies {
// https://github.com/grpc/grpc-java#download
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
implementation "io.grpc:grpc-stub:${grpcVersion}"
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}"
implementation "io.opentelemetry:opentelemetry-api:${openTelemetryVersion}"
implementation "io.opentelemetry:opentelemetry-context:${openTelemetryVersion}"
testImplementation(platform('org.junit:junit-bom:5.7.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation project(':azuremanaged')
testImplementation "com.azure:azure-core:${azureCoreVersion}"
testImplementation "com.azure:azure-identity:${azureIdentityVersion}"
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
options.fork = true
options.forkOptions.executable = "${PATH_TO_TEST_JAVA_RUNTIME}/bin/javac"
}
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')
// Skip download if proto file already exists
if (protoFile.exists()) {
logger.info("Proto file already exists, skipping download")
return
}
protoDir.mkdirs()
// Download the proto file
new URL("https://raw.githubusercontent.com/microsoft/durabletask-protobuf/${ext.branch}/protos/orchestrator_service.proto")
.withInputStream { i ->
protoFile.withOutputStream { it << i }
}
// Get and save the commit hash
def commitHashFile = new File("${rootProject.projectDir}/internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH")
def commitApiUrl = new URL("https://api.github.com/repos/microsoft/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')
def commitHash = new groovy.json.JsonSlurper().parse(connection.inputStream)[0].sha
commitHashFile.text = commitHash
}
}
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'
}
}
}
tasks.withType(Test) {
executable = new File("${PATH_TO_TEST_JAVA_RUNTIME}", 'bin/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 "file://$project.rootDir/repo"
}
}
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/microsoft/durabletask-java/tree/main/client"
licenses {
license {
name = "MIT License"
url = "https://opensource.org/licenses/MIT"
distribution = "repo"
}
}
developers {
developer {
id = "Microsoft"
name = "Microsoft Corporation"
}
}
scm {
connection = "scm:git:https://github.com/microsoft/durabletask-java"
developerConnection = "scm:git:git@github.com:microsoft/durabletask-java"
url = "https://github.com/microsoft/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")
}
}
}
}
}
}
}
signing {
required = !project.hasProperty("skipSigning")
sign publishing.publications.mavenJava
}
java {
withSourcesJar()
withJavadocJar()
}
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
}
}
}