Skip to content

Commit 245a8b1

Browse files
authored
fix jar configuration not applying to deobfJar (#1562)
1 parent b1ac99c commit 245a8b1

File tree

2 files changed

+50
-33
lines changed

2 files changed

+50
-33
lines changed

build.gradle

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,15 @@ fancyGradle {
176176
}
177177
}
178178

179+
processJarTask jar
180+
179181
if (project.build_deobfJar.toBoolean()) {
180182
// Create deobf dev jars
181183
tasks.register('deobfJar', Jar) {
182184
archiveClassifier.set 'deobf'
183185
from sourceSets.main.output
184186
}
187+
processJarTask deobfJar
185188
}
186189

187190
if (project.build_apiJar.toBoolean()) {
@@ -235,33 +238,6 @@ sourceSets {
235238
main.output.setResourcesDir(main.java.classesDirectory)
236239
}
237240

238-
jar {
239-
manifest {
240-
// noinspection GroovyAssignabilityCheck
241-
def attribute_map = [:]
242-
if (project.use_coremod.toBoolean()) {
243-
attribute_map['FMLCorePlugin'] = project.coremod_plugin_class_name
244-
if (project.include_mod.toBoolean()) {
245-
attribute_map['FMLCorePluginContainsFMLMod'] = true
246-
attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == 'build'
247-
}
248-
}
249-
if (project.use_mixins.toBoolean()) {
250-
attribute_map['TweakClass'] = 'org.spongepowered.asm.launch.MixinTweaker'
251-
}
252-
if (project.has_access_transformer.toBoolean()) {
253-
attribute_map['FMLAT'] = 'gregtech_at.cfg'
254-
}
255-
attributes(attribute_map)
256-
}
257-
258-
// exclude all files in src/api from being shipped in the jar
259-
// this prevents crashes in obfuscated environments
260-
file('src/api/').eachDirRecurse { dir ->
261-
exclude dir.name
262-
}
263-
}
264-
265241
artifacts {
266242
if (project.build_deobfJar.toBoolean()) {
267243
archives deobfJar
@@ -313,6 +289,42 @@ test {
313289
useJUnitPlatform()
314290
}
315291

292+
/**
293+
* Applies required processing to jar tasks
294+
* @param task the task to process
295+
*/
296+
private void processJarTask(task) {
297+
task.configure {
298+
manifest {
299+
// noinspection GroovyAssignabilityCheck
300+
def attribute_map = [:]
301+
if (project.use_coremod.toBoolean()) {
302+
attribute_map['FMLCorePlugin'] = project.coremod_plugin_class_name
303+
if (project.include_mod.toBoolean()) {
304+
attribute_map['FMLCorePluginContainsFMLMod'] = true
305+
attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == 'build'
306+
}
307+
}
308+
if (project.use_mixins.toBoolean()) {
309+
attribute_map['TweakClass'] = 'org.spongepowered.asm.launch.MixinTweaker'
310+
}
311+
if (project.has_access_transformer.toBoolean()) {
312+
attribute_map['FMLAT'] = 'gregtech_at.cfg'
313+
}
314+
attributes(attribute_map)
315+
}
316+
317+
// exclude all files in src/api from being shipped in the jar
318+
// this prevents crashes in obfuscated environments
319+
file('src/api/').eachDirRecurse { dir ->
320+
exclude dir.name
321+
}
322+
}
323+
}
324+
325+
/**
326+
* @return the current project version, parsed from the version file
327+
*/
316328
@SuppressWarnings('GroovyAssignabilityCheck')
317329
private String getVersionFromJava() {
318330
def major = '0'

gradle.properties

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ minecraft_version = 1.12.2
88
maven_group = gregtech
99
archives_base_name = gregtech
1010

11-
# This will downlaod sourses and Javadoc for the dependencies (for example mixins), set which ide you use
12-
# You can look up dependencies and their available sources and Javadoc in intellij by going to File ProjectStructure Libaries
11+
# This will download sources and Javadoc for the dependencies (for example mixins), set which ide you use
12+
# You can look up dependencies and their available sources and Javadoc in intellij by going to File ProjectStructure Libraries
1313
use_intellij_idea = true
1414
use_eclipse = false
1515

16-
# Optionial Jar compiling
17-
build_deobfJar = false
16+
# Optional Jar compiling
17+
build_deobfJar = true
1818
build_apiJar = false
19-
build_sourceJar = false
19+
build_sourceJar = true
2020

2121
# If any properties change below this line, refresh gradle again to ensure everything is working correctly.
2222

@@ -42,22 +42,27 @@ mcp_mappings_channel = stable
4242
mcp_mappings_version = 39-1.12
4343

4444
## Hard Dependencies
45+
### CCL 3.2.3.358
4546
ccl_pid = 242818
4647
ccl_fid = 2779848
4748

4849
## Soft Dependencies
4950
jei_version = 4.16.1.302
5051
crt_version = 4.1.20.684
52+
### TOP 1.4.28
5153
top_pid = 245211
5254
top_fid = 2667280
55+
### CTM 1.0.2.31
5356
ctm_pid = 267602
5457
ctm_fid = 2915363
58+
### GRS 0.3.0
5559
grs_pid = 687577
5660
grs_fid = 4399621
61+
### AE2 0.55.6
5762
ae2_pid = 570458
5863
ae2_fid = 4402048
5964

60-
## Mixin Depdencies
65+
## Mixin Dependencies
6166
mixingradle_version = 0.7-SNAPSHOT
6267
mixinbooter_version = 7.0
6368
mixin_annotations_version = 0.8.5

0 commit comments

Comments
 (0)