forked from TerraFirmaGreg-Team/Core-Modern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
245 lines (206 loc) · 6.83 KB
/
build.gradle
File metadata and controls
245 lines (206 loc) · 6.83 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
buildscript {
repositories {
// These repositories are only for Gradle plugins
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
mavenCentral()
maven {
name = "NeoForged"
url = 'https://maven.neoforged.net/releases'
content {
includeGroup "net.neoforged"
}
}
}
}
plugins {
id 'java'
id 'java-library'
id 'idea'
id 'net.neoforged.moddev.legacyforge' version "${mdg_legacy_version}"
id 'com.diffplug.spotless' version "${spotless_version}"
id "com.github.ManifestClasspath" version "0.1.0-RELEASE"
}
apply from: 'gradle/scripts/repositories.gradle'
apply from: 'gradle/scripts/dependencies.gradle'
apply from: 'gradle/scripts/spotless.gradle'
if (file("moveToInstance.gradle").exists()) apply from: "moveToInstance.gradle"
base {
version = "${mod_version}"
group = "${mod_package}"
archivesName = "${mod_name}-${mod_name_suffix}"
}
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
mixin {
var refMap = add sourceSets.main, "${mod_id}.refmap.json"
jar.from refMap;
config "${mod_id}.mixins.json"
}
sourceSets {
main.resources {
srcDir 'src/main/resources'
srcDir 'src/generated/resources'
}
dev {
java.srcDir("src/dev/java")
resources.srcDir("src/dev/resources")
compileClasspath += sourceSets.main.compileClasspath
}
}
legacyForge {
version = "${minecraft_version}-${forge_version}"
runs {
configureEach {
gameDirectory = project.file('run')
systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'forge.logging.console.level', 'INFO'
}
client {
client()
gameDirectory = project.file('run/client')
}
server {
server()
gameDirectory = project.file('run/server')
programArgument '--nogui'
}
data {
data()
gameDirectory = project.file('run/data')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll('--mod', "${mod_id}", '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath())
}
}
mods {
"${mod_id}" {
sourceSet(sourceSets.main)
}
}
}
processResources {
var replaceProperties = [
'mod_id' : "${mod_id}",
'mod_name' : "${mod_name}",
'mod_version' : "${mod_version}",
'mod_description' : "${mod_description}",
'mod_authors' : "${mod_authors}",
'mod_credits' : "${mod_credits}",
'mod_url' : "${mod_url}",
'mod_update_json' : "${mod_update_json}",
'mod_logo_path' : "${mod_logo_path}",
'minecraft_version' : "${minecraft_version}",
'minecraft_version_range': "${minecraft_version_range}",
'forge_version' : "${forge_version}",
'forge_version_range' : "${forge_version_range}",
'loader_version_range' : "${loader_version_range}"
]
var filterList = [
'META-INF/mods.toml',
'pack.mcmeta'
]
inputs.properties replaceProperties
duplicatesStrategy = DuplicatesStrategy.INCLUDE
filesMatching(filterList) { fcd ->
fcd.expand(replaceProperties + [project: project])
}
}
sourceSets {
dev {
java.srcDir("src/dev/java")
resources.srcDir("src/dev/resources")
compileClasspath += sourceSets.main.compileClasspath
}
}
tasks.withType(Jar).configureEach {
manifest.attributes([
"Specification-Title" : "${mod_id}",
"Specification-Vendor" : "${mod_authors}",
"Specification-Version" : "1",
"Implementation-Title" : "${mod_name}",
"Implementation-Version" : "${mod_version}",
"Implementation-Vendor" : "${mod_authors}",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs" : "${mod_id}.mixins.json"
])
}
// Fix a bug in Species that only shows up when running from dev env
// Compile our patched Species.class, and use it instead of the normal one in the species-3.5.jar.
// Put the result in run/server/mods
tasks.register("patchSpeciesJar", Jar) {
dependsOn compileDevJava
archiveFileName = 'species-3.5.jar'
destinationDirectory = file("run/server/mods")
from({
configurations.compileClasspath
.filter { it.name.contains("species-3.5") }
.collect { zipTree(it) }
}) {
exclude "com/ninni/species/Species.class"
}
from(sourceSets.dev.output.classesDirs) {
include 'com/ninni/species/Species.class'
}
manifest {
attributes(
'MixinConfigs': 'species.mixins.json',
'Specification-Title': 'species',
'Implementation-Title': 'species',
'Implementation-Version': '3.5'
)
}
}
// Prepare server: patch Species, accept EULA, set offline mode
tasks.register("prepareServerDev") {
dependsOn patchSpeciesJar
def serverDir = file("run/server")
def propsFile = file("${serverDir}/server.properties")
outputs.file(eulaFile)
outputs.file(propsFile)
doLast {
serverDir.mkdirs()
// Create or patch server.properties to set online-mode=false
if (propsFile.exists()) {
def content = propsFile.text
if (content.contains('online-mode=')) {
content = content.replaceAll(/online-mode=\w+/, 'online-mode=false')
} else {
content += '\nonline-mode=false'
}
propsFile.text = content
} else {
propsFile.text = 'online-mode=false\n'
}
}
}
// Runs Species patch before runServer.
allprojects {
tasks.matching { it.name == "prepareRunServer" }.configureEach {
dependsOn("prepareServerDev")
}
}
// Moving the core jar to a custom folder
tasks.register('copyJarToInstance', Copy) {
group = 'mod development/internal'
from("${buildDir}/libs") {
include("*${version}.jar")
exclude("*-sources.jar", "*-javadoc.jar")
}
into("${modpack_mods}")
}
if (project.findProperty('enable_copy_jar_to_instance')?.toBoolean()) {
tasks.build.finalizedBy('copyJarToInstance')
}
configurations.all {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
}
}