-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
305 lines (259 loc) · 7.92 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
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
plugins {
id 'java-library'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.180'
id "com.hypherionmc.modutils.modpublisher" version "2.1.6"
id 'idea'
}
apply from: 'optimization_utils.gradle'
repositories {
mavenLocal()
maven {
name "AnonymousHacker1279"
url "https://maven.anonymoushacker1279.tech/releases"
}
maven {
name "Jared's Maven"
url 'https://maven.blamejared.com'
}
maven {
name "ModMaven"
url "https://modmaven.dev/"
}
maven {
name "Maven Central"
url "https://repo.maven.apache.org/maven2"
}
maven {
name "Bai Maven"
url "https://maven2.bai.lol"
}
maven {
name "AzureDoom's Maven"
url 'https://maven.azuredoom.com/mods'
}
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/"
}
}
version = mod_version
group = mod_group_id
base {
archivesName = project.mod_id
}
jarJar.enable()
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
println('Java: ' + System.getProperty('java.version') + ' | JVM: ' + System.getProperty('java.vm.version') + ' (' + System.getProperty('java.vendor') + ') | Arch: ' + System.getProperty('os.arch'))
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
sourceSets {
main {
resources {
// Include resources generated by data generators.
srcDirs += "src/generated/resources"
}
}
generated
// Separate datagen sourceSet from main to shrink the build jar
datagen {
compileClasspath += main.output
}
}
// Ensure other source sets receive the necessary dependencies
configurations {
extendConfigurations(implementation, testImplementation, datagenImplementation)
extendConfigurations(compileOnly, testCompileOnly, datagenCompileOnly)
extendConfigurations(runtimeOnly, testRuntimeOnly, datagenRuntimeOnly)
}
static void extendConfigurations(Configuration base, Configuration... configurations) {
for (configuration in configurations) {
configuration.extendsFrom(base)
}
}
runs {
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'forge.logging.console.level', 'debug'
jvmArguments.addAll '-Xmx6G', '-XX:NonProfiledCodeHeapSize=512M'
// If the selected toolchain is a JBR, enable DCEVM for improved hotswapping
if (it.project.javaToolchains.launcherFor(java.toolchain).map { it.metadata.vendor }.getOrElse("").contains("JetBrains")) {
jvmArguments.addAll '-XX:+AllowEnhancedClassRedefinition', '-XX:NonProfiledCodeHeapSize=256M', '-XX:ReservedCodeCacheSize=300M'
}
modSources project.sourceSets.main, project.sourceSets.datagen
}
client {
// Setup client information from gradle.properties in the user home
// All of these are optional
if (project.hasProperty('mc_uuid')) {
arguments('--uuid', (String) project.property('mc_uuid'))
}
if (project.hasProperty('mc_username')) {
arguments('--username', (String) project.property('mc_username'))
}
if (project.hasProperty('mc_accessToken')) {
arguments('--accessToken', (String) project.property('mc_accessToken'))
}
}
server {
argument '--nogui'
}
data {
arguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}
// Include resources generated by data generators
sourceSets.main.resources {
srcDir 'src/generated/resources'
// Exclude the cache directory
exclude '.cache'
}
dependencies {
implementation 'org.jetbrains:annotations:24.1.0'
implementation "net.neoforged:neoforge:${neoforge_version}"
implementation(jarJar("com.terraformersmc:biolith-neoforge:[${biolith}]")) {
version {
prefer biolith
}
}
implementation(jarJar("net.kyrptonaught.customportalapi:cpapireforged-neo-${minecraft_version}:[${custom_portals_api_version},)")) {
version {
prefer custom_portals_api_version
}
}
// Include Immersive Weapons Compatibility Bridge (IWCB)
implementation "tech.anonymoushacker1279.iwcompatbridge:IWCompatBridge:${iwcb_version}"
// Include JEI
runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"
// Include WTHIT and badpackets
runtimeOnly "mcp.mobius.waila:wthit:neo-${wthit_version}"
runtimeOnly "lol.bai:badpackets:neo-${badpackets_version}"
}
tasks.named('processResources', ProcessResources).configure {
LinkedHashMap<String, String> replaceProperties = [
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
neoforge_version : neoforge_version, neoforge_version_range: neoforge_version_range,
loader_version_range: loader_version_range, mod_version: mod_version
]
inputs.properties replaceProperties
filesMatching(['META-INF/neoforge.mods.toml']) {
expand replaceProperties + [project: project]
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
java {
withSourcesJar()
withJavadocJar()
}
tasks.named('sourcesJar', Jar).configure {
from sourceSets.main.allSource
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.named('jar', Jar).configure {
archiveClassifier = "slim"
manifest {
attributes([
'Specification-Title' : mod_id,
'Specification-Vendor' : "AnonymousHacker1279",
'Specification-Version' : '1',
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : "AnonymousHacker1279",
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs" : "mixins.immersiveweapons.json"
])
}
}
tasks.jarJar.configure {
archiveClassifier = ""
}
tasks.named('build').configure {
dependsOn('jarJar')
}
artifacts {
archives javadocJar
archives sourcesJar
archives tasks.jarJar
}
publishing {
publications {
register('mavenJava', MavenPublication) {
artifact jar
artifact tasks.jarJar
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
name "AnonymousHacker1279"
String baseMavenUrl = "https://maven.anonymoushacker1279.tech/"
url mod_version.contains("SNAPSHOT") ? baseMavenUrl + "snapshots" : baseMavenUrl + "releases"
credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
}
}
}
if (file("RELEASE_NOTES.md").exists()) {
publisher {
apiKeys {
// Load API keys from tokens.properties file
Properties tokens = new Properties()
file("tokens.properties").withInputStream {
stream -> tokens.load(stream)
}
curseforge = tokens.getProperty("curseforge")
modrinth = tokens.getProperty("modrinth")
}
setDebug(false)
setCurseID("494454")
setModrinthID("QZFdnUQ5")
setGithubRepo("AnonymousHacker1279/ImmersiveWeapons")
setVersionType("release")
// Read the contents of the RELEASE_NOTES.md file
setChangelog(file("RELEASE_NOTES.md").text)
// Get the IW version from the mod_version variable, it's the last part of the version string
setVersion("v" + mod_version.split("-")[1])
setDisplayName("Immersive Weapons - v" + mod_version.split("-")[1])
setGameVersions([minecraft_version])
setLoaders("neoforge")
setCurseEnvironment("both")
setArtifact(tasks.jarJar)
setJavaVersions([JavaVersion.VERSION_21])
addAdditionalFile(javadocJar, sourcesJar)
curseDepends {
optional "immersive-weapons-compatibility-bridge", "attributefix"
embedded 'biomesquisher', 'custom-portal-api-reforged'
}
modrinthDepends {
optional "immersive-weapons-compatibility-bridge", "attributefix"
embedded 'biomesquisher', 'custom-portal-api-reforged'
}
}
} else {
println("No RELEASE_NOTES.md found, publishing outside of Maven is disabled.")
}
tasks.named('javadoc', Javadoc).configure {
options {
tags = [
'reason:a:Mixin Reason'
]
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
options.fork = true // Use a separate JVM process for Java compilation
}
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}