-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
162 lines (138 loc) · 4.79 KB
/
build.gradle.kts
File metadata and controls
162 lines (138 loc) · 4.79 KB
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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.shadow)
alias(libs.plugins.sonatype.central.portal.publisher)
`maven-publish`
}
allprojects {
group = "app.simplecloud.plugin"
version = determineVersion()
repositories {
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://oss.sonatype.org/content/repositories/central")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://jitpack.io")
}
}
subprojects {
apply {
plugin("org.jetbrains.kotlin.jvm")
plugin("com.gradleup.shadow")
plugin("net.thebugmc.gradle.sonatype-central-portal-publisher")
plugin("maven-publish")
}
dependencies {
compileOnly(rootProject.libs.kotlin.jvm)
compileOnly(rootProject.libs.kotlin.test)
compileOnly(rootProject.libs.luckperms.api)
compileOnly(rootProject.libs.custom.names.api)
implementation(rootProject.libs.adventure.api)
implementation(rootProject.libs.adventure.text.minimessage)
implementation(rootProject.libs.gson)
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(21)
compilerOptions {
jvmTarget = JvmTarget.JVM_21
languageVersion = KotlinVersion.KOTLIN_2_0
apiVersion = KotlinVersion.KOTLIN_2_0
}
}
tasks.shadowJar {
mergeServiceFiles()
archiveFileName.set("${project.name}.jar")
}
centralPortal {
name = project.name
username = project.findProperty("sonatypeUsername") as? String
password = project.findProperty("sonatypePassword") as? String
pom {
name.set("SimpleCloud Prefixes Plugin")
description.set("Plugin/Extension for Paper or Minestom, that manages prefixes or suffixes in the tab.")
url.set("https://github.com/simplecloudapp/prefixes-plugin")
developers {
developer {
id.set("SimpleCloud Developers")
}
}
licenses {
license {
name.set("Apache-2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
url.set("https://github.com/simplecloudapp/prefixes-plugin.git")
connection.set("git:git@github.com:simplecloudapp/prefixes-plugin.git")
}
}
}
publishing {
repositories {
maven {
name = "simplecloud"
url = uri(determineRepositoryUrl())
credentials {
username = System.getenv("SIMPLECLOUD_USERNAME")
?: (project.findProperty("simplecloudUsername") as? String)
password = System.getenv("SIMPLECLOUD_PASSWORD")
?: (project.findProperty("simplecloudPassword") as? String)
}
authentication {
create<BasicAuthentication>("basic")
}
}
}
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
}
if(project.name != "prefixes-api")
{
publishing.publications.remove(publishing.publications["mavenJava"])
}
signing {
val releaseType = project.findProperty("releaseType")?.toString() ?: "snapshot"
if (releaseType != "release") {
return@signing
}
if (hasProperty("signingPassphrase")) {
val signingKey: String? by project
val signingPassphrase: String? by project
useInMemoryPgpKeys(signingKey, signingPassphrase)
} else {
useGpgCmd()
}
sign(publishing.publications)
}
}
fun determineVersion(): String {
val baseVersion = project.findProperty("baseVersion")?.toString() ?: "0.0.0"
val releaseType = project.findProperty("releaseType")?.toString() ?: "snapshot"
val commitHash = System.getenv("COMMIT_HASH") ?: "local"
return when (releaseType) {
"release" -> baseVersion
"rc" -> "$baseVersion-rc.$commitHash"
"snapshot" -> "$baseVersion-SNAPSHOT.$commitHash"
else -> "$baseVersion-SNAPSHOT.local"
}
}
fun determineRepositoryUrl(): String {
val baseUrl = "https://repo.simplecloud.app"
return when (project.findProperty("releaseType")?.toString() ?: "snapshot") {
"release" -> "$baseUrl/releases"
"rc" -> "$baseUrl/rc"
else -> "$baseUrl/snapshots"
}
}