@@ -48,12 +48,8 @@ minecraft {
4848 // Simply re-run your setup task after changing the mappings to update your workspace.
4949 mappings channel: mapping_channel, version: mapping_version
5050
51- // When true, this property will have all Eclipse run configurations run the "prepareX" task for the given run configuration before launching the game.
52- // In most cases, it is not necessary to enable.
51+ // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
5352 // enableEclipsePrepareRuns = true
54-
55- // When true, this property will have all IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
56- // In most cases, it is not necessary to enable.
5753 // enableIdeaPrepareRuns = true
5854
5955 // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
@@ -77,7 +73,8 @@ minecraft {
7773 // Default run configurations.
7874 // These can be tweaked, removed, or duplicated as needed.
7975 runs {
80- client {
76+ // applies to all the run configs below
77+ configureEach {
8178 workingDirectory project.file('run')
8279
8380 // Recommended logging data for a userdev environment
@@ -93,73 +90,43 @@ minecraft {
9390 // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
9491 property 'forge.logging.console.level', 'debug'
9592
96- #if (${GAME_TEST_FRAMEWORK})
97- // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
98- property 'forge.enabledGameTestNamespaces', mod_id
99- #end
100-
10193 mods {
10294 "${mod_id}" {
10395 source sourceSets.main
10496 }
10597 }
10698 }
10799
108- server {
109- workingDirectory project.file('run')
110-
111- property 'forge.logging.markers', 'REGISTRIES'
112-
113- property 'forge.logging.console.level', 'debug'
114-
115- #if (${GAME_TEST_FRAMEWORK})
100+ #if (${GAME_TEST_FRAMEWORK})
101+ client {
102+ // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
116103 property 'forge.enabledGameTestNamespaces', mod_id
117- #end
104+ }
105+ #end
118106
119- mods {
120- "${mod_id}" {
121- source sourceSets.main
122- }
123- }
107+ server {
108+ #if (${GAME_TEST_FRAMEWORK})
109+ property 'forge.enabledGameTestNamespaces', mod_id
110+ #end
111+ args '--nogui'
124112 }
125113#if (${GAME_TEST_FRAMEWORK})
126114
127115 // This run config launches GameTestServer and runs all registered gametests, then exits.
128116 // By default, the server will crash when no gametests are provided.
129117 // The gametest system is also enabled by default for other run configs under the /test command.
130118 gameTestServer {
131- workingDirectory project.file('run')
132-
133- property 'forge.logging.markers', 'REGISTRIES'
134-
135- property 'forge.logging.console.level', 'debug'
136-
137119 property 'forge.enabledGameTestNamespaces', mod_id
138-
139- mods {
140- "${mod_id}" {
141- source sourceSets.main
142- }
143- }
144120 }
145121#end
146122#if (${HAS_DATA})
147123
148124 data {
149- workingDirectory project.file('run')
150-
151- property 'forge.logging.markers', 'REGISTRIES'
152-
153- property 'forge.logging.console.level', 'debug'
125+ // example of overriding the workingDirectory set in configureEach above
126+ workingDirectory project.file('run-data')
154127
155128 // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
156129 args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
157-
158- mods {
159- "${mod_id}" {
160- source sourceSets.main
161- }
162- }
163130 }
164131#end
165132 }
@@ -219,25 +186,23 @@ dependencies {
219186// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
220187// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
221188// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
222- def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta']
223- def replaceProperties = [
224- minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
225- forge_version: forge_version, forge_version_range: forge_version_range,
226- loader_version_range: loader_version_range,
227- mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
228- mod_authors: mod_authors, mod_description: mod_description
229- ]
230- processResources {
189+ tasks.named('processResources', ProcessResources).configure {
190+ var replaceProperties = [
191+ minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
192+ forge_version: forge_version, forge_version_range: forge_version_range,
193+ loader_version_range: loader_version_range,
194+ mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
195+ mod_authors: mod_authors, mod_description: mod_description,
196+ ]
197+
231198 inputs.properties replaceProperties
232- replaceProperties.put 'project', project
233199
234- filesMatching(resourceTargets) {
235- expand replaceProperties
236- }
237- }
200+ filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
201+ expand replaceProperties + [project: project]
202+ }}
238203
239204// Example for how to get properties into the manifest for reading at runtime.
240- jar {
205+ tasks.named(' jar', Jar).configure {
241206 manifest {
242207 attributes([
243208 "Specification-Title": mod_id,
@@ -249,9 +214,10 @@ jar {
249214 "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
250215 ])
251216 }
252- }
253217
254- jar.finalizedBy('reobfJar')
218+ // This is the preferred method to reobfuscate your jar file
219+ finalizedBy 'reobfJar'
220+ }
255221
256222tasks.withType(JavaCompile).configureEach {
257223 options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
0 commit comments