forked from MCModderAnchor/SimpleBedrockModel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
257 lines (219 loc) · 6.79 KB
/
Copy pathbuild.gradle
File metadata and controls
257 lines (219 loc) · 6.79 KB
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
plugins {
id 'java-library'
id 'idea'
id 'net.neoforged.moddev' version '2.0.142'
id "com.modrinth.minotaur" version "2.8.7"
id 'me.champeau.jmh' version '0.7.2'
id 'maven-publish'
}
version = mod_version
group = mod_group_id
base {
archivesName = 'simplebedrockmodel'
}
java.toolchain.languageVersion = JavaLanguageVersion.of(25)
neoForge {
version = project.neo_version
runs {
client {
client()
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
server {
server()
programArgument '--nogui'
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}
data {
clientData()
programArguments.addAll '--mod', project.mod_id, '--all',
'--output', file('src/generated/resources/').getAbsolutePath(),
'--existing', file('src/main/resources/').getAbsolutePath()
}
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
logLevel = org.slf4j.event.Level.DEBUG
}
}
mods {
"${mod_id}" {
sourceSet(sourceSets.main)
sourceSet(sourceSets.test)
}
}
}
sourceSets.main.resources {
srcDir 'src/generated/resources'
}
sourceSets.main.java {
exclude 'com/github/mcmodderanchor/simplebedrockmodel/v2/particle/debug/**'
}
configurations {
runtimeClasspath.extendsFrom localRuntime
// 自定义一个 minecraftLibrary,方便引入需要 jarJar 的库
mcLib
implementation {
extendsFrom mcLib
}
additionalRuntimeClasspath {
extendsFrom mcLib
}
// 让测试编译期能访问 Minecraft / NeoForge 等主模块的编译依赖
testCompileClasspath.extendsFrom compileClasspath
testRuntimeClasspath.extendsFrom runtimeClasspath
}
repositories {
maven {
name = "CaffeineMC"
url = "https://maven.caffeinemc.net/releases"
}
mavenLocal()
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
content {
includeGroup "curse.maven"
}
}
mavenLocal()
mavenCentral()
}
dependencies {
compileOnly "net.caffeinemc:sodium-neoforge-api:${sodiumVersion}"
localRuntime "net.caffeinemc:sodium-neoforge:${sodiumVersion}"
mcLib jarJar("com.maydaymemory:mae:1.1.4") {
exclude group: 'com.google.code.gson', module: 'gson'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
exclude group: 'it.unimi.dsi', module: 'fastutil'
exclude group: 'org.joml', module: 'joml'
}
api 'org.ow2.asm:asm:9.8'
// 测试用兼容模组:发布时仍保持可选依赖。
// Test
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.2'
testImplementation "org.joml:joml:1.10.5"
// JMH: mocha 原版 (javassist) 用于性能对比
jmhImplementation 'team.unnamed:mocha:3.0.1'
}
// 用于 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,
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([
"Specification-Title" : mod_id,
"Specification-Vendor" : mod_authors,
"Specification-Version" : version,
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : mod_authors,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
exclude 'example/**'
exclude 'assets/example/**'
exclude 'data/example/**'
}
// 让 idea 主动下载前置库的源码和 Javadoc
// 新版本 idea 默认不会下载这两个,这虽然加快了构建速度,但是不方便调试
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
// 必须,编码需要显式指定为 UTF
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
test {
useJUnitPlatform()
}
jmh {
zip64 = true
jmhVersion = '1.37'
}
java {
// 编译源码文件,方便发布 maven
withSourcesJar()
}
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = mod_id
versionName = "${mod_id}-${version}"
versionNumber = mod_version
uploadFile = "${layout.buildDirectory.get()}/libs/${mod_id}-${version}.jar"
additionalFiles = ["${layout.buildDirectory.get()}/libs/${mod_id}-${version}-sources.jar"]
gameVersions = [minecraft_version]
loaders = ["neoforge"]
//debugMode = true
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = project.group
artifactId = base.archivesName.get()
version = project.version
from components.java
pom {
name = mod_name
description = mod_description
licenses {
license {
name = mod_license
}
}
}
}
}
}
tasks.register("runWithRenderDoc", Exec) {
commandLine = [
"D:\\tools\\RenderDoc_1.44_64\\renderdoccmd.exe",
"capture",
"--opt-hook-children",
"--wait-for-exit",
"--working-dir",
projectDir.absolutePath,
"C:\\Windows\\System32\\cmd.exe",
"/c",
file("gradlew.bat").absolutePath,
"--no-daemon",
"runClient"
]
doFirst {
println "=== RenderDoc gradlew command ==="
println commandLine.collect {
it.toString().contains(" ") ? "\"${it}\"" : it
}.join(" ")
println "================================="
}
}