From 2d736e7104b7057b76f33e25bc1a6a3f22f882f1 Mon Sep 17 00:00:00 2001 From: progwml6 Date: Mon, 2 Nov 2020 21:48:58 -0500 Subject: [PATCH] attempt to fix gradle issues --- build.gradle | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index a4dc518c..93dba279 100644 --- a/build.gradle +++ b/build.gradle @@ -145,23 +145,52 @@ sourceSets { } } -processResources { - exclude '**/*.xcf' - from(sourceSets.main.resources.srcDirs) { - include 'META-INF/mods.toml' +def modsTomlSpec = copySpec{ + from(sourceSets.main.resources) { + include 'META-INF/mods.toml' expand 'version': project.version, - 'minecraft_version_min': minecraft_version_min, 'minecraft_version_max': minecraft_version_max, - 'forge_version_min': forge_version_min, 'forge_version_max': forge_version_max, - 'javafml_min': javafml_min, 'javafml_max': javafml_max + 'minecraft_version_min': minecraft_version_min, + 'minecraft_version_max': minecraft_version_max, + 'forge_version_min': forge_version_min, + 'forge_version_max': forge_version_max, + 'javafml_min': javafml_min, + 'javafml_max': javafml_max } +} - from(sourceSets.main.resources.srcDirs) { - exclude 'META-INF/mods.toml' +// need to copy into each build directory, unfortunately does not seem easy to do this automatically +def buildPaths = [ + "$rootDir/out/production/resources", // IDEA + "$rootDir/bin", // Eclipse +] + +// task to add mods.toml to all relevant folders +task replaceResources { + // copy for gradle + copy { + outputs.upToDateWhen { false } + with modsTomlSpec + into processResources.destinationDir + } + // copy for IDEs + buildPaths.each { path -> + if (new File(path).exists()) { + copy { + outputs.upToDateWhen { false } + with modsTomlSpec + into path + } + } } } +processResources { + exclude 'META-INF/mods.toml' + finalizedBy replaceResources +} + task sourcesJar(type: Jar) { from sourceSets.main.allJava classifier = 'sources'