-
Notifications
You must be signed in to change notification settings - Fork 51
/
build.gradle.kts
221 lines (182 loc) · 5.58 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.loom)
alias(libs.plugins.detekt)
alias(libs.plugins.git.hooks)
alias(libs.plugins.shadow)
`maven-publish`
}
val props = properties
val modId: String by project
val modName: String by project
val modVersion: String by project
val mavenGroup: String by project
base.archivesBaseName = modId
version = "$modVersion${getVersionMetadata()}"
group = mavenGroup
sourceSets {
create("testmod") {
runtimeClasspath += sourceSets["main"].runtimeClasspath
compileClasspath += sourceSets["main"].compileClasspath
}
}
loom {
//serverOnlyMinecraftJar()
runs {
create("testmodClient") {
client()
ideConfigGenerated(project.rootProject == project)
name("Networking Testmod (Client)")
source(sourceSets.getByName("testmod"))
}
}
}
configurations.implementation.get().extendsFrom(configurations.shadow.get())
fun DependencyHandlerScope.modImplementationAndInclude(dep: Any) {
modImplementation(dep)
include(dep)
}
repositories {
maven("https://maven.fabricmc.net/")
maven("https://maven.nucleoid.xyz/")
maven("https://jitpack.io")
maven("https://oss.sonatype.org/content/repositories/snapshots")
mavenCentral()
mavenLocal()
}
dependencies {
// To change the versions see the libs.versions.toml
// Fabric
minecraft(libs.minecraft)
mappings(variantOf(libs.yarn.mappings) { classifier("v2") })
modImplementation(libs.fabric.loader)
// Fabric API
modImplementation(libs.fabric.api)
// Permissions
modImplementationAndInclude(libs.fabric.permissions)
// Translations
modImplementationAndInclude(libs.translations)
// Kotlin
modImplementation(libs.fabric.kotlin)
// Database
shadow(libs.exposed.core)
shadow(libs.exposed.dao)
shadow(libs.exposed.jdbc)
shadow(libs.exposed.java.time)
shadow(libs.sqlite.jdbc)
// Config
shadow(libs.konf.core)
shadow(libs.konf.toml)
detektPlugins(libs.detekt.formatting)
}
tasks {
val javaVersion = JavaVersion.VERSION_21
processResources {
inputs.property("id", modId)
inputs.property("name", modName)
inputs.property("version", version)
filesMatching("fabric.mod.json") {
expand(
mapOf(
"id" to modId,
"version" to version,
"name" to modName,
"fabricApi" to libs.versions.fabric.api.get(),
"fabricKotlin" to libs.versions.fabric.kotlin.get(),
"minecraft" to libs.versions.minecraft.get(),
)
)
}
}
withType<JavaCompile> {
options.encoding = "UTF-8"
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
options.release.set(javaVersion.toString().toInt())
}
compileKotlin {
kotlinOptions {
jvmTarget = javaVersion.toString()
}
}
jar {
from("LICENSE")
}
java {
toolchain { languageVersion.set(JavaLanguageVersion.of(javaVersion.toString())) }
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
withSourcesJar()
}
remapJar {
dependsOn(shadowJar)
input.set(shadowJar.get().archiveFile)
}
shadowJar {
from("LICENSE")
configurations = listOf(
project.configurations.shadow.get()
)
archiveClassifier.set("dev-all")
exclude("kotlin/**", "kotlinx/**", "javax/**")
exclude("org/checkerframework/**", "org/intellij/**", "org/jetbrains/annotations/**")
exclude("com/google/gson/**")
exclude("net/kyori/**")
exclude("org/slf4j/**")
val relocPath = "com.github.quiltservertools.libs."
relocate("com.fasterxml", relocPath + "com.fasterxml")
relocate("com.moandjiezana.toml", relocPath + "com.moandjiezana.toml")
relocate("javassist", relocPath + "javassist")
// Relocate each apache lib separately as just org.apache.commons will relocate things that aren't shadowed and break stuff
relocate("org.apache.commons.lang3", relocPath + "org.apache.commons.lang3")
relocate("org.apache.commons.text", relocPath + "org.apache.commons.text")
relocate("org.reflections", relocPath + "org.reflections")
// it appears you cannot relocate sqlite due to the native libraries
// relocate("org.sqlite", relocPath + "org.sqlite")
}
compileKotlin {
kotlinOptions {
jvmTarget = javaVersion.toString()
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = javaVersion.toString()
}
}
}
// configure the maven publication
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
// select the repositories you want to publish to
repositories {
// mavenLocal()
}
}
detekt {
buildUponDefaultConfig = true
autoCorrect = true
config = rootProject.files("detekt.yml")
}
gitHooks {
setHooks(
mapOf("pre-commit" to "detekt")
)
}
fun getVersionMetadata(): String {
val buildId = System.getenv("GITHUB_RUN_NUMBER")
val workflow = System.getenv("GITHUB_WORKFLOW")
if (workflow == "Release") {
return ""
}
// CI builds only
if (buildId != null) {
return "+build.$buildId"
}
// No tracking information could be found about the build
return "+local"
}