Search in sources :

Example 1 with CodeTranslator

use of io.vertx.codetrans.CodeTranslator in project vertx-examples by vert-x3.

the class CodeTransProcessor method init.

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    String outputOption = processingEnv.getOptions().get("codetrans.output");
    if (outputOption != null) {
        outputDir = new File(outputOption);
    }
    translator = new CodeTranslator(processingEnv);
    langs = Arrays.asList(new JavaScriptLang(), new GroovyLang(), new RubyLang());
    String configFile = processingEnv.getOptions().get("codetrans.config");
    if (configFile != null) {
        ObjectMapper mapper = new ObjectMapper().enable(JsonParser.Feature.ALLOW_COMMENTS).enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES);
        File file = new File(configFile);
        try {
            config = (ObjectNode) mapper.readTree(file);
        } catch (IOException e) {
            System.err.println("[ERROR] Cannot read configuration file " + file.getAbsolutePath() + " : " + e.getMessage());
            e.printStackTrace();
        }
    }
}
Also used : JavaScriptLang(io.vertx.codetrans.lang.js.JavaScriptLang) RubyLang(io.vertx.codetrans.lang.ruby.RubyLang) GroovyLang(io.vertx.codetrans.lang.groovy.GroovyLang) IOException(java.io.IOException) File(java.io.File) CodeTranslator(io.vertx.codetrans.CodeTranslator) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 CodeTranslator (io.vertx.codetrans.CodeTranslator)1 GroovyLang (io.vertx.codetrans.lang.groovy.GroovyLang)1 JavaScriptLang (io.vertx.codetrans.lang.js.JavaScriptLang)1 RubyLang (io.vertx.codetrans.lang.ruby.RubyLang)1 File (java.io.File)1 IOException (java.io.IOException)1