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'