src/main/java/xelfi/compiler/XelfiCompilerMain.java
branchDirtyFix
changeset 15 cdb47e644581
parent 10 fe294d0f1297
parent 14 3ff7a893a7ce
     1.1 --- a/src/main/java/xelfi/compiler/XelfiCompilerMain.java	Tue Jan 17 21:12:37 2017 +0100
     1.2 +++ b/src/main/java/xelfi/compiler/XelfiCompilerMain.java	Tue Jan 24 04:30:13 2017 +0100
     1.3 @@ -6,6 +6,10 @@
     1.4  package xelfi.compiler;
     1.5  
     1.6  import java.io.*;
     1.7 +import java.util.Arrays;
     1.8 +import javax.tools.JavaCompiler;
     1.9 +import javax.tools.StandardJavaFileManager;
    1.10 +import javax.tools.ToolProvider;
    1.11  
    1.12  
    1.13  class XelfiCompilerMain extends Object implements MainCompiler
    1.14 @@ -34,7 +38,17 @@
    1.15        args[0] = file.toString();
    1.16        output("Compiling: " + args[0]);
    1.17      }
    1.18 -//    compile(args);
    1.19 +    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    1.20 +    StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
    1.21 +    try {
    1.22 +      compiler.getTask(new OutputStreamWriter(out), fm, null, Arrays.asList(args).subList(0, args.length - 1), null, fm.getJavaFileObjects(args[args.length - 1])).call();
    1.23 +    } finally {
    1.24 +      try {
    1.25 +        fm.close();
    1.26 +      } catch (IOException ex) {
    1.27 +         ex.printStackTrace();
    1.28 +      }
    1.29 +    }
    1.30      output("\n");
    1.31    }
    1.32