-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.gradle.kts
233 lines (207 loc) · 6.97 KB
/
build.gradle.kts
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
import net.ltgt.gradle.errorprone.errorprone
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.sonarqube.gradle.SonarTask
plugins {
alias(libs.plugins.sonarqube)
alias(libs.plugins.test.logger)
alias(libs.plugins.nexus.publish)
alias(libs.plugins.jmh)
alias(libs.plugins.errorprone)
alias(libs.plugins.mrjar)
`maven-publish`
`java-library`
signing
jacoco
}
description = "High-performance JSON masker in Java with no runtime dependencies"
if (version == "unspecified") {
version = "0.1.0-SNAPSHOT"
}
group = "dev.blaauwendraad"
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withJavadocJar()
withSourcesJar()
}
multiRelease {
targetVersions(11, 17)
}
dependencies {
api(libs.jspecify)
"java17Implementation"(libs.jspecify)
testImplementation(libs.assertj.core)
testImplementation(libs.jackson.databind)
testImplementation(libs.junit.api)
testImplementation(libs.junit.params)
testRuntimeOnly(libs.junit.engine)
jmh(libs.jmh.core)
jmhAnnotationProcessor(libs.jmh.generator.annproccesor)
errorprone(libs.nullaway)
errorprone(libs.errorprone.core)
}
publishing {
repositories {
maven {
val url = if (version.toString().endsWith("SNAPSHOT")) {
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
}
setUrl(url)
}
}
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
pom {
name = project.name
description = project.description
url = "https://github.com/Breus/json-masker"
licenses {
license {
name = "MIT License"
url = "https://opensource.org/license/mit/"
}
}
developers {
developer {
id = "breus"
name = "Breus Blaauwendraad"
email = "[email protected]"
}
developer {
id = "gavlyukovskiy"
name = "Artur Havliukovskyi"
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com/Breus/json-masker.git"
url = "https://github.com/Breus/json-masker"
}
issueManagement {
url = "https://github.com/Breus/json-masker/issues"
}
}
}
}
}
val sonatypeUsername = System.getenv("SONATYPE_TOKEN_USERNAME")
val sonatypePassword = System.getenv("SONATYPE_TOKEN_PASSWORD")
val gpgKey = System.getenv("GPG_PRIV_KEY")
val gpgPassphrase = System.getenv("GPG_PASS_PHRASE")
nexusPublishing {
repositories {
sonatype {
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
username = sonatypeUsername
password = sonatypePassword
}
}
}
signing {
isRequired = gpgKey != null
useInMemoryPgpKeys(gpgKey, gpgPassphrase)
sign(*publishing.publications.toTypedArray())
}
jmh {
fun listOfProperty(vararg values: String) = rootProject.objects.listProperty<String>().value(values.toList())
// run this with ./gradlew jmh -PjmhShort to only run these parameters and 4 iterations
if (project.hasProperty("jmhShort")) {
benchmarkParameters = mapOf(
"jsonSize" to listOfProperty("1kb"),
"maskedKeyProbability" to listOfProperty("0.1"),
"jsonPath" to listOfProperty("false", "true"),
"characters" to listOfProperty("unicode"),
"numberOfTargetKeys" to listOfProperty("1000"),
"keyLength" to listOfProperty("100"),
)
iterations = 4
}
// if you have async profiler installed, you can provide it to generate flamegraphs
// ./gradlew jmh -PjmhAsyncProfilerLibPath=/workspace/async-profiler/lib/libasyncProfiler.so (for MacOS - libasyncProfiler.dylib)
// the results will be stored in build/results/jmh/async-profiler and can be opened in IDEA or Java Flight Recorder
if (project.hasProperty("jmhAsyncProfilerLibPath")) {
profilers = listOfProperty("async:libPath=${project.property("jmhAsyncProfilerLibPath")};output=jfr;dir=build/results/jmh/async-profiler")
} else {
profilers = listOfProperty("gc")
}
}
sonar {
properties {
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.organization", "breus")
property("sonar.projectKey", "Breus_json-masker")
}
}
tasks {
compileJava {
sourceCompatibility = "11"
targetCompatibility = "11"
}
compileTestJava {
sourceCompatibility = "17"
targetCompatibility = "17"
}
test {
useJUnitPlatform()
}
withType<JavaCompile>().configureEach {
options.errorprone {
error(
"CheckedExceptionNotThrown",
"FunctionalInterfaceClash",
"NonFinalStaticField",
"NullAway",
"RedundantOverride",
"RedundantThrows",
"RemoveUnusedImports",
"DefaultCharset",
"UnnecessarilyFullyQualified",
"UnnecessarilyUsedValue",
"UnnecessaryBoxedAssignment",
"UnnecessaryBoxedVariable",
"UnnecessaryFinal",
"UnusedException",
"UnusedLabel",
"UnusedMethod",
"UnusedNestedClass",
"UnusedVariable",
"WildcardImport",
)
if (DefaultNativePlatform.getCurrentOperatingSystem().isWindows) {
disable("MisleadingEscapedSpace") // good stuff
}
disable(
"StringCaseLocaleUsage",
"MissingSummary",
)
option("NullAway:JSpecifyMode")
option("NullAway:AnnotatedPackages", "dev.blaauwendraad.masker")
excludedPaths = ".*/build/generated/.*"
}
options.encoding = "UTF-8"
}
javadoc {
val options = options as StandardJavadocDocletOptions
options.addBooleanOption("html5", true)
options.addStringOption("Xdoclint:all,-missing", "-quiet")
}
jacocoTestReport {
reports {
xml.required = true
}
}
withType<SonarTask> {
dependsOn(jacocoTestReport)
}
}