forked from avro-kotlin/avro4k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
164 lines (143 loc) · 4.21 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
mavenCentral()
mavenLocal()
google()
gradlePluginPortal()
}
}
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.kotest)
alias(libs.plugins.github.versions)
alias(libs.plugins.nexus.publish)
}
repositories {
mavenCentral()
google()
}
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(kotlin("reflect"))
implementation(libs.xerial.snappy)
testImplementation(libs.kotest.junit5)
testImplementation(libs.kotest.core)
testImplementation(libs.kotest.json)
testImplementation(libs.kotest.property)
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.apiVersion = "1.5"
kotlinOptions.languageVersion = "1.5"
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
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"))
}
//Configuration for publication on maven central
val signingKey: String? by project
val signingPassword: String? by project
val publications: PublicationContainer = (extensions.getByName("publishing") as PublishingExtension).publications
signing {
useGpgCmd()
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
if (Ci.isRelease) {
sign(publications)
}
}
nexusPublishing {
this.repositories {
sonatype()
}
}
publishing {
publications {
register("mavenJava", MavenPublication::class) {
from(components["java"])
pom {
val projectUrl = "https://github.com/avro-kotlin/avro4k"
name.set("avro4k-core")
description.set("Avro format support for 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("mail@thorsten-hake.com")
}
developer {
id.set("chuckame")
name.set("Antoine Michaud")
email.set("contact@antoine-michaud.fr")
}
}
}
}
}
}
fun Project.publishing(action: PublishingExtension.() -> Unit) =
configure(action)
fun Project.signing(configure: SigningExtension.() -> Unit): Unit =
configure(configure)
object Ci {
// this is the version used for building snapshots
// .buildnumber-snapshot will be appended
private const val snapshotBase = "1.9.0"
private val githubBuildNumber = System.getenv("GITHUB_RUN_NUMBER")
private val snapshotVersion = when (githubBuildNumber) {
null -> "$snapshotBase-SNAPSHOT"
else -> "$snapshotBase.${githubBuildNumber}-SNAPSHOT"
}
private val releaseVersion = System.getenv("RELEASE_VERSION")
val isRelease = releaseVersion != null
val publishVersion = releaseVersion ?: snapshotVersion
}