-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
225 lines (183 loc) · 6 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
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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
object Meta {
const val PROJECT_VERSION = "0.3.0-rc.2"
const val DESCRIPTION = "Generate documentation for KordEx bots!"
const val GITHUB_REPO = "HyacinthBots/doc-generator"
const val RELEASE = "https://s01.oss.sonatype.org/content/repositories/releases/"
const val SNAPSHOT = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
val version: String
get() {
val tag = System.getenv("GITHUB_TAG_NAME")
val branch = System.getenv("GITHUB_BRANCH_NAME")
return when {
!tag.isNullOrBlank() -> tag
!branch.isNullOrBlank() && branch.startsWith("refs/heads/") ->
"$PROJECT_VERSION-SNAPSHOT"
else -> "undefined"
}
}
val isSnapshot: Boolean get() = version.endsWith("-SNAPSHOT")
val isRelease: Boolean get() = !isSnapshot && !isUndefined
private val isUndefined: Boolean get() = version == "undefined"
}
plugins {
`java-library`
`maven-publish`
signing
alias(libs.plugins.kotlin)
alias(libs.plugins.detekt)
alias(libs.plugins.git.hooks)
alias(libs.plugins.licenser)
alias(libs.plugins.binary.compatibility.validator)
alias(libs.plugins.kordex.plugin)
}
group = "org.hyacinthbots"
version = Meta.PROJECT_VERSION
val javaVersion = 13 // KordEx minimum pinned Java version
repositories {
mavenCentral()
maven {
name = "Kord Snapshots"
url = uri("https://repo.kord.dev/snapshots")
}
maven {
name = "Kord Extensions (Snapshots)"
url = uri("https://snapshots-repo.kordex.dev")
}
maven {
name = "Kord Extensions (Releases)"
url = uri("https://releases-repo.kordex.dev")
}
maven {
name = "Sonatype Snapshots (Legacy)"
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
maven {
name = "Sonatype Snapshots"
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
}
}
dependencies {
detektPlugins(libs.detekt)
implementation(libs.kotlin.stdlib)
implementation(libs.logging)
testImplementation(kotlin("test"))
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(kotlin("test-junit5"))
testRuntimeOnly(libs.junit.jupiter.engine)
}
kordEx {
kordExVersion = "2.3.1-20241123.224536-17"
ignoreIncompatibleKotlinVersion = true
i18n {
classPackage = "docgenerator.i18n"
translationBundle = "doc-generator.strings"
publicVisibility = false
}
}
gitHooks {
setHooks(
mapOf("pre-commit" to "clean apiCheck updateLicense detekt")
)
}
kotlin {
explicitApi()
}
java {
withJavadocJar()
withSourcesJar()
}
tasks {
test {
useJUnitPlatform()
}
withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString()))
languageVersion.set(KotlinVersion.fromVersion(libs.plugins.kotlin.get().version.requiredVersion.substringBeforeLast(".")))
incremental = true
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}
}
withType<JavaCompile> {
options.encoding = "UTF-8"
options.isDeprecation = true
options.release.set(javaVersion)
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
}
detekt {
buildUponDefaultConfig = true
config.from(files("$rootDir/detekt.yml"))
autoCorrect = true
}
license {
setHeader(rootProject.file("HEADER"))
include("**/*.kt", "**/*.java", "**/strings**.properties")
exclude("**/Translations.kt")
}
signing {
val signingKey = providers.environmentVariable("GPG_SIGNING_KEY")
val signingPass = providers.environmentVariable("GPG_SIGNING_PASS")
if (signingKey.isPresent && signingPass.isPresent) {
useInMemoryPgpKeys(signingKey.get(), signingPass.get())
val extension = extensions.getByName("publishing") as PublishingExtension
sign(extension.publications)
}
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = project.name
version = Meta.version
from(components["kotlin"])
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
pom {
name.set(project.name)
description.set(Meta.DESCRIPTION)
url.set("https://github.com/${Meta.GITHUB_REPO}")
organization {
name.set("HyacinthBots")
url.set("https://github.com/HyacinthBots")
}
developers {
developer {
name.set("The HyacinthBots team")
}
}
issueManagement {
system.set("GitHub")
url.set("https://github.com/${Meta.GITHUB_REPO}/issues")
}
licenses {
license {
name.set("MIT")
url.set("https://mit-license.org/")
}
}
scm {
url.set("https://github.com/${Meta.GITHUB_REPO}.git")
connection.set("scm:git:git://github.com/${Meta.GITHUB_REPO}.git")
developerConnection.set("scm:git:git://github.com/#${Meta.GITHUB_REPO}.git")
}
}
}
}
repositories {
maven {
url = uri(if (Meta.isSnapshot) Meta.SNAPSHOT else Meta.RELEASE)
credentials {
username = System.getenv("NEXUS_USER")
password = System.getenv("NEXUS_PASSWORD")
}
}
}
}