Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
141 lines (125 loc) · 4.99 KB
/
Copy pathbuild.gradle
File metadata and controls
141 lines (125 loc) · 4.99 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
plugins {
id 'java-library'
id 'maven-publish'
id 'net.neoforged.moddev' version '2.0.78'
}
version = mod_version
group = mod_group_id
base.archivesName = mod_id
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
neoForge {
version = neo_version
// 可选:如果以后想用 Parchment 映射,把下面这段打开并填上版本
// parchment {
// mappingsVersion = parchment_mappings_version
// minecraftVersion = parchment_minecraft_version
// }
runs {
client {
client()
systemProperty 'neoforge.enabledGameTestNamespaces', mod_id
}
server {
server()
programArgument '--nogui'
systemProperty 'neoforge.enabledGameTestNamespaces', mod_id
}
}
mods {
"${mod_id}" {
sourceSet sourceSets.main
}
}
}
// ============================================================
// 依赖来源
// ------------------------------------------------------------
// Create 和 AE2 都不在 Maven Central 上,这里走 Modrinth 的 Maven 镜像。
// 坐标格式是 maven.modrinth:<slug>:<version-id>。
// 注意第三个参数是 Modrinth 的 version id(如 UjX6dr61),
// 不是 version_number(如 6.0.10+mc1.21.1)——后者带 + 号,解析容易出岔子。
// 如果哪天 Modrinth Maven 挂了,可以换成 CurseMaven:
// implementation "curse.maven:create-328085:5838779"
// 具体 file id 在 CurseForge 项目的 Files 页面上能看到。
// ============================================================
repositories {
maven { url = 'https://api.modrinth.com/maven' }
maven { url = 'https://cursemaven.com' }
maven { url = 'https://maven.createmod.net' }
maven { url = 'https://maven.blamejared.com' }
mavenCentral()
}
dependencies {
// Optional API compilation for Boss Guard and the existing perfect-item policy.
// Runtime activation is gated; these JARs are never bundled or made required.
// Example: -Pcir_optional_mods_dir=D:/Minecraft/.minecraft/versions/CIR-MODPACK-v4.1/mods
if (providers.gradleProperty('cir_optional_mods_dir').isPresent()) {
compileOnly fileTree(dir: providers.gradleProperty('cir_optional_mods_dir').get(),
includes: ['*Apotheosis*.jar', '*ApothicAttributes*.jar', '*Placebo*.jar', '*placebo*.jar'])
}
// Create —— 硬前置,mods.toml 里是 required
implementation "maven.modrinth:create:${create_version}"
// AE2 —— 可选前置。编译期需要它的几个类做反射目标,
// 但运行时不装也能启动(QuantumGuard 全部走反射,不做编译期引用,
// MixinQuantumBridge 由 CirMixinPlugin 门控)。
compileOnly "maven.modrinth:ae2:${ae2_version}"
// Zstd 压缩库(网络压缩模块用)
implementation 'com.github.luben:zstd-jni:1.5.6-4'
}
// 把 gradle.properties 里的版本号写进 mods.toml
tasks.withType(ProcessResources).configureEach {
def 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']) {
// 用 filter 逐行替换 @key@,而不是 expand(replaceProperties)。
// expand 会把整个文件交给 Groovy 的 SimpleTemplateEngine,而 TOML 的
// 三引号 / 方括号 / 注释语法会让它语法解析失败,实测报
// SimpleTemplateScript1.groovy: 1: Unexpected input: '('
filter { line ->
replaceProperties.inject(line) { acc, entry ->
acc.replace("@${entry.key}@", entry.value.toString())
}
}
}
}
tasks.named('jar', Jar).configure {
manifest {
attributes([
'Specification-Title' : mod_id,
'Specification-Vendor' : mod_authors,
'Specification-Version' : '1',
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_authors,
// Mixin 配置入口,缺了这一行模组启动时会因为找不到 mixins.json 直接崩
'MixinConfigs' : 'createciraddition.mixins.json'
])
}
}
publishing {
publications {
register('mavenJava', MavenPublication) {
from components.java
}
}
repositories {
maven {
url = "file://${project.projectDir}/repo"
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}