Package atessera.comp

Class LocalCompiler

java.lang.Object
atessera.comp.LocalCompiler
All Implemented Interfaces:
Compiler

public final class LocalCompiler extends Object implements Compiler
Default Compiler implementation that executes commands locally in an isolated temporary directory.

LocalCompiler performs the following steps for each CompilationTask:

  1. Creates a temporary working directory via TempDir.
  2. Writes all text and binary source files into that directory.
  3. Executes the task's shell commands sequentially. Each command's stdout and stderr are captured in separate threads (via ShellCmd) to prevent deadlocks.
  4. If a command fails (non-zero exit code), collects the files listed in saveTextFilesOnFailure and returns immediately.
  5. If all commands succeed, collects the files listed in saveTextFilesOnSuccess and saveBinaryFilesOnSuccess.
  6. Cleans up the temporary directory (via try-with-resources).

In case of an internal exception (e.g. I/O error), the method sets the exit code to -1, captures the stack trace in the result, and returns the result object; it does not throw.

See Also:
  • Constructor Details

    • LocalCompiler

      public LocalCompiler()
  • Method Details

    • compile

      public CompilationResult compile(CompilationTask task)
      Executes the compilation task in a local temporary directory.
      Specified by:
      compile in interface Compiler
      Parameters:
      task - the compilation task to execute; must not be null
      Returns:
      the compilation result; never null in normal operation (even on failure, a result with a non-zero exit code is returned)