forked from webauthn4j/webauthn4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
274 lines (240 loc) · 9.55 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
274 lines (240 loc) · 9.55 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
import org.asciidoctor.gradle.jvm.AsciidoctorTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.jvm.tasks.Jar
import java.net.URI
import java.nio.charset.StandardCharsets
plugins {
id("java-library")
id("signing")
id("maven-publish")
id("jacoco")
id(libs.plugins.asciidoctor.get().pluginId) version libs.versions.asciidoctor
id(libs.plugins.sonarqube.get().pluginId) version libs.versions.sonarqube
}
val webAuthn4JVersion: String by project
val latestReleasedWebAuthn4JVersion: String by project
allprojects {
group = "com.webauthn4j"
version = webAuthn4JVersion
repositories {
mavenCentral()
maven(url = "https://jitpack.io")
}
}
subprojects {
apply(plugin = "java-library")
apply(plugin = "signing")
apply(plugin = "maven-publish")
apply(plugin = "jacoco")
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11 // Although webauthn4j uses JDK 15+ API to support EdDSA, keep target version 11 to support JDK11 users who don't need EdDSA.
}
tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed") //, "standardOut", "standardError"
showExceptions = true
exceptionFormat = TestExceptionFormat.FULL
showCauses = true
showStackTraces = true
showStandardStreams = false
}
}
tasks.javadoc{
options {
charset("UTF-8")
encoding("UTF-8")
}
}
tasks.register<Jar>("javadocJar") {
group = "build"
description = "Assembles Javadoc jar"
dependsOn(tasks.named("javadoc"))
archiveClassifier = "javadoc"
from(tasks.named<Javadoc>("javadoc").get().destinationDir)
}
tasks.register<Jar>("sourcesJar") {
group = "build"
description = "Assembles sources jar"
archiveClassifier = "sources"
from(sourceSets.main.get().allSource)
}
tasks.jacocoTestReport {
reports {
xml.required = true
}
}
fun getVariable(envName: String, propertyName: String): String?{
return if (System.getenv(envName) != null && System.getenv(envName).isNotEmpty()) {
System.getenv(envName)
} else if (project.hasProperty(propertyName)) {
project.property(propertyName) as String?
} else {
null
}
}
val githubUrl = "https://github.com/webauthn4j/webauthn4j"
val mavenCentralUser = getVariable("MAVEN_CENTRAL_USER", "mavenCentralUser")
val mavenCentralPassword = getVariable("MAVEN_CENTRAL_PASSWORD", "mavenCentralPassword")
val pgpSigningKey = getVariable("PGP_SIGNING_KEY", "pgpSigningKey")
val pgpSigningKeyPassphrase = getVariable("PGP_SIGNING_KEY_PASSPHRASE", "pgpSigningKeyPassphrase")
publishing {
publications{
create<MavenPublication>("standard") {
from(components["java"])
artifact(tasks.named("sourcesJar"))
artifact(tasks.named("javadocJar"))
// "Resolved versions" strategy is used to define dependency version because WebAuthn4J use dependencyManagement (BOM) feature
// to define its dependency versions. Without "Resolved versions" strategy, version will not be exposed
// to dependencies.dependency.version in POM file, and it cause warning in the library consumer environment.
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
pom {
name = project.name
//description = project.description.toString() //TODO: this doesn't work. to be fixed. https://github.com/gradle/gradle/issues/12259
url = githubUrl
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}
developers {
developer {
id = "ynojima"
name = "Yoshikazu Nojima"
email = "mail@ynojima.net"
}
}
scm {
url = githubUrl
}
}
pom.withXml{
asNode().appendNode("description", project.description) // workaround for https://github.com/gradle/gradle/issues/12259
}
}
}
repositories {
maven {
name = "mavenCentral"
url = URI("https://oss.sonatype.org/service/local/staging/deploy/maven2")
credentials {
username = "${mavenCentralUser}"
password = "${mavenCentralPassword}"
}
}
maven {
name = "snapshot"
url = URI("https://oss.sonatype.org/content/repositories/snapshots")
credentials {
username = "${mavenCentralUser}"
password = "${mavenCentralPassword}"
}
}
}
signing {
useInMemoryPgpKeys(pgpSigningKey, pgpSigningKeyPassphrase)
sign(publishing.publications["standard"])
}
tasks.withType(Sign::class.java).configureEach {
onlyIf { pgpSigningKey != null && pgpSigningKeyPassphrase != null }
}
tasks.named("publishStandardPublicationToSnapshotRepository"){
onlyIf{ webAuthn4JVersion.endsWith("-SNAPSHOT") }
}
tasks.named("publishStandardPublicationToMavenCentralRepository"){
onlyIf{ !webAuthn4JVersion.endsWith("-SNAPSHOT") }
}
}
}
tasks.register("updateVersionsInDocuments"){
group = "documentation"
description = "Update versions in document source code"
val regex = Regex("""<webauthn4j\.version>.*</webauthn4j\.version>""")
val replacement = "<webauthn4j.version>$latestReleasedWebAuthn4JVersion</webauthn4j.version>"
val files = arrayOf(file("README.md"), file("docs/src/reference/asciidoc/en/introduction.adoc"), file("docs/src/reference/asciidoc/ja/introduction.adoc"), file("docs/src/reference/asciidoc/en/quick-start.adoc"), file("docs/src/reference/asciidoc/ja/quick-start.adoc"))
files.forEach { file ->
val updated = file.readText(StandardCharsets.UTF_8).replaceFirst(regex, replacement)
file.writeText(updated, StandardCharsets.UTF_8)
}
}
tasks.register<JavaExec>("generateReleaseNote") {
group = "documentation"
description = "Generate release note"
classpath = files("gradle/lib/github-release-notes-generator.jar")
args(webAuthn4JVersion, file("build/release-note.md").absolutePath, "--spring.config.location=file:" + file("github-release-notes-generator.yml").absolutePath)
}
asciidoctorj{
modules{
diagram.use()
diagram.version("2.3.1")
}
attributes(mapOf("source-highlighter" to "rouge"))
}
tasks.register<AsciidoctorTask>("generateReferenceJA") {
group = "documentation"
description = "Generate reference (ja)"
baseDirFollowsSourceDir()
setSourceDir(file("docs/src/reference/asciidoc/ja"))
setOutputDir(file("build/docs/asciidoc/html5/ja"))
options(mapOf("eruby" to "erubis"))
//noinspection GroovyAssignabilityCheck
attributes(mapOf(
"docinfo" to "",
"copycss" to "",
"icons" to "font",
"source-highlighter" to "prettify",
"sectanchors" to "",
"toc2" to "",
"idprefix" to "",
"idseparator" to "-",
"doctype" to "book",
"numbered" to "",
"revnumber" to webAuthn4JVersion
))
}
tasks.register<AsciidoctorTask>("generateReferenceEN") {
group = "documentation"
description = "Generate reference (en)"
baseDirFollowsSourceDir()
setSourceDir(file("docs/src/reference/asciidoc/en"))
setOutputDir(file("build/docs/asciidoc/html5/en"))
options(mapOf("eruby" to "erubis"))
//noinspection GroovyAssignabilityCheck
attributes(mapOf(
"docinfo" to "",
"copycss" to "",
"icons" to "font",
"source-highlighter" to "prettify",
"sectanchors" to "",
"toc2" to "",
"idprefix" to "",
"idseparator" to "-",
"doctype" to "book",
"numbered" to "",
"revnumber" to webAuthn4JVersion
))
}
sonarqube {
properties {
property("sonar.projectKey", "webauthn4j")
property("sonar.issue.ignore.multicriteria", "e1,e2,e3,e4")
property("sonar.issue.ignore.multicriteria.e1.ruleKey", "java:S110")
property("sonar.issue.ignore.multicriteria.e1.resourceKey", "**/*.java")
property("sonar.issue.ignore.multicriteria.e2.ruleKey", "java:S1452")
property("sonar.issue.ignore.multicriteria.e2.resourceKey", "**/*.java")
property("sonar.issue.ignore.multicriteria.e3.ruleKey", "common-java:DuplicatedBlocks")
property("sonar.issue.ignore.multicriteria.e3.resourceKey", "**/*.java")
property("sonar.issue.ignore.multicriteria.e4.ruleKey", "java:S5778")
property("sonar.issue.ignore.multicriteria.e4.resourceKey", "**/*.java")
}
}