forked from RuiPereiraDev/SimpleScore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
135 lines (110 loc) · 4.06 KB
/
build.gradle.kts
File metadata and controls
135 lines (110 loc) · 4.06 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
import io.papermc.hangarpublishplugin.model.Platforms
import org.apache.tools.ant.filters.ReplaceTokens
import java.io.ByteArrayOutputStream
plugins {
id("maven-publish")
alias(libs.plugins.kotlin)
alias(libs.plugins.shadowJar)
alias(libs.plugins.hangar)
alias(libs.plugins.minotaur)
}
group = "com.r4g3baby"
version = "4.0.2-dev"
dependencies {
api(project("bukkit"))
}
subprojects {
group = "${rootProject.group}.${rootProject.name.lowercase()}"
version = rootProject.version
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "maven-publish")
java {
withSourcesJar()
}
}
allprojects {
kotlin {
jvmToolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
tasks {
processResources {
filteringCharset = "UTF-8"
filesMatching(listOf("**plugin.yml")) {
filter<ReplaceTokens>(
"tokens" to mapOf(
"name" to rootProject.name,
"version" to rootProject.version,
"description" to "A simple animated scoreboard plugin for your server.",
"package" to "${rootProject.group}.${rootProject.name.lowercase()}",
"website" to "https://ruipereira.dev"
)
)
}
}
}
}
tasks {
shadowJar {
archiveFileName.set("${project.name}-${project.version}.jar")
val libs = "${project.group}.${project.name.lowercase()}.lib"
relocate("org.objenesis", "$libs.objenesis")
relocate("net.swiftzer.semver", "$libs.semver")
relocate("org.bstats", "$libs.bstats")
// relocate("com.zaxxer.hikari", "$libs.hikari")
// relocate("org.slf4j", "$libs.slf4j")
relocate("org.jetbrains", "$libs.jetbrains")
relocate("kotlin", "$libs.kotlin")
from(file("LICENSE"))
dependencies {
exclude("META-INF/**")
}
minimize()
}
hangarPublish {
publications.register("plugin") {
apiKey = findProperty("hangar.token") as String? ?: System.getenv("HANGAR_TOKEN")
id = property("hangar.project") as String?
version = project.version as String
channel = "Release"
changelog = generateChangelog()
platforms {
register(Platforms.PAPER) {
jar.set(shadowJar.flatMap { it.archiveFile })
platformVersions = mapVersions("hangar.versions")
}
}
}
}
modrinth {
token = findProperty("modrinth.token") as String? ?: System.getenv("MODRINTH_TOKEN")
projectId = property("modrinth.project") as String?
uploadFile = shadowJar.get()
gameVersions = mapVersions("modrinth.versions")
loaders = arrayListOf("bukkit", "spigot", "paper", "folia")
changelog = generateChangelog()
syncBodyFrom = file("README.md").readText()
modrinth.get().dependsOn(modrinthSyncBody)
}
}
fun mapVersions(propertyName: String): Provider<List<String>> = provider {
return@provider (property(propertyName) as String).split(",").map { it.trim() }
}
fun generateChangelog(): Provider<String> = provider {
val tags = providers.exec {
commandLine("git", "tag", "--sort", "version:refname")
}.standardOutput.asText.get().trim().split("\n")
val tagsRange = if (tags.size > 1) {
"${tags[tags.size - 2]}...${tags[tags.size - 1]}"
} else if (tags.isNotEmpty()) tags[0] else "HEAD~1...HEAD"
val repoUrl = property("github.url") as String?
val changelog = ByteArrayOutputStream().apply {
write("### Commits:\n".toByteArray())
write(providers.exec {
commandLine("git", "log", tagsRange, "--pretty=format:- [%h]($repoUrl/commit/%H) %s", "--reverse")
}.standardOutput.asBytes.get())
write("\n\nCompare Changes: [$tagsRange]($repoUrl/compare/$tagsRange)".toByteArray())
}.toString(Charsets.UTF_8.name())
return@provider changelog
}