Class ModuleCompiler
java.lang.Object
com.netflix.module.compile.ModuleCompiler
- All Implemented Interfaces:
AutoCloseable
Compiles Java source modules to immutable filesystem directories.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordImmutable inputs affecting compilation and output reuse.static final recordFilesystem paths presenting a compiled module.static interfaceResolves the filesystem path for a declared module-path entry.static final recordControls reuse, diagnostic emission, and verbose javac output for one compilation. -
Constructor Summary
ConstructorsConstructorDescriptionModuleCompiler(Path outputRoot) Creates a compiler which does not emit diagnostics.ModuleCompiler(Path outputRoot, DiagnosticListener<? super JavaFileObject> diagnosticListener) Creates a compiler that reports current and retained javac diagnostics todiagnosticListener. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()compile(Path sourceRoot, ModuleCompiler.Configuration configuration, int targetRelease) Compiles or reuses a source module with the default options.compile(Path sourceRoot, ModuleCompiler.Configuration configuration, int targetRelease, ModuleCompiler.Options options) Compiles a source module with explicit reuse and diagnostic options.modulePath(String moduleName, CompiledModule compilation) Returns a reusable module path, retaining a patch when one is available.modulePath(String moduleName, CompiledModule compilation, boolean allowPatch) Returns paths presenting a compiled module, optionally materializing a complete module rather than returning a patch.write(CompiledModule compilation, Path target) Materializes a compiled module as one complete directory.
-
Constructor Details
-
ModuleCompiler
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 todiagnosticListener. Individual compilations can suppress emission withModuleCompiler.Options.SILENTwithout suppressing diagnostic retention.- Parameters:
outputRoot- the root for managed immutable compilation outputdiagnosticListener- the diagnostic recipient, ornull- 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 rootconfiguration- the compilation configurationtargetRelease- 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 rootconfiguration- the compilation configurationtargetRelease- the feature release of the compiling toolchainoptions- reuse and diagnostic options- Returns:
- immutable managed compilation output
- Throws:
IOException- if compilation or output management fails
-
write
Materializes a compiled module as one complete directory.- Parameters:
compilation- the managed compilation outputtarget- 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 namecompilation- 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 namecompilation- the managed compilation outputallowPatch- 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
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-