Class ModuleCompiler

java.lang.Object
com.netflix.module.compile.ModuleCompiler
All Implemented Interfaces:
AutoCloseable

public final class ModuleCompiler extends Object implements AutoCloseable
Compiles Java source modules to immutable filesystem directories.
  • Constructor Details

    • ModuleCompiler

      public ModuleCompiler(Path outputRoot) throws IOException
      Creates a compiler which does not emit diagnostics.
      Parameters:
      outputRoot - the root for managed immutable compilation output
      Throws:
      IOException - if the output store cannot be initialized
    • ModuleCompiler

      public ModuleCompiler(Path outputRoot, DiagnosticListener<? super JavaFileObject> diagnosticListener) throws IOException
      Creates a compiler that reports current and retained javac diagnostics to diagnosticListener. Individual compilations can suppress emission with ModuleCompiler.Options.SILENT without suppressing diagnostic retention.
      Parameters:
      outputRoot - the root for managed immutable compilation output
      diagnosticListener - the diagnostic recipient, or null
      Throws:
      IOException - if the output store cannot be initialized
  • Method Details

    • compile

      public CompiledModule compile(Path sourceRoot, ModuleCompiler.Configuration configuration, int targetRelease) throws IOException
      Compiles or reuses a source module with the default options.
      Parameters:
      sourceRoot - the module's source root
      configuration - the compilation configuration
      targetRelease - the feature release of the compiling toolchain
      Returns:
      immutable managed compilation output
      Throws:
      IOException - if compilation or output management fails
    • compile

      public CompiledModule compile(Path sourceRoot, ModuleCompiler.Configuration configuration, int targetRelease, ModuleCompiler.Options options) throws IOException
      Compiles a source module with explicit reuse and diagnostic options. Forced compilations are still published as managed output.
      Parameters:
      sourceRoot - the module's source root
      configuration - the compilation configuration
      targetRelease - the feature release of the compiling toolchain
      options - reuse and diagnostic options
      Returns:
      immutable managed compilation output
      Throws:
      IOException - if compilation or output management fails
    • write

      public Path write(CompiledModule compilation, Path target) throws IOException
      Materializes a compiled module as one complete directory.
      Parameters:
      compilation - the managed compilation output
      target - the destination directory
      Returns:
      the normalized destination path
      Throws:
      IOException - if the output cannot be read or written
    • modulePath

      public ModuleCompiler.ModulePath modulePath(String moduleName, CompiledModule compilation) throws IOException
      Returns a reusable module path, retaining a patch when one is available.
      Parameters:
      moduleName - the compiled module name
      compilation - the managed compilation output
      Returns:
      paths presenting the compiled module
      Throws:
      IOException - if the output cannot be read or touched
    • modulePath

      public ModuleCompiler.ModulePath modulePath(String moduleName, CompiledModule compilation, boolean allowPatch) throws IOException
      Returns paths presenting a compiled module, optionally materializing a complete module rather than returning a patch.
      Parameters:
      moduleName - the compiled module name
      compilation - the managed compilation output
      allowPatch - whether a separate patch path may be returned
      Returns:
      paths presenting the compiled module
      Throws:
      IOException - if the output cannot be read, written, or touched
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException