Include only the mod meta data file for the respective loader

Also clean up the entire processResources block in the process cause it was a
mere coincidence that it has worked properly.
This commit is contained in:
Jonas Herzig
2020-07-13 14:44:26 +02:00
parent ecee63491c
commit f83216ab91

View File

@@ -458,34 +458,27 @@ jar {
} }
} }
processResources processResources {
{
// this will ensure that this task is redone when the versions change. // this will ensure that this task is redone when the versions change.
inputs.property 'version', { project.version } inputs.property 'version', { project.version }
inputs.property 'mcversion', { mcVersionStr } inputs.property 'mcversion', { mcVersionStr }
// replace stuff in mcmod.info (forge) and fabric.mod.json, nothing else // replace stuff in mcmod.info (forge) and fabric.mod.json, nothing else
from(sourceSets.main.resources.srcDirs) { spec -> filesMatching(['mcmod.info', 'fabric.mod.json']) {
include 'mcmod.info'
include 'fabric.mod.json'
// replace version and mcversion // replace version and mcversion
afterEvaluate { expand 'version': project.version, 'mcversion': mcVersionStr
spec.expand 'version': project.version, 'mcversion': mcVersionStr
}
} }
// strip comments from (strict) JSON files // strip comments from (strict) JSON files
from(sourceSets.main.resources.srcDirs) { filesMatching('pack.mcmeta') {
include 'pack.mcmeta'
filter { line -> line.trim().startsWith('//') ? '' : line} filter { line -> line.trim().startsWith('//') ? '' : line}
} }
// copy everything else, thats not the mcmod.info or fabric.mod.json // exclude mod meta for non-applicable loader
from(sourceSets.main.resources.srcDirs) { if (FABRIC) {
exclude 'mcmod.info' exclude 'mcmod.info'
} else {
exclude 'fabric.mod.json' exclude 'fabric.mod.json'
exclude 'pack.mcmeta'
} }
} }