-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle.kts
134 lines (106 loc) · 3.65 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
import org.apache.tools.ant.filters.ReplaceTokens
import java.time.Instant
import java.time.format.DateTimeFormatter
fun property(key: String) = project.findProperty(key).toString()
plugins {
id("java")
id("net.minecraftforge.gradle")
}
repositories {
maven("https://maven.tterrag.com/")
maven("https://maven.blamejared.com")
}
val modName = property("modName")
val modId = property("modId")
val modVersion = property("modVersion")
val mcVersion = property("mcVersion")
val forgeVersion = property("forgeVersion")
val mappingsVersion = property("mappingsVersion")
version = "$mcVersion-$modVersion"
group = property("group")
minecraft {
mappings("snapshot", mappingsVersion)
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
runs {
create("client") {
workingDirectory = file("run").absolutePath
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
property("forge.logging.console.level", "debug")
if (project.hasProperty("mcUuid")) {
args("--uuid", project.property("mcUuid"))
}
if (project.hasProperty("mcUsername")) {
args("--username", project.property("mcUsername"))
}
if (project.hasProperty("mcAccessToken")) {
args("--accessToken", project.property("mcAccessToken"))
}
}
create("server") {
workingDirectory = file("run").absolutePath
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
property("forge.logging.console.level", "debug")
}
}
}
dependencies {
minecraft("net.minecraftforge:forge:$mcVersion-$forgeVersion")
runtimeOnly("team.chisel.ctm:CTM:MC1.12.2-1.0.2.31")
runtimeOnly("team.chisel:Chisel:MC1.12.2-1.0.2.45")
implementation("vazkii.patchouli:Patchouli:1.0-19.96")
}
// Workaround for resources issue. Use gradle tasks rather than generated runs for now.
sourceSets {
main {
output.setResourcesDir(file("build/combined"))
java.destinationDirectory.set(file("build/combined"))
}
}
tasks.processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
inputs.property("version", project.version)
inputs.property("mcversion", mcVersion)
from(sourceSets.main.get().resources.srcDirs) {
include("mcmod.info")
expand("version" to project.version, "mcversion" to mcVersion)
}
from(sourceSets.main.get().resources.srcDirs) {
exclude("mcmod.info")
}
}
// Assign version constant in ModConstants.
val prepareSources = tasks.register("prepareSources", Copy::class) {
from("src/main/java")
into("build/src/main/java")
filter<ReplaceTokens>("tokens" to mapOf("VERSION" to version.toString()))
}
tasks.compileJava {
source = prepareSources.get().outputs.files.asFileTree
}
tasks.jar {
manifest.attributes(
"Specification-Title" to project.name,
"Specification-Vendor" to "ferreusveritas",
"Specification-Version" to "1",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "ferreusveritas",
"Implementation-Timestamp" to DateTimeFormatter.ISO_INSTANT.format(Instant.now()),
"FMLAT" to "accesstransformer.cfg"
)
archiveBaseName.set(modName)
finalizedBy("reobfJar")
}
java {
withSourcesJar()
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
val deobfJar = tasks.register("deobfJar", Jar::class) {
archiveClassifier.set("deobf")
from(sourceSets.main.get().output)
}
tasks.build {
dependsOn(deobfJar)
}