Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to load mappings from multiple files #12

Merged
merged 2 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 0 additions & 85 deletions Jenkinsfile

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ The following are the core command-line options (options are optional unless oth
- `--output <path>` - Path to the output JAR file; if not present, then the input JAR file is _overwritten_ with the
output
- `--map <path>`/`--names <path>` - 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>` - Path to an output file for logging; if not present, then logging is directed to the
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/net/neoforged/art/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<File> 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();
}
Expand Down