-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
155 lines (130 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.ByteArrayOutputStream
plugins {
kotlin("jvm") version "2.0.20"
id("org.jetbrains.dokka") version "1.9.20"
id("com.github.ben-manes.versions") version "0.51.0"
`maven-publish`
`java-library`
signing
}
group = "tv.blademaker"
val gitTag: String? by lazy {
try {
val stdout = ByteArrayOutputStream()
rootProject.exec {
commandLine("git", "describe", "--tags", "--abbrev=0")
standardOutput = stdout
}
stdout.toString().trim()
} catch(e: Throwable) {
null
}
}
val gitHash: String by lazy {
val stdout = ByteArrayOutputStream()
rootProject.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}
stdout.toString().trim()
}
val isSnapshot = System.getenv("OSSRH_SNAPSHOT") != null
version = (gitTag ?: gitHash).plus(if (isSnapshot) "-SNAPSHOT" else "")
repositories {
mavenCentral()
maven("https://m2.dv8tion.net/releases")
maven("https://jitpack.io")
}
dependencies {
implementation(kotlin("stdlib", "2.0.20"))
implementation(kotlin("reflect", "2.0.20"))
compileOnly(libs.coroutines.core)
api(libs.reflections)
compileOnly(libs.jda) { exclude(module = "opus-java") }
implementation(libs.slf4j)
implementation(libs.sentry)
compileOnly(libs.prometheus)
testImplementation("junit:junit:4.13.2")
testImplementation("ch.qos.logback:logback-classic:1.5.10")
}
val dokkaOutputDir = "$buildDir/dokka"
tasks {
withType<KotlinCompile> {
this.kotlinOptions.jvmTarget = "11"
}
getByName<org.jetbrains.dokka.gradle.DokkaTask>("dokkaHtml") {
outputDirectory.set(file(dokkaOutputDir))
}
}
val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
delete(dokkaOutputDir)
}
val javadocJar = tasks.register<Jar>("javadocJar") {
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}
java {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
withSourcesJar()
}
val mavenCentralRepository = if (isSnapshot)
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
else
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
publishing {
repositories {
maven {
name = "MavenCentral"
url = uri(mavenCentralRepository)
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}
publications {
create<MavenPublication>("MavenCentral") {
artifactId = "slash"
groupId = project.group as String
version = project.version as String
from(components["java"])
artifact(javadocJar)
pom {
name.set(project.name)
description.set("Advanced Slash Command handler for Discord and JDA")
url.set("https://github.com/Blad3Mak3r/Slash")
issueManagement {
system.set("GitHub")
url.set("https://github.com/Blad3Mak3r/Slash/issues")
}
licenses {
license {
name.set("Apache License 2.0")
url.set("https://github.com/Blad3Mak3r/Slash/LICENSE.txt")
distribution.set("repo")
}
}
scm {
url.set("https://github.com/Blad3Mak3r/Slash")
connection.set("https://github.com/Blad3Mak3r/Slash.git")
developerConnection.set("scm:git:ssh://git@github.com:Blad3Mak3r/Slash.git")
}
developers {
developer {
name.set("Juan Luis Caro")
url.set("https://github.com/Blad3Mak3r")
}
}
}
}
}
}
val canSign = System.getenv("SIGNING_KEY_ID") != null
if (canSign) {
signing {
sign(publishing.publications["MavenCentral"])
}
}