forked from TartaricAcid/TouhouLittleMaid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
231 lines (207 loc) · 6.82 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
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
222
223
224
225
226
227
228
229
230
231
// 调用的 gradle 插件
plugins {
id 'java-library'
// 用于 eclipse 或者 idea 的插件
id 'eclipse'
id 'idea'
// NeoForged 开发插件
id 'net.neoforged.moddev' version '0.1.99'
}
// ALL 为下载 gradle 源码,方便查看调试
tasks.named('wrapper', Wrapper).configure {
distributionType = Wrapper.DistributionType.ALL
}
// 模组相关信息
version = mod_version
group = mod_group_id
// 需要的前置库
repositories {
// ./libs 目录为库
flatDir {
dir "libs"
}
// mavenLocal 为本机仓库
mavenLocal()
mavenCentral()
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
maven {
url "https://maven.shedaniel.me/"
content {
includeGroup "me.shedaniel"
includeGroup "me.shedaniel.cloth"
includeGroup "dev.architectury"
}
}
maven {
url "https://maven2.bai.lol"
content {
includeGroup "mcp.mobius.waila"
includeGroup "lol.bai"
}
}
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/"
content {
includeGroup "dev.emi"
}
}
maven {
name 'cursemaven'
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven { // for TOP
url "https://maven.k-4u.nl/"
content {
includeGroup "mcjty.theoneprobe"
}
}
maven {
url = "https://maven.theillusivec4.top/"
content {
includeGroup "top.theillusivec4.curios"
}
}
}
// 打包成 jar 时的名称
base {
archivesName = 'touhoulittlemaid-' + minecraft_version + '-release'
}
// 需要 Java 21 版本
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
neoForge {
// NeoForge 版本信息
version = project.neo_version
// 反混淆表
parchment {
mappingsVersion = project.parchment_mappings_version
minecraftVersion = project.parchment_minecraft_version
}
// 运行部分
runs {
client {
client()
gameDirectory = project.file('run/client')
programArguments = [
"--username", "tartaric_acid"
]
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
server {
server()
gameDirectory = project.file('run/server')
programArgument '--nogui'
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
gameTestServer {
type = "gameTestServer"
gameDirectory = project.file('run/gameTestServer')
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
data {
data()
gameDirectory = project.file('run/data')
programArguments.addAll '--mod', project.mod_id, '--all',
'--output', file('src/generated/resources/').getAbsolutePath(),
'--existing', file('src/main/resources/').getAbsolutePath()
}
configureEach {
// +AllowEnhancedClassRedefinition 为 JetBrains Runtime 所需的参数
// JetBrains Runtime 是一个修改过的 JDK,支持热重载
// +IgnoreUnrecognizedVMOptions 用于忽略未知指令
// 否则没有安装 JetBrains Runtime 的用户运行时会报错
jvmArguments = ['-XX:+IgnoreUnrecognizedVMOptions',
'-XX:+AllowEnhancedClassRedefinition']
systemProperty 'forge.logging.markers', 'REGISTRIES'
// 参考:https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
logLevel = org.slf4j.event.Level.DEBUG
}
}
mods {
// define mod <-> source bindings
// these are used to tell the game which sources are for which mod
// mostly optional in a single mod project
// but multi mod projects should define one per mod
"${mod_id}" {
sourceSet(sourceSets.main)
}
}
}
sourceSets.main {
resources {
srcDir 'src/generated/resources'
}
}
configurations {
runtimeClasspath.extendsFrom localRuntime
}
dependencies {
// JEI
implementation "maven.modrinth:jei:${jei_version}"
// REI
compileOnly "maven.modrinth:architectury-api:${architectury_api_version}"
compileOnly "maven.modrinth:rei:${rei_version}"
// EMI
compileOnly "maven.modrinth:emi:${emi_version}"
implementation "maven.modrinth:jade:${jade_version}"
compileOnly "maven.modrinth:the-one-probe:${top_version}"
implementation "maven.modrinth:cloth-config:${cloth_config_version}"
implementation "maven.modrinth:iron-chests:${iron_chests_version}"
implementation "maven.modrinth:carry-on:${carry_on_version}"
implementation "maven.modrinth:patchouli:${patchouli_version}"
// IPN
runtimeOnly "maven.modrinth:kotlin-for-forge:5.4.0"
runtimeOnly "maven.modrinth:libipn:neoforge-1.21-6.0.2"
implementation "maven.modrinth:inventory-profiles-next:neoforge-1.21-2.0.4"
implementation "curse.maven:aquaculture-60028:5713551"
implementation "maven.modrinth:sodium:mc1.21-0.6.0-beta.2-neoforge"
implementation "maven.modrinth:iris:1.8.0-beta.5+1.21-neoforge"
compileOnly "maven.modrinth:embeddium:1.0.11+mc1.21.1-neoforge"
}
// 用于 neoforge.mods 里替换那一堆 ${xxxx}
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
minecraft_version : minecraft_version,
minecraft_version_range: minecraft_version_range,
neo_version : neo_version,
neo_version_range : neo_version_range,
loader_version_range : loader_version_range,
mod_id : mod_id,
mod_name : mod_name,
mod_license : mod_license,
mod_version : mod_version,
mod_authors : mod_authors,
mod_description : mod_description
]
inputs.properties replaceProperties
filesMatching(['META-INF/neoforge.mods.toml']) {
expand replaceProperties
}
}
// 生成 manifest 内容,用于填充版本信息等内容
jar {
manifest {
attributes([
"Implementation-Title" : project.name,
"Implementation-Version": "${version}"
])
}
}
// 必须,编码需要显式指定为 UTF
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
// 让 idea 主动下载前置库的源码和 Javadoc
// 新版本 idea 默认不会下载这两个,这虽然加快了构建速度,但是不方便调试
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}