Search in sources :

Example 1 with ProcessingRules

use of org.mariotaku.patchlib.common.model.ProcessingRules in project PatchLib by mariotaku.

the class PatchLibApplication method startProcess.

private boolean startProcess(File inFile, File outFile, CommandLine cmdLine) throws IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    final ProcessingRules conf = new ProcessingRules();
    conf.setRules(new HashMap<String, PatchClassInfo>());
    for (File rulesFile : getFiles(cmdLine.getOptionValue("rules"))) {
        final Map<String, PatchClassInfo> rulesMap = mapper.readValue(rulesFile, new TypeReference<Map<String, PatchClassInfo>>() {
        });
        conf.addRules(rulesMap);
    }
    try (InputStream is = new FileInputStream(inFile);
        OutputStream os = new FileOutputStream(outFile)) {
        final LibraryProcessor.CommandLineOptions options = getOptions(cmdLine);
        options.setSourceFilePath(inFile.getAbsolutePath());
        final LibraryProcessor processor = LibraryProcessor.get(is, os, inFile.getName(), conf, options);
        if (processor == null) {
            throw new UnsupportedOperationException("Unsupported library " + inFile);
        }
        return processor.process();
    }
}
Also used : LibraryProcessor(org.mariotaku.patchlib.common.processor.LibraryProcessor) PatchClassInfo(org.mariotaku.patchlib.common.model.PatchClassInfo) ProcessingRules(org.mariotaku.patchlib.common.model.ProcessingRules) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) HashMap(java.util.HashMap) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 PatchClassInfo (org.mariotaku.patchlib.common.model.PatchClassInfo)1 ProcessingRules (org.mariotaku.patchlib.common.model.ProcessingRules)1 LibraryProcessor (org.mariotaku.patchlib.common.processor.LibraryProcessor)1