-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
174 lines (142 loc) · 4.58 KB
/
build.gradle
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
import groovy.json.JsonSlurper
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Files
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "de.undercouch.download" version "4.1.2"
id "com.github.johnrengelman.shadow" version "8.1.1"
id "io.github.pacifistmc.forgix" version "1.2.9"
id "base"
}
apply from: "build_dep_ver.gradle"
architectury {
minecraft = minecraft_version
}
subprojects {
apply plugin: "dev.architectury.loom"
loom {
silentMojangMappingsLicense()
}
configurations {
shadowCommon
}
dependencies {
annotationProcessor 'systems.manifold:manifold-preprocessor:+'
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings parchment_version == "" ? loom.officialMojangMappings() : loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
}
implementation 'io.lettuce:lettuce-core:6.2.3.RELEASE'
shadowCommon 'io.lettuce:lettuce-core:6.2.3.RELEASE'
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
// options.verbose = true
}
}
task setupLibrary() {
/* TODO... */
}
task setupFiles() {
copy {
outputs.upToDateWhen { false }
from "common/src/main/BuildConfigTemplate.java"
into "common/src/main/java/cn/zbx1425/worldcomment"
filter(ReplaceTokens, tokens: ["version": minecraft_version + "-" + rootProject.mod_version])
rename "(.+)Template.java", "\$1.java"
}
}
allprojects {
apply plugin: "architectury-plugin"
version = project.mod_version + "+" + minecraft_version
group = project.maven_group
repositories {
maven { url = "https://jitpack.io/" }
maven { url = "https://maven.terraformersmc.com/" }
maven { url = "https://maven.parchmentmc.org/" }
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
if (minecraft_main_version == 16) {
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
options.release.set(targetVersion)
}
} else if (minecraft_main_version == 17) {
options.release.set(16)
} else if (minecraft_main_version < 21) {
options.release.set(17)
} else {
options.release.set(21)
}
options.compilerArgs += ['-Xplugin:Manifold', '-AMC_VERSION=' + minecraft_version_int]
}
afterEvaluate {
for (def task in it.tasks) {
if (task != rootProject.tasks.setupFiles) {
task.dependsOn rootProject.tasks.setupFiles
}
}
}
build.finalizedBy(mergeJars)
assemble.finalizedBy(mergeJars)
}
static def getModrinthVersion(loader, minecraftVersion, projectId) {
def versionsArray = new JsonSlurper().parse(("https://api.modrinth.com/v2/project/" + projectId + "/version").toURL())
for (def versionElement : versionsArray) {
if (versionElement["loaders"].contains(loader) && versionElement["game_versions"].contains(minecraftVersion)) {
return versionElement["version_number"]
}
}
return ""
}
static def getParchmentVersion(minecraftVersion) {
def url = "https://ldtteam.jfrog.io/artifactory/parchmentmc-internal/org/parchmentmc/data/parchment-" + minecraftVersion + "/maven-metadata.xml"
def data = new XmlParser().parse(url)
return data.versioning.latest.text()
}
forgix {
group = "cn.zbx1425"
mergedJarName = "WorldComment" + "-" + rootProject.mod_version + "+" + minecraft_version + ".jar"
outputDir = "build/"
if (minecraft_version_int < 12100) {
forge {
projectName = "forge"
jarLocation = "build/libs/forge" + "-" + rootProject.mod_version + "+" + minecraft_version + ".jar"
}
} else {
neoforge {
projectName = "neoforge"
jarLocation = "build/libs/neoforge" + "-" + rootProject.mod_version + "+" + minecraft_version + ".jar"
}
}
fabric {
projectName = "fabric"
jarLocation = "build/libs/fabric" + "-" + rootProject.mod_version + "+" + minecraft_version + ".jar"
}
}
import org.gradle.api.internal.file.copy.CopyAction;
import org.gradle.api.internal.file.copy.CopyActionProcessingStream;
class DummyArchiveTask extends AbstractArchiveTask {
protected CopyAction createCopyAction() {
return new DummyCopyAction();
}
class DummyCopyAction implements CopyAction {
@Override
WorkResult execute(CopyActionProcessingStream stream) {
return WorkResults.didWork(true);
}
}
}
task dummyForgixOutput(type: DummyArchiveTask) {
// Forgix's mergeJars task doesn't extend AbstractArchiveTask.
// This is to make github.com/teaconmc/longjing happy.
dependsOn(mergeJars)
mustRunAfter mergeJars
destinationDirectory = file("build/")
archiveBaseName = "WorldComment"
archiveVersion = rootProject.mod_version + "+" + minecraft_version
archiveExtension = "jar"
}