-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
128 lines (117 loc) · 3.33 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
@file:Suppress("UnstableApiUsage")
plugins {
`java-library`
`maven-publish`
signing
alias(libs.plugins.spotless)
}
val jdkVersion = 23
val javaVersion = 17
dependencies {
api(libs.jspecify)
testImplementation(libs.assertj)
testImplementation(libs.jqwikApi)
testImplementation(libs.jqwikTime)
testImplementation(libs.junitJupiter)
testImplementation(libs.messagePack)
testRuntimeOnly(libs.jqwikEngine)
testRuntimeOnly(libs.junitLauncher)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(jdkVersion)
vendor = JvmVendorSpec.ORACLE
}
consistentResolution {
useCompileClasspathVersions()
}
withSourcesJar()
withJavadocJar()
}
tasks.withType<JavaCompile>().configureEach {
options.release = javaVersion
}
tasks.compileTestJava {
// for jqwik diagnostic messages
options.compilerArgs.add("-parameters")
}
tasks.test {
useJUnitPlatform()
}
tasks.javadoc {
val outputDir = System.getProperty("javadocDir")
if (outputDir != null) {
setDestinationDir(rootDir.resolve(outputDir))
}
with (options as StandardJavadocDocletOptions) {
docTitle("MxPack Core")
encoding("UTF-8")
memberLevel = JavadocMemberLevel.PROTECTED
links("https://jspecify.dev/docs/api/")
// https://github.com/gradle/gradle/issues/19726
val sourceSetDirectories = sourceSets.main.get().java.sourceDirectories.joinToString(":")
addStringOption("-source-path", sourceSetDirectories)
}
exclude("org/odenix/mxpack/core/internal/**")
}
spotless {
java {
licenseHeaderFile(file("../gradle/spotless/license.java"))
}
format("javaCode", com.diffplug.gradle.spotless.JavaExtension::class.java) {
targetExclude("src/test/java/org/odenix/mxpack/java/example/**")
// https://github.com/google/google-java-format/issues/1193
// googleJavaFormat(libs.versions.googleJavaFormat.get()).reflowLongStrings()
}
}
// https://docs.gradle.org/current/userguide/publishing_maven.html
// https://central.sonatype.org/publish-ea/publish-ea-guide/
publishing {
repositories {
maven {
name = "file"
url = file("build/m2").toURI()
}
}
publications {
create<MavenPublication>("maven") {
from(components["java"])
pom {
name = "mxpack-core"
description = "A modern Java library for reading and writing the MessagePack serialization format."
url = "https://github.com/odenix/mxpack"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
name = "MxPack project authors"
email = "mxpack@odenix.org"
}
}
scm {
connection = "scm:git:git://github.com/odenix/mxpack.git"
developerConnection = "scm:git:ssh://github.com/odenix/mxpack.git"
url = "https://github.com/odenix/mxpack/tree/master"
}
}
}
}
repositories {
maven {
url = project.layout.buildDirectory.dir("maven").get().asFile.toURI()
}
}
}
// https://docs.gradle.org/current/userguide/signing_plugin.html
signing {
val signingKey = System.getenv("SIGNING_KEY")
if (signingKey != null) {
val passphrase = System.getenv("PASSPHRASE")!!
useInMemoryPgpKeys(signingKey, passphrase)
sign(publishing.publications["maven"])
}
}