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