Search in sources :

Example 1 with MavenShade

use of net.md_5.specialsource.transformer.MavenShade in project SpecialSource by md-5.

the class JarMapping method loadMappings.

/**
 * @param filename A filename of a .srg/.csrg or an MCP directory of
 * .srg+.csv, local or remote
 * @param reverse Swap input and output mappings
 * @param numericSrgNames When reading mapping directory, load numeric "srg"
 * instead obfuscated names
 * @param inShadeRelocation Apply relocation on mapping input
 * @param outShadeRelocation Apply relocation on mapping output
 * @throws IOException
 */
public void loadMappings(String filename, boolean reverse, boolean numericSrgNames, String inShadeRelocation, String outShadeRelocation) throws IOException {
    // Optional shade relocation, on input or output names
    MappingTransformer inputTransformer = null;
    MappingTransformer outputTransformer = null;
    if (inShadeRelocation != null) {
        inputTransformer = new MavenShade(inShadeRelocation);
    }
    if (outShadeRelocation != null) {
        outputTransformer = new MavenShade(outShadeRelocation);
    }
    if (new File(filename).isDirectory() || filename.endsWith("/")) {
        if (inputTransformer != null || outputTransformer != null) {
            // yet
            throw new IllegalArgumentException("loadMappings(" + filename + "): shade relocation not supported on directories");
        }
        loadMappingsDir(filename, reverse, false, numericSrgNames);
    } else {
        if (numericSrgNames) {
            throw new IllegalArgumentException("loadMappings(" + filename + "): numeric only supported on directories, not files");
        }
        try (BufferedReader reader = new BufferedReader(new FileReader(FileLocator.getFile(filename)))) {
            loadMappings(reader, inputTransformer, outputTransformer, reverse);
        }
    }
}
Also used : MappingTransformer(net.md_5.specialsource.transformer.MappingTransformer) MavenShade(net.md_5.specialsource.transformer.MavenShade)

Aggregations

MappingTransformer (net.md_5.specialsource.transformer.MappingTransformer)1 MavenShade (net.md_5.specialsource.transformer.MavenShade)1