Last active
November 5, 2024 16:44
-
-
Save wreulicke/8aabaa4947809f075ed2d36d675bf8aa to your computer and use it in GitHub Desktop.
jbangで標準入力から入ってきたxmlをlogback-tylerを処理してJavaコードを出力するやつ + google-java-formatでフォーマットしたやつを出力するやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JAVA 21 | |
//DEPS ch.qos.logback.tyler:tyler-base:0.9 com.google.googlejavaformat:google-java-format:1.24.0 | |
// | |
//RUNTIME_OPTIONS --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED | |
//RUNTIME_OPTIONS --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED | |
//RUNTIME_OPTIONS --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED | |
//RUNTIME_OPTIONS --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED | |
//RUNTIME_OPTIONS --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED | |
//RUNTIME_OPTIONS --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED | |
import ch.qos.logback.core.joran.spi.JoranException; | |
import ch.qos.logback.core.model.Model; | |
import ch.qos.logback.core.util.StatusPrinter; | |
import ch.qos.logback.core.ContextBase; | |
import ch.qos.logback.tyler.base.ModelToJava; | |
import com.google.googlejavaformat.java.Formatter; | |
public class tyler { | |
public static void main(String[] args) throws Exception{ | |
byte[] allBytes = System.in.readAllBytes(); | |
ContextBase context = new ContextBase(); | |
ModelToJava m2j = new ModelToJava(context); | |
Model model = m2j.extractModel(new String(allBytes)); | |
String result = m2j.toJava(model); | |
String formattedSource = new Formatter().formatSource(result); | |
System.out.println(formattedSource); | |
m2j.statusToStringList().forEach(System.err::println); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment