-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathbuild.gradle
More file actions
285 lines (249 loc) · 8.98 KB
/
build.gradle
File metadata and controls
285 lines (249 loc) · 8.98 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
284
285
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import com.vanniktech.maven.publish.SonatypeHost
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
buildscript {
repositories {
maven { url "https://repo1.maven.org/maven2" }
gradlePluginPortal()
}
}
plugins {
id 'java'
id 'jvm-test-suite'
id "signing"
id "org.openapi.generator" version libs.versions.openapi.generator
id "com.diffplug.spotless" version libs.versions.spotless
id "com.github.evestera.depsize" version libs.versions.depsize
id 'jacoco-report-aggregation'
id "com.github.spotbugs" version libs.versions.spotbugs
id "org.owasp.dependencycheck" version libs.versions.depcheck
id "com.vanniktech.maven.publish" version libs.versions.maven.publish
}
apply plugin: 'org.openapi.generator'
allprojects {
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
configurations.configureEach {
resolutionStrategy {
// version overrides for CVE fixes
force 'org.apache.commons:commons-lang3:3.18.0' // CVE-2025-48924
force 'ch.qos.logback:logback-classic:1.3.15' // CVE-2024-12798, CVE-2024-12801
force 'com.google.code.gson:gson:2.13.2' // CVE-2025-53864
// JDK 25 fix for spotless plugin
force 'com.google.googlejavaformat:google-java-format:1.27.0'
}
}
apply plugin: 'java-library'
apply plugin: 'org.owasp.dependencycheck'
}
dependencies {
api libs.okhttp3.core
api libs.okhttp3.logging.interceptor
api libs.gson.fire
api libs.google.gson
api libs.google.findbugs
api libs.caffeine.cache
api libs.murmur3
api libs.swagger.annotations
api libs.javax.annotation.api
api libs.slf4j.api
compileOnly libs.lombok
annotationProcessor libs.lombok
}
group = 'io.harness'
version = libs.versions.sdk.get()
description = 'Harness Feature Flag Java Server SDK'
openApiGenerate {
// https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-gradle-plugin
generatorName = "java"
inputSpec = "$rootDir/src/main/resources/client-v1.yaml".toString()
outputDir = "$buildDir/generated".toString()
templateDir = "$rootDir/template"
apiPackage = "io.harness.cf.api"
invokerPackage = "io.harness.cf"
modelPackage = "io.harness.cf.model"
generateApiDocumentation = false
generateModelDocumentation = false
generateModelTests = false
generateApiTests = false
typeMappings = [ "OffsetDateTime" : "Date" ]
importMappings = [ "java.time.OffsetDateTime" : "java.util.Date" ]
// https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/java.md
configOptions = [
java8: "true",
dateLibrary : "java8",
serializableModel : "true",
//additionalModelTypeAnnotations : "@FieldDefaults(makeFinal=true)"
]
}
tasks.register('generateVersion', Copy) {
def tokens = [version: project.version]
inputs.properties tokens
from "src/template/java"
into "$buildDir/generated-version/src/main/java"
expand tokens
}
testing {
suites {
test {
useJUnitJupiter()
dependencies {
implementation project()
implementation libs.logback.classic
implementation platform(libs.junit.bom)
runtimeOnly libs.junit.platform.launcher
implementation libs.mockito.junit5
implementation libs.okhttp3.mockwebserver
compileOnly libs.lombok
annotationProcessor libs.lombok
// JMH dependencies
implementation libs.jmh.core
annotationProcessor libs.jmh.annotations
}
targets {
all {
testTask.configure {
testLogging {
events "passed", "skipped", "failed"
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
debug {
events "started","passed", "skipped", "failed", "standard_out", "standard_error"
showStandardStreams = true
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
}
info = debug
}
}
}
}
sources {
java {
srcDirs += [ "$buildDir/generated/src/main/java", "$buildDir/generated-version/src/main/java"]
}
}
}
}
}
mavenPublishing {
// To publish, make sure the following env vars are set
//
// ORG_GRADLE_PROJECT_mavenCentralUsername
// ORG_GRADLE_PROJECT_mavenCentralPassword
//
// To sign, make sure the following properties are set
//
// signing.secretKeyRingFile=(keyring location - e.g. output of `gpg --no-default-keyring --keyring secring.gpg --export-secret-keys <LONGID> >/tmp/keyring.gpg`)
// signing.password=(****)
// signing.keyId=(8 digit keyid)
//
// Also make sure that corresponding public key has been published to hkp://keys.openpgp.org, hkp://pgp.mit.edu, etc.
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
configure(new JavaLibrary(new JavadocJar.Javadoc(), true))
pom {
description = project.description
name = project.name
url = "https://github.com/harness/ff-java-server-sdk"
licenses {
license {
name = "Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}
scm {
developerConnection = "scm:git:ssh://https://github.com/harness/ff-java-server-sdk.git"
connection = "scm:git:ssh://https://github.com/harness/ff-java-server-sdk.git"
url = "https://github.com/drone/ff-java-server-sdk"
}
developers {
developer {
id = "andybharness"
name = "Andrew Bell"
email = "andrew.bell@harness.io"
organization = "Harness Inc"
organizationUrl = "https://www.harness.io/"
}
developer {
id = "davejohnston"
name = "Dave Johnston"
email = "dave.johnston@harness.io"
organization = "Harness Inc"
organizationUrl = "https://www.harness.io/"
}
developer {
id = "enver-bisevac"
name = "Enver Bisevac"
email = "enver.bisevac@harness.io"
organization = "Harness Inc"
organizationUrl = "https://www.harness.io/"
}
developer {
id = "rushabh-harness"
name = "Rushabh Shah"
email = "rushabh@harness.io"
organization = "Harness Inc"
organizationUrl = "https://www.harness.io/"
}
developer {
id = "hannah-tang"
name = "Hannah Tang"
email = "hannah.tang@harness.io"
organization = "Harness Inc"
organizationUrl = "https://www.harness.io/"
}
developer {
id = "subiradhikari"
name = "Subir Adhikari"
email = "subir.adhikari@harness.io"
organization = "Harness Inc"
organizationUrl = "https://www.harness.io/"
}
}
}
}
spotless {
java {
targetExclude(fileTree("$buildDir/generated"), fileTree("$buildDir/generated-version") { include("**/*.java") })
removeUnusedImports()
googleJavaFormat().formatJavadoc(false)
}
}
dependencyCheck {
formats = [ "HTML", "JSON" ]
nvd {
apiKey = System.getenv("FF_NVD_API_KEY")
validForHours = 144
}
}
compileJava.dependsOn tasks.openApiGenerate
compileJava.dependsOn generateVersion
compileJava.dependsOn spotlessApply
jacocoTestReport.dependsOn test
spotbugsTest.enabled = false
spotbugsMain.enabled = false
sourceSets.main.java.srcDirs += [ "$buildDir/generated/src/main/java", "$buildDir/generated-version/src/main/java" ]
tasks.withType(Javadoc).configureEach {
options.addStringOption('Xdoclint:none', '-quiet')
}
tasks.named("sourcesJar") {
dependsOn(tasks.named("generateVersion"))
}
wrapper {
gradleVersion = '9.3.0'
distributionType = Wrapper.DistributionType.ALL
}
tasks.named("generatePomFileForMavenPublication").configure {
def publication = publishing.publications.maven
destination = rootProject.file("${publication.artifactId}-${publication.version}.pom")
}