Merging in usage of modern Java compiler DirtyFix tip
authorJaroslav Tulach <jaroslav.tulach@xelfi.cz>
Tue, 24 Jan 2017 04:30:13 +0100
branchDirtyFix
changeset 15cdb47e644581
parent 12 a3b670224d5d
parent 14 3ff7a893a7ce
Merging in usage of modern Java compiler
.hgignore
src/main/java/xelfi/compiler/XelfiCompilerMain.java
     1.1 --- a/.hgignore	Tue Jan 17 21:19:45 2017 +0100
     1.2 +++ b/.hgignore	Tue Jan 24 04:30:13 2017 +0100
     1.3 @@ -4,3 +4,5 @@
     1.4  \.rej$
     1.5  \.conflict\~$
     1.6  target
     1.7 +\.brw$
     1.8 +\.XelfiOptions
     2.1 --- a/src/main/java/xelfi/compiler/XelfiCompilerMain.java	Tue Jan 17 21:19:45 2017 +0100
     2.2 +++ b/src/main/java/xelfi/compiler/XelfiCompilerMain.java	Tue Jan 24 04:30:13 2017 +0100
     2.3 @@ -6,6 +6,10 @@
     2.4  package xelfi.compiler;
     2.5  
     2.6  import java.io.*;
     2.7 +import java.util.Arrays;
     2.8 +import javax.tools.JavaCompiler;
     2.9 +import javax.tools.StandardJavaFileManager;
    2.10 +import javax.tools.ToolProvider;
    2.11  
    2.12  
    2.13  class XelfiCompilerMain extends Object implements MainCompiler
    2.14 @@ -34,7 +38,17 @@
    2.15        args[0] = file.toString();
    2.16        output("Compiling: " + args[0]);
    2.17      }
    2.18 -//    compile(args);
    2.19 +    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    2.20 +    StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
    2.21 +    try {
    2.22 +      compiler.getTask(new OutputStreamWriter(out), fm, null, Arrays.asList(args).subList(0, args.length - 1), null, fm.getJavaFileObjects(args[args.length - 1])).call();
    2.23 +    } finally {
    2.24 +      try {
    2.25 +        fm.close();
    2.26 +      } catch (IOException ex) {
    2.27 +         ex.printStackTrace();
    2.28 +      }
    2.29 +    }
    2.30      output("\n");
    2.31    }
    2.32