-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
138 lines (120 loc) · 4.02 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
/*
* Copyright (c) 2024-Present Perracodex. Use of this source code is governed by an MIT license.
*/
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.SonatypeHost
import org.gradle.configurationcache.extensions.capitalized
plugins {
`java-library`
signing
alias(libs.plugins.dokka)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.vanniktech)
alias(libs.plugins.detekt)
}
group = project.properties["group"] as String
version = project.properties["version"] as String
repositories {
mavenCentral()
mavenLocal()
}
// Configure Detekt for static code analysis.
detekt {
buildUponDefaultConfig = true
allRules = true
config.setFrom("$rootDir/config/detekt/detekt.yml")
}
// Configure Detekt task reports.
tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
reports {
html.required.set(true)
xml.required.set(false)
sarif.required.set(true)
}
}
kotlin {
jvmToolchain(jdkVersion = 17)
// Enable explicit API mode.
// https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md
// https://kotlinlang.org/docs/whatsnew14.html#explicit-api-mode-for-library-authors
explicitApi()
compilerOptions {
extraWarnings.set(true)
}
}
dependencies {
detektPlugins(libs.detekt.formatting)
implementation(libs.exposed.core)
implementation(libs.kotlinx.serialization)
implementation(libs.ktor.server.core)
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
// https://central.sonatype.com/account
// https://central.sonatype.com/publishing/deployments
// https://vanniktech.github.io/gradle-maven-publish-plugin/central/#automatic-release
mavenPublishing {
val artifactId: String = project.properties["artifactId"] as String
val repository: String = project.properties["repository"] as String
val repositoryConnection: String = project.properties["repositoryConnection"] as String
val developer: String = project.properties["developer"] as String
val pomName: String = project.properties["pomName"] as String
val pomDescription: String = project.properties["pomDescription"] as String
configure(
KotlinJvm(
javadocJar = JavadocJar.Dokka("dokkaGeneratePublicationHtml"),
sourcesJar = true,
)
)
coordinates(
groupId = group as String,
artifactId = artifactId,
version = version as String
)
publishToMavenCentral(
host = SonatypeHost.CENTRAL_PORTAL,
automaticRelease = false
)
signAllPublications()
pom {
name.set(pomName)
description.set(pomDescription)
url.set("https://$repository/$artifactId")
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set(developer)
name.set(developer.capitalized())
email.set(System.getenv("DEVELOPER_EMAIL"))
url = "https://$repository"
}
}
scm {
connection.set("scm:git:git://$repository/$artifactId.git")
developerConnection.set("scm:git:ssh://$repositoryConnection/$artifactId.git")
url.set("https://$repository/$artifactId")
}
}
}
signing {
val privateKeyPath: String? = System.getenv("MAVEN_SIGNING_KEY_PATH")
val passphrase: String? = System.getenv("MAVEN_SIGNING_KEY_PASSPHRASE")
if (privateKeyPath.isNullOrBlank()) {
println("MAVEN_SIGNING_KEY_PATH is not set. Skipping signing.")
} else if (passphrase.isNullOrBlank()) {
println("MAVEN_SIGNING_KEY_PASSPHRASE is not set. Skipping signing.")
} else {
val privateKey: String = File(privateKeyPath).readText()
useInMemoryPgpKeys(privateKey, passphrase)
sign(publishing.publications)
}
}