forked from IdeallandEarthDept/IdeallandFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
309 lines (260 loc) · 11.3 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
306
307
308
309
Properties versiondata = new Properties()
versiondata.load(new FileInputStream("version.properties"))
apply from: 'gradle/scripts/helpers.gradle'
assertProperty 'root_package'
assertProperty 'mod_id'
assertProperty 'mod_name'
assertSubProperties 'use_access_transformer', 'access_transformer_locations'
assertSubProperties 'is_coremod', 'coremod_includes_mod', 'coremod_plugin_class_name'
assertSubProperties 'use_asset_mover', 'asset_mover_version'
setDefaultProperty 'mapping_channel', true, 'stable'
setDefaultProperty 'mapping_version', true, '39'
buildscript {
repositories {
if (project.use_mirror == 'true') {
// clear all proxy settings, this is available for global
System.clearProperty "http.proxyHost"
System.clearProperty "http.proxyPort"
System.clearProperty "https.proxyHost"
System.clearProperty "https.proxyPort"
System.clearProperty "socksProxyHost"
System.clearProperty "socksProxyPort"
System.setProperty "java.net.useSystemProxies", "false"
maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
maven { url "https://${mirror_maven_url}" }
}
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://maven.outlands.top/releases' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.10.+', changing: true
classpath "net.minecraftforge:gradlejarsigner:1.0.5"
classpath "org.spongepowered:mixingradle:0.7.+"
}
}
//if (propertyBool('use_mirror')) apply from: "gradle/scripts/mirror.gradle"
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'java'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'net.minecraftforge.gradlejarsigner'
version = "1.12.2-${versiondata.mod_version}"
group = project.root_package
archivesBaseName = project.mod_name
java.toolchain.languageVersion = JavaLanguageVersion.of(propertyInteger('java_version'))
jarSigner.autoDetect(archivesBaseName)
minecraft {
legacy {
fixClasspath = true
extractMappings = true
attachMappings = true
}
mappings channel: project.mapping_channel, version: project.mapping_version
copyIdeResources = true;
if(propertyBool('use_access_transformer')){
accessTransformer = file('src/main/resources/META-INF/${project.access_transformer_locations}')
}
runs {
// applies to all the run configs below
configureEach {
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
//property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
//property 'forge.logging.console.level', 'debug'
}
client {
workingDirectory project.file('run/client')
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
//property 'forge.enabledGameTestNamespaces', version.mod_id
mods {
"${project.mod_id}" {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run/server')
//property 'forge.enabledGameTestNamespaces', version.mod_id
args '--nogui'
mods {
"${project.mod_id}" {
source sourceSets.main
}
}
}
}
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
maven {
name 'Cleanroom Maven'
url 'https://maven.cleanroommc.com/'
}
maven {
url "https://repo.cleanroommc.com/snapshots"
}
maven {
url "https://maven.outlands.top/releases/"
}
maven {
url "https://repo.maven.apache.org/maven2/"
}
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
forRepositories(fg.repository) // Only add this if you're using ForgeGradle, otherwise remove this line
filter {
includeGroup "maven.modrinth"
}
}
mavenCentral()
mavenLocal()
flatDir {
dirs 'libs'
}
}
dependencies {
// Specify the version of Minecraft to use.
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
// The "userdev" classifier will be requested and setup by ForgeGradle.
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
minecraft "com.cleanroommc:cleanroom:${project.cleanroom_version}"
// Example mod dependency with JEI
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
// compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
// runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"
// Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
// The group id is ignored when searching -- in this case, it is "blank"
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
// For more info:
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
// Mixin and it's common libraries
// annotationProcessor 'org.ow2.asm:asm:9.6'
// annotationProcessor 'com.google.guava:guava:33.0.0-jre'
// annotationProcessor 'com.google.code.gson:gson:2.10.1'
// annotationProcessor ('com.cleanroommc:sponge-mixin:0.17.6+mixin.0.8.5')
// //implementation 'com.cleanroommc:sponge-mixin:0.17.6+mixin.0.8.5'
// annotationProcessor ("io.github.llamalad7:mixinextras-common:0.3.5")
// //implementation "io.github.llamalad7:mixinextras-common:0.3.5"
if (propertyBool('use_asset_mover')) {
implementation "com.cleanroommc:assetmover:${project.asset_mover_version}"
}
if (propertyBool('enable_junit_testing')) {
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources).configure {
def filterList = ['mcmod.info', 'pack.mcmeta']
filterList.addAll(propertyStringList('mixin_configs').collect(config -> "mixins.${config}.json" as String))
var replaceProperties = [
mod_id: propertyString('mod_id'),
mod_name: propertyString('mod_name'),
mod_version: version,
mod_description: propertyString('mod_description'),
mod_authors: "[${propertyStringList('mod_authors', ',').join(', ')}]",
mod_credits: propertyString('mod_credits'),
mod_url: propertyString('mod_url'),
mod_update_json: propertyString('mod_update_json'),
mod_logo_path: propertyString('mod_logo_path'),
mixin_refmap: propertyString('mixin_refmap'),
mixin_package: propertyString('mixin_package'),
java_version: propertyString('java_version')
]
inputs.properties replaceProperties
filesMatching(filterList) {
expand replaceProperties + [project: project]
}
if (propertyBool('use_access_transformer')) {
rename '(.+_at.cfg)', 'META-INF/$1'
}
}
// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {
def attribute_map = [:]
attribute_map['Specification-Version'] = '1' // We are version 1 of ourselves
attribute_map['Specification-Vendor'] = "[${propertyStringList('mod_authors', ',').join(', ')}]"
attribute_map['ModType'] = 'CRL'
attribute_map['Implementation-Title'] = project.name
attribute_map['Implementation-Version'] = version
attribute_map['Implementation-Vendor'] = "[${propertyStringList('mod_authors', ',').join(', ')}]"
attribute_map['Implementation-Timestamp'] = new Date().format('yyyy-MM-dd\'T\'HH:mm:ssZ')
if(propertyBool('is_coremod')){
attribute_map['FMLCorePlugin'] = propertyString('coremod_plugin_class_name')
if (propertyBool('coremod_includes_mod')) {
attribute_map['FMLCorePluginContainsFMLMod'] = true
attribute_map['ForceLoadAsMod'] = true
}
}
if((!propertyBool('is_coremod')) || propertyBool('coremod_includes_mod')){
attribute_map['Specification-Title'] = project.mod_id
}
if(propertyBool('use_access_transformer')){
attribute_map['FMLAT']= project.access_transformer_locations
}
if(propertyBool('use_mixin')){
attribute_map['MixinConfigs'] = project.mixin_configs;
}
attributes(attribute_map)
}
jarSigner.sign(it)
}
jar.finalizedBy('reobfJar')
// Example configuration to allow publishing using the maven-publish plugin
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file://${project.projectDir}/mcmodsrepo"
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
eclipse {
// Run everytime eclipse builds the code
//autoBuildTasks genEclipseRuns
// Run when importing the project
synchronizationTasks 'genEclipseRuns'
}
// Merge the resources and classes into the same directory.
// This is done because java expects modules to be in a single directory.
// And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem
// This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later.
sourceSets.each {
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
it.output.resourcesDir = dir
it.java.destinationDirectory = dir
}
mixin {
add sourceSets.main, project.mixin_refmap
}