-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
105 lines (91 loc) · 2.81 KB
/
build.gradle.kts
File metadata and controls
105 lines (91 loc) · 2.81 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
import groovy.json.JsonSlurper
import org.gradle.api.GradleException
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
plugins {
kotlin("jvm") version "2.2.20-RC"
id("com.gradleup.shadow") version "8.3.0"
id("xyz.jpenilla.run-paper") version "2.3.1"
id("com.modrinth.minotaur") version "2.+"
}
group = "com.cyr1en"
version = "1.0.2"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/") {
name = "papermc-repo"
}
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.github.erosb:everit-json-schema:1.14.6")
implementation("com.h2database:h2:2.3.232")
implementation("com.zaxxer:HikariCP:5.1.0")
}
tasks {
runServer {
minecraftVersion("1.21.8")
}
}
val targetJavaVersion = 21
kotlin {
jvmToolchain(targetJavaVersion)
}
tasks.shadowJar {
archiveClassifier.set("")
val shadeBase = "${project.group}.shade"
relocate("com.zaxxer.hikari", "$shadeBase.hikari")
relocate("org.h2", "$shadeBase.h2")
relocate("org.everit.json.schema", "$shadeBase.schema")
}
tasks.build {
dependsOn("shadowJar")
}
tasks.jar {
enabled = false
}
tasks.processResources {
val props = mapOf("version" to version)
inputs.properties(props)
filteringCharset = "UTF-8"
filesMatching("paper-plugin.yml") {
expand(props)
}
}
// Only to be used when a new release is ready to be published on GitHub.
// Automated via GitHub Actions.
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("3C31Qs54")
versionNumber.set(project.version.toString())
versionType.set("release")
uploadFile.set(tasks.shadowJar)
changelog.set(githubLatestReleaseBody())
gameVersions.addAll("1.21.8", "1.21.7")
loaders.add("paper")
syncBodyFrom.set(rootProject.file("README.md").readText(Charsets.UTF_8))
}
tasks.modrinth {
dependsOn(tasks.modrinthSyncBody)
}
fun githubLatestReleaseBody(): String {
val url = "https://api.github.com/repos/cyr1en/cardea/releases/latest"
val client = HttpClient.newHttpClient()
val request =
HttpRequest
.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/vnd.github+json")
.header("User-Agent", "gradle-build-script")
.GET()
.build()
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
if (response.statusCode() / 100 != 2) {
throw GradleException("Failed to fetch latest release: HTTP ${response.statusCode()} - ${response.body()}")
}
val json = JsonSlurper().parseText(response.body()) as Map<*, *>
return (json["body"] as String?) ?: ""
}