Class PyronautCompiler.Builder
java.lang.Object
io.micronaut.python.compiler.PyronautCompiler.Builder
- Enclosing class:
PyronautCompiler
Builder for PyronautCompiler.
- Since:
- 5.2.0
- Author:
- Micronaut
-
Method Summary
Modifier and TypeMethodDescriptionannotationProcessorPath(List<File> annotationProcessorPath) Set annotation processor path entries for processing.annotationProcessors(List<? extends Processor> annotationProcessors) Supplies annotation processors used only for this compilation.applicationClass(String applicationClass) Set the fully qualified name of an existing application class annotated with @PythonApplication.bootclasspath(List<File> bootclasspath) Set boot classpath entries.build()Build the PyronautCompiler instance.classElementCallback(Consumer<ClassElement> classElementCallback) Set a callback to be invoked for each class element created during processing.Set additional classpath entries for processing.compilePythonBytecode(boolean compilePythonBytecode) Enable generation of hash-based GraalPy bytecode for Python resources generated during annotation processing.errorDumpDirectory(File errorDumpDirectory) Set the directory used for full compiler error dump files.incremental(boolean incremental) Enable incremental disk compilation.incrementalCacheDirectory(File incrementalCacheDirectory) Set the directory used to persist incremental compilation state.Set the Java source directory to scan for .java files to include in processing.Sets compiler options.packageName(String packageName) Set the package name for the generated application class.parentClassLoader(ClassLoader parentClassLoader) Set the parent classloader for in-memory processing results.pythonCode(String pythonCode) Set the inline Python code to process.pythonIncrementalMode(PythonIncrementalMode pythonIncrementalMode) Set how incremental compilation handles dynamic or unresolved Python relationships.pythonProcessingSession(PythonProcessingSession pythonProcessingSession) Reuse an initialized GraalPy context across serialized compiler invocations.pythonSourceVisitors(List<? extends PythonSourceVisitor> pythonSourceVisitors) Supplies visitors for Python source metadata.Set the Python source directory to scan for .py files.runtimeClasspath(List<File> runtimeClasspath) Set classpath entries used by the in-memory application runtime.Set the target directory for file system processing mode.verboseErrors(boolean verboseErrors) Include full diagnostics and stack traces in thrown compiler errors.
-
Method Details
-
packageName
Set the package name for the generated application class. Must be a valid Java package name. Defaults to "pyronaut_application".- Parameters:
packageName- The package name- Returns:
- This builder
-
pythonSrc
Set the Python source directory to scan for .py files.- Parameters:
pythonSrc- The Python source directory path- Returns:
- This builder
-
pythonCode
Set the inline Python code to process.- Parameters:
pythonCode- The Python code- Returns:
- This builder
-
javaSrc
Set the Java source directory to scan for .java files to include in processing.- Parameters:
javaSrc- The Java source directory path- Returns:
- This builder
-
applicationClass
Set the fully qualified name of an existing application class annotated with @PythonApplication. If specified, no Java source will be generated. Requires javaSrc to be set.- Parameters:
applicationClass- The application class name- Returns:
- This builder
-
targetDir
Set the target directory for file system processing mode.- Parameters:
targetDir- The target directory- Returns:
- This builder
-
annotationProcessorPath
Set annotation processor path entries for processing.- Parameters:
annotationProcessorPath- The classpath files- Returns:
- This builder
-
classpath
Set additional classpath entries for processing.- Parameters:
classpath- The classpath files- Returns:
- This builder
-
runtimeClasspath
Set classpath entries used by the in-memory application runtime. When unset, the compile classpath is used for backward compatibility.- Parameters:
runtimeClasspath- The runtime classpath files- Returns:
- This builder
-
bootclasspath
Set boot classpath entries.- Parameters:
bootclasspath- The boot classpath files- Returns:
- This builder
-
parentClassLoader
Set the parent classloader for in-memory processing results. This lets generated application classes resolve user runtime dependencies without requiring generated classes to be written to disk first.- Parameters:
parentClassLoader- The parent classloader- Returns:
- This builder
-
classElementCallback
Set a callback to be invoked for each class element created during processing. This is primarily used for testing purposes to capture class elements.- Parameters:
classElementCallback- The callback function- Returns:
- This builder
-
options
Sets compiler options.- Parameters:
compilerOptions- the compiler options- Returns:
- this builder
-
verboseErrors
Include full diagnostics and stack traces in thrown compiler errors.- Parameters:
verboseErrors- Whether verbose errors should be thrown- Returns:
- this builder
-
compilePythonBytecode
Enable generation of hash-based GraalPy bytecode for Python resources generated during annotation processing. Source resources remain available alongside the bytecode.- Parameters:
compilePythonBytecode- Whether generated Python resources should include bytecode- Returns:
- This builder
- Since:
- 5.2.0
-
incremental
Enable incremental disk compilation. Incremental compilation is disabled by default and has no effect onPyronautCompiler.buildClassLoader().- Parameters:
incremental- Whether disk compilation should reuse compatible previous outputs- Returns:
- This builder
- Since:
- 5.2.0
-
incrementalCacheDirectory
Set the directory used to persist incremental compilation state. The directory must not contain, or be contained by, the target output directory.- Parameters:
incrementalCacheDirectory- The incremental compilation state directory- Returns:
- This builder
- Since:
- 5.2.0
-
pythonIncrementalMode
Set how incremental compilation handles dynamic or unresolved Python relationships. Defaults toPythonIncrementalMode.CONSERVATIVE.- Parameters:
pythonIncrementalMode- The Python incremental dependency policy- Returns:
- This builder
- Since:
- 5.2.0
-
pythonProcessingSession
public PyronautCompiler.Builder pythonProcessingSession(PythonProcessingSession pythonProcessingSession) Reuse an initialized GraalPy context across serialized compiler invocations.The caller owns the session and must close it after the final compilation.
- Parameters:
pythonProcessingSession- The reusable Python processing session- Returns:
- This builder
- Since:
- 5.2.0
-
errorDumpDirectory
Set the directory used for full compiler error dump files.- Parameters:
errorDumpDirectory- The dump directory- Returns:
- this builder
-
pythonSourceVisitors
public PyronautCompiler.Builder pythonSourceVisitors(List<? extends PythonSourceVisitor> pythonSourceVisitors) Supplies visitors for Python source metadata.- Parameters:
pythonSourceVisitors- visitors to invoke for Python source metadata in this compilation- Returns:
- this builder
-
annotationProcessors
public PyronautCompiler.Builder annotationProcessors(List<? extends Processor> annotationProcessors) Supplies annotation processors used only for this compilation.- Parameters:
annotationProcessors- processors to invoke before standard Pyronaut processors- Returns:
- this builder
-
build
Build the PyronautCompiler instance.- Returns:
- A new PyronautCompiler
-