forked from MCModderAnchor/TACZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
224 lines (198 loc) · 7.16 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
import java.text.SimpleDateFormat
// 设置日期格式,用于填充快照版版本号
SimpleDateFormat FORMAT = new SimpleDateFormat("MMdd-HHmmss")
FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"))
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
maven { url = 'https://maven.parchmentmc.org' }
maven { url = 'https://repo.spongepowered.org/maven' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath 'org.parchmentmc:librarian:1.+'
classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT'
// shadow 插件,用来打包 Apache Commons Math 库
classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'eclipse'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
apply plugin: 'maven-publish'
version = "1.0.0"
// 版本号,正式发布需要修改这一行
//version = FORMAT.format(new Date())
group = "com.tacz"
archivesBaseName = "tacz-1.20.1"
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
mixin {
add sourceSets.main, "tacz.refmap.json"
config "tacz.mixins.json"
}
minecraft {
// 使用 parchment 来反混淆变量名
mappings channel: 'parchment', version: '2023.08.20-1.20.1'
// 使用 access transformer 来修改原版的一些方法访问修饰符
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// 运行参数
runs {
client {
// 使用 JetBrainsRuntime 时需要的参数,否则无法热重载
// 如果你使用别的 JDK,那么可以删除这一行
jvmArgs "-XX:+AllowEnhancedClassRedefinition"
// 每个启动单独区分文件夹
workingDirectory project.file('run/client_a')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
mods {
tacz {
source sourceSets.main
}
}
}
client2 {
parent minecraft.runs.client
workingDirectory project.file('run/client_b')
// 设定用户名
args '--username', 'mayday_memory'
mods {
tacz {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run/server')
property 'mixin.env.disableRefMap', 'true'
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
mods {
tacz {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run/data')
property 'mixin.env.disableRefMap', 'true'
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
args '--mod', 'tacz', '--all', '--output', file('src/generated/resources/')
mods {
tacz {
source sourceSets.main
}
}
}
}
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
maven {
// 阿里云镜像,方便国内开发
url = uri("https://maven.aliyun.com/repository/public/")
}
maven {
// location of the maven that hosts JEI files since January 2023
// Patchouli
name = "Jared's maven"
url = "https://maven.blamejared.com/"
}
maven {
// location of a maven mirror for JEI files, as a fallback
name = "Mod Maven"
url = "https://modmaven.k-4u.nl"
}
maven {
// cloth config api
url "https://maven.shedaniel.me/"
}
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}
dependencies {
minecraft "net.minecraftforge:forge:${forge_version}"
// Apache Commons Math 库,用于进行一些插值运算
minecraftLibrary 'org.apache.commons:commons-math3:3.6.1'
// compile against the JEI API but do not include it at runtime
compileOnly(fg.deobf("mezz.jei:jei-1.20.1-common-api:${jei_version}"))
compileOnly(fg.deobf("mezz.jei:jei-1.20.1-forge-api:${jei_version}"))
// at runtime, use the full JEI jar for Forge
runtimeOnly(fg.deobf("mezz.jei:jei-1.20.1-forge:${jei_version}"))
implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:${cloth_config_forge}")
compileOnly fg.deobf("org.embeddedt:embeddium-1.20.1:${embeddedt_id}")
compileOnly fg.deobf("curse.maven:oculus-581495:${oculus_id}")
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}
jar {
// 打包时,给 manifest 文件写入一些有用信息
// 这些信息会被游戏调用,从而显示成模组的名称和版本信息
manifest {
attributes([
"Implementation-Title" : project.name,
"Implementation-Version": project.version
])
}
}
java {
// 编译源码文件,方便发布 maven
withSourcesJar()
}
publishing {
// 发布到 jitpack maven,方便其他模组开发者
publications.create('mavenJava', MavenPublication) {
from components.java
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
pom {
name = project.archivesBaseName
// 删除所有依赖,不需要
pom.withXml {
asNode().dependencies.dependency.each { dep ->
assert dep.parent().remove(dep)
}
}
}
}
}
// 禁用元数据生成,它生成的 maven 项目有问题
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
shadowJar {
dependencies {
// 打包 Apache Commons Math 库
include(dependency("org.apache.commons:commons-math3:3.6.1"))
// 排除 Apache Commons Math 库中不需要的说明文件
exclude('META-INF/LICENSE.txt')
exclude('META-INF/NOTICE.txt')
exclude('META-INF/maven/')
}
// 防止与其他模组导致的同名路径冲突
relocate 'org.apache.commons.math3', 'com.tacz.guns.libs.org.apache.commons.math3'
// 最小化
minimize()
}
reobf {
// 与名称的混淆有关的,反正需要 shadowJar 一下
shadowJar {}
}
// 保证编译时的 assemble 在 shadowJar 之后执行
assemble.dependsOn shadowJar
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}