Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

44
LINES

< > BotCompany Repo | #1033530 // JavaCompilation - uses direct ECJ

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (7002L) is out of date.

sclass JavaCompilation {
  File srcDir;
  L<File> libraries;
  File classesDir;
  bool verbose = true;
  S sourceLevel = "11";
  S moreOptions = "-warn:none";
  
  L<File> sources;
  File optionsFile;
  S compilerOutput;
  
  swappable void invokeJavaCompiler() {
    compilerOutput = invokeEcj_direct(optionsFile);
  }
  
  run {
    // collect sources

    sources = findJavaSourceFiles(srcDir);
    if (sources.isEmpty())
      throw new IOException("No sources found");

    // compile

    optionsFile = File.createTempFile("ecj", "", javaxTempDir());
    try {
      if (verbose) printWithMS("Compiling " + sources.size() + " source(s) to " + classesDir.getPath());
      if (verbose) printWithMS("Libraries: " + libraries);
      
      S options = unnull(moreOptions) + " -source " + sourceLevel + " -target " + sourceLevel;
      options += " -d " + pqO(classesDir.getPath());
      libraries.add(pathToJavaxJar());
      makeOptionsFileForJavaCompiler(optionsFile, sources, libraries, options);
      if (verbose) printWithMS("Options: " + loadTextFile(optionsFile));
      classesDir.mkdirs();
      time "invokeJavaCompiler" {
        invokeJavaCompiler();
      }
    } finally {
      optionsFile.delete();
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033530
Snippet name: JavaCompilation - uses direct ECJ
Eternal ID of this version: #1033530/11
Text MD5: 3ba80c361211779607202b6a41b94e32
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-06 23:22:06
Source code size: 1275 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 160 / 255
Version history: 10 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)