-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.gradle.kts
118 lines (99 loc) · 2.81 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
plugins {
java
idea
eclipse
alias(libs.plugins.forgegradle)
alias(libs.plugins.parchment)
alias(libs.plugins.spotless)
}
fun getGitRef(): String {
return providers.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
isIgnoreExitValue = true
}.standardOutput.asText.get().trim()
}
val modId: String by project
val mavenGroup: String by project
val modVersion: String by project
val minecraftVersion: String = libs.versions.minecraft.get()
val forgeVersion: String = libs.versions.forge.platform.get().split("-")[1]
version = "${modVersion}+${getGitRef()}"
group = mavenGroup
base {
archivesName.set("${modId}-MC${minecraftVersion}")
}
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
dependencies {
minecraft(libs.forge.platform)
}
minecraft {
mappings("parchment", "${libs.versions.parchment.get()}-$minecraftVersion")
runs {
create("client") {
workingDirectory(file("run"))
property("forge.logging.markers", "REGISTRIES")
property("forge.logging.console.level", "info")
mods {
create(modId) {
source(sourceSets.main.get())
}
}
}
create("server") {
workingDirectory(file("run"))
property("forge.logging.markers", "REGISTRIES")
property("forge.logging.console.level", "info")
mods {
create(modId) {
source(sourceSets.main.get())
}
}
}
}
}
tasks {
withType<JavaCompile>().configureEach {
options.encoding = "utf-8"
}
processResources {
val properties = mapOf(
"version" to modVersion,
"minecraftVersion" to minecraftVersion,
"loaderVersion" to forgeVersion.split(".").first(),
"forgeVersion" to forgeVersion
)
inputs.properties(properties)
filesMatching("META-INF/mods.toml") {
expand(properties)
}
}
jar {
finalizedBy("reobfJar")
manifest {
attributes(mapOf(
"Specification-Title" to modId,
"Specification-Version" to "1",
"Specification-Vendor" to "Sangar",
"Implementation-Title" to modId,
"Implementation-Version" to version,
"Implementation-Vendor" to "Sangar",
))
}
}
}
spotless {
java {
target("src/*/java/li/cil/**/*.java")
endWithNewline()
trimTrailingWhitespace()
removeUnusedImports()
indentWithSpaces()
}
}
idea {
module {
for (exclude in arrayOf("out", "logs")) {
excludeDirs.add(file(exclude))
}
}
}