forked from harness/ff-java-server-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
269 lines (238 loc) · 8.66 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
buildscript {
repositories {
maven { url "https://repo1.maven.org/maven2" }
gradlePluginPortal()
}
}
plugins {
id 'java'
id 'jvm-test-suite'
id 'maven-publish'
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
}
apply plugin: 'org.openapi.generator'
allprojects {
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
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
}
// From https://stackoverflow.com/a/74205283
tasks.register("copyPomToRoot") {
def publication = publishing.publications.mavenJava
def generatePom = tasks.named("generatePomFileFor${publication.name.capitalize()}Publication")
dependsOn(generatePom)
def output = rootProject.file("${publication.artifactId}-${publication.version}.pom")
outputs.file(output)
doLast { output.bytes = generatePom.get().destination.bytes }
}
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
}
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"]
}
}
}
}
}
publishing {
repositories {
maven {
credentials {
username System.getenv("MAVEN_USERNAME") != null ? System.getenv("MAVEN_USERNAME") : ""
password System.getenv("MAVEN_PASSWORD") != null ? System.getenv("MAVEN_PASSWORD") : ""
}
def sonatypeSnapshotRepo = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
def sonatypeStagingRepo="https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
url = version.endsWith('SNAPSHOT') ? sonatypeSnapshotRepo : sonatypeStagingRepo
}
}
publications.create("mavenJava", MavenPublication) {
from components.java
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/"
}
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("publish") }
sign publishing.publications.mavenJava
}
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
sourcesJar.dependsOn tasks.openApiGenerate
sourcesJar.dependsOn generateVersion
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')
}