-
Notifications
You must be signed in to change notification settings - Fork 37
/
build.gradle.kts
166 lines (147 loc) · 4.52 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
plugins {
java
id("java-library")
kotlin("jvm") version libs.versions.kotlin
kotlin("plugin.serialization") version libs.versions.kotlin
id("maven-publish")
signing
alias(libs.plugins.dokka)
alias(libs.plugins.kover)
alias(libs.plugins.kotest)
alias(libs.plugins.github.versions)
alias(libs.plugins.nexus.publish)
alias(libs.plugins.spotless)
alias(libs.plugins.binary.compatibility.validator)
}
tasks {
javadoc
}
group = "com.github.avro-kotlin.avro4k"
version = Ci.publishVersion
dependencies {
api(libs.apache.avro)
api(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.okio)
testImplementation(libs.kotest.junit5)
testImplementation(libs.kotest.core)
testImplementation(libs.kotest.json)
testImplementation(libs.kotest.property)
}
kotlin {
explicitApi()
compilerOptions {
optIn = listOf("kotlin.RequiresOptIn", "kotlinx.serialization.ExperimentalSerializationApi")
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8)
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9)
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9)
freeCompilerArgs = listOf("-Xcontext-receivers")
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
tasks.named<Test>("test") {
useJUnitPlatform()
filter {
isFailOnNoMatchingTests = false
}
testLogging {
showExceptions = true
showStandardStreams = true
events =
setOf(
org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED,
org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED
)
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
tasks.named<Jar>("javadocJar") {
from(tasks.named("dokkaJavadoc"))
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
pom {
val projectUrl = "https://github.com/avro-kotlin/avro4k"
name.set("avro4k-core")
description.set("Avro binary format support for kotlin, built on top of kotlinx-serialization")
url.set(projectUrl)
scm {
connection.set("scm:git:$projectUrl")
developerConnection.set("scm:git:$projectUrl")
url.set(projectUrl)
}
licenses {
license {
name.set("Apache-2.0")
url.set("https://opensource.org/licenses/Apache-2.0")
}
}
developers {
developer {
id.set("thake")
name.set("Thorsten Hake")
email.set("[email protected]")
}
developer {
id.set("chuckame")
name.set("Antoine Michaud")
email.set("[email protected]")
}
}
}
}
}
}
nexusPublishing {
repositories {
sonatype()
}
}
signing {
if (Ci.isRelease) {
val signingKey: String? by project
val signingPassword: String? by project
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
} else {
throw IllegalStateException("No signing key or password found")
}
sign(publishing.publications)
}
}
object Ci {
// this is the version used for building snapshots
// .buildnumber-snapshot will be appended
private const val SNAPSHOT_BASE = "1.9.0"
private val githubBuildNumber = System.getenv("GITHUB_RUN_NUMBER")
private val snapshotVersion =
when (githubBuildNumber) {
null -> "$SNAPSHOT_BASE-SNAPSHOT"
else -> "$SNAPSHOT_BASE.$githubBuildNumber-SNAPSHOT"
}
private val releaseVersion = System.getenv("RELEASE_VERSION")
val isRelease = releaseVersion != null
val publishVersion = releaseVersion ?: snapshotVersion
}
spotless {
kotlin {
ktlint()
}
json {
target("src/test/resources/**.json")
prettier()
}
kotlinGradle {
ktlint()
}
}
repositories {
mavenCentral()
}