From b85e4e69349edeff657d9d57f9b670352845d5b4 Mon Sep 17 00:00:00 2001 From: Matyrobbrt <65940752+Matyrobbrt@users.noreply.github.com> Date: Sat, 7 Sep 2024 16:08:33 +0300 Subject: [PATCH] Add the ability to load mappings from multiple files (#12) --- Jenkinsfile | 85 ----------------------- README.md | 3 +- src/main/java/net/neoforged/art/Main.java | 10 ++- 3 files changed, 9 insertions(+), 89 deletions(-) delete mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index f6db84b..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,85 +0,0 @@ -@Library('forge-shared-library')_ - -pipeline { - agent { - docker { - image 'gradle:jdk8' - args '-v gradlecache:/gradlecache' - } - } - environment { - GRADLE_ARGS = '-Dorg.gradle.daemon.idletimeout=5000' - DISCORD_WEBHOOK = credentials('forge-discord-jenkins-webhook') - DISCORD_PREFIX = "Job: Forge Auto Renaming Tool Branch: ${BRANCH_NAME} Build: #${BUILD_NUMBER}" - JENKINS_HEAD = 'https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png' - } - - stages { - stage('notify_start') { - when { - not { - changeRequest() - } - } - steps { - discordSend( - title: "${DISCORD_PREFIX} Started", - successful: true, - result: 'ABORTED', //White border - thumbnail: JENKINS_HEAD, - webhookURL: DISCORD_WEBHOOK - ) - } - } - stage('buildandtest') { - steps { - withGradle { - sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue build test' - } - script { - gradleVersion(this) - } - } - post { - success { - writeChangelog(currentBuild, 'build/changelog.txt') - } - } - } - stage('publish') { - when { - not { - changeRequest() - } - } - steps { - withCredentials([usernamePassword(credentialsId: 'maven-forge-user', usernameVariable: 'MAVEN_USER', passwordVariable: 'MAVEN_PASSWORD')]) { - withGradle { - sh './gradlew ${GRADLE_ARGS} publish' - } - } - } - post { - success { - build job: 'filegenerator', parameters: [string(name: 'COMMAND', value: "promote ${env.MYGROUP}:${env.MYARTIFACT} ${env.MYVERSION} latest")], propagate: false, wait: false - } - } - } - } - post { - always { - script { - if (env.CHANGE_ID == null) { // This is unset for non-PRs - discordSend( - title: "${DISCORD_PREFIX} Finished ${currentBuild.currentResult}", - description: '```\n' + getChanges(currentBuild) + '\n```', - successful: currentBuild.resultIsBetterOrEqualTo("SUCCESS"), - result: currentBuild.currentResult, - thumbnail: JENKINS_HEAD, - webhookURL: DISCORD_WEBHOOK - ) - } - } - } - } -} \ No newline at end of file diff --git a/README.md b/README.md index 865c44b..171d504 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ The following are the core command-line options (options are optional unless oth - `--output ` - Path to the output JAR file; if not present, then the input JAR file is _overwritten_ with the output - `--map `/`--names ` - Path to the mappings file, which may be of any format supported - by [SrgUtils][srgutils] + by [SrgUtils][srgutils]. Can be specified multiple times. If more than one mappings file is specified, the rest will + be merged with the first one sequentially, only using the first entry for any duplicates across all files. - `--reverse` - When present, any provided mappings are first reversed (`A -> B` becomes `B -> A`) before its application - `--log ` - Path to an output file for logging; if not present, then logging is directed to the diff --git a/src/main/java/net/neoforged/art/Main.java b/src/main/java/net/neoforged/art/Main.java index f664921..f9367f6 100644 --- a/src/main/java/net/neoforged/art/Main.java +++ b/src/main/java/net/neoforged/art/Main.java @@ -15,6 +15,7 @@ import java.util.Arrays; import java.util.List; import java.util.function.Consumer; +import java.util.stream.Collectors; import java.util.stream.Stream; import joptsimple.OptionException; import joptsimple.OptionParser; @@ -100,9 +101,12 @@ public static void main(String[] args) throws IOException { // Map is optional so that we can run other fixes without renaming. // This does mean that it's not strictly a 'renaming' tool but screw it I like the name. if (options.has(mapO)) { - File mapF = options.valueOf(mapO); - log.accept("Names: " + mapF.getAbsolutePath() + "(reversed: " + options.has(reverseO) + ")"); - IMappingFile mappings = IMappingFile.load(mapF); + List mapF = options.valuesOf(mapO); + log.accept("Names: " + mapF.stream().map(File::getAbsolutePath).collect(Collectors.joining(", ")) + "(reversed: " + options.has(reverseO) + ")"); + IMappingFile mappings = IMappingFile.load(mapF.get(0)); + for (int i = 1; i < mapF.size(); i++) { + mappings = mappings.merge(IMappingFile.load(mapF.get(i))); + } if (options.has(reverseO)) { mappings = mappings.reverse(); }