-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.gradle.kts
194 lines (162 loc) · 5.29 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
plugins {
val jvmVersion = libs.versions.fabric.kotlin.get()
.split("+kotlin.")[1]
.split("+")[0]
kotlin("jvm").version(jvmVersion)
kotlin("plugin.serialization").version(jvmVersion)
alias(libs.plugins.fabric.loom)
alias(libs.plugins.mod.publish)
alias(libs.plugins.shadow)
alias(libs.plugins.explosion)
`maven-publish`
java
}
val shade: Configuration by configurations.creating
repositories {
maven("https://maven.parchmentmc.org/")
maven("https://masa.dy.fi/maven")
maven("https://jitpack.io")
maven("https://repo.viaversion.com")
maven("https://api.modrinth.com/maven")
maven("https://maven.maxhenkel.de/repository/public")
maven("https://maven.andante.dev/releases/")
maven("https://maven4.bai.lol")
maven("https://maven.nucleoid.xyz")
mavenCentral()
}
val modVersion = "1.2.10"
val releaseVersion = "${modVersion}+mc${libs.versions.minecraft.get()}"
version = releaseVersion
group = "me.senseiwells"
dependencies {
minecraft(libs.minecraft)
@Suppress("UnstableApiUsage")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${libs.versions.parchment.get()}@zip")
})
modImplementation(libs.fabric.loader)
modImplementation(libs.fabric.api)
modImplementation(libs.fabric.kotlin)
include(implementation(libs.inject.api.get())!!)
include(implementation(libs.inject.http.get())!!)
include(modImplementation(libs.inject.fabric.get())!!)
modCompileOnly(libs.carpet)
modCompileOnly(libs.vmp)
modCompileOnly(explosion.fabric(libs.c2me))
modCompileOnly(libs.servux)
modCompileOnly(libs.syncmatica)
modCompileOnly(libs.voicechat)
modCompileOnly(libs.polymer.core)
compileOnly(libs.voicechat.api)
shade(implementation(libs.replay.studio.get())!!)
includeModImplementation(libs.permissions) {
exclude(libs.fabric.api.get().group)
}
}
loom {
accessWidenerPath.set(file("src/main/resources/serverreplay.accesswidener"))
runs {
getByName("server") {
runDir = "run/${libs.versions.minecraft.get()}"
}
getByName("client") {
runDir = "run/client"
}
}
}
java {
withSourcesJar()
}
tasks {
processResources {
inputs.property("version", modVersion)
filesMatching("fabric.mod.json") {
expand(mutableMapOf("version" to modVersion))
}
}
remapJar {
inputFile.set(shadowJar.get().archiveFile)
}
shadowJar {
destinationDirectory.set(File("./build/devlibs"))
isZip64 = true
from("LICENSE")
// For compatability with viaversion
relocate("assets/viaversion", "assets/replay-viaversion")
relocate("com.github.steveice10.netty", "io.netty")
exclude("com/github/steveice10/netty/**")
exclude("it/unimi/dsi/**")
exclude("org/apache/commons/**")
exclude("org/xbill/DNS/**")
exclude("com/google/**")
configurations = listOf(shade)
archiveClassifier = "shaded"
}
publishMods {
file = remapJar.get().archiveFile
changelog.set(
"""
- Fixes a compatability issue when recording polymer entities
""".trimIndent()
)
type = STABLE
modLoaders.add("fabric")
displayName = "ServerReplay $modVersion for ${libs.versions.minecraft.get()}"
version = releaseVersion
modrinth {
accessToken = providers.environmentVariable("MODRINTH_API_KEY")
projectId = "qCvSZ8ra"
minecraftVersions.add(libs.versions.minecraft)
requires {
id = "P7dR8mSH"
}
requires {
id = "Ha28R6CL"
}
optional {
id = "Vebnzrzj"
}
}
}
}
publishing {
publications {
create<MavenPublication>("ServerReplay") {
groupId = "me.senseiwells"
artifactId = "server-replay"
version = "${modVersion}+${libs.versions.minecraft.get()}"
from(components["java"])
updateReadme("./README.md")
}
}
repositories {
val mavenUrl = System.getenv("MAVEN_URL")
if (mavenUrl != null) {
maven {
url = uri(mavenUrl)
val mavenUsername = System.getenv("MAVEN_USERNAME")
val mavenPassword = System.getenv("MAVEN_PASSWORD")
if (mavenUsername != null && mavenPassword != null) {
credentials {
username = mavenUsername
password = mavenPassword
}
}
}
}
}
}
private fun DependencyHandler.includeModImplementation(provider: Provider<*>, action: Action<ExternalModuleDependency>) {
include(provider, action)
modImplementation(provider, action)
}
private fun MavenPublication.updateReadme(vararg readmes: String) {
val location = "${groupId}:${artifactId}"
val regex = Regex("""${Regex.escape(location)}:[\d\.\-a-zA-Z+]+""")
val locationWithVersion = "${location}:${version}"
for (path in readmes) {
val readme = file(path)
readme.writeText(readme.readText().replace(regex, locationWithVersion))
}
}