Class PyronautCompiler.Builder

java.lang.Object
io.micronaut.python.compiler.PyronautCompiler.Builder
Enclosing class:
PyronautCompiler

public static final class PyronautCompiler.Builder extends Object
Builder for PyronautCompiler.
Since:
5.2.0
Author:
Micronaut
  • Method Details

    • packageName

      public PyronautCompiler.Builder packageName(String 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

      public PyronautCompiler.Builder pythonSrc(String pythonSrc)
      Set the Python source directory to scan for .py files.
      Parameters:
      pythonSrc - The Python source directory path
      Returns:
      This builder
    • pythonCode

      public PyronautCompiler.Builder pythonCode(String pythonCode)
      Set the inline Python code to process.
      Parameters:
      pythonCode - The Python code
      Returns:
      This builder
    • javaSrc

      public PyronautCompiler.Builder javaSrc(String 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

      public PyronautCompiler.Builder applicationClass(String 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

      public PyronautCompiler.Builder targetDir(File targetDir)
      Set the target directory for file system processing mode.
      Parameters:
      targetDir - The target directory
      Returns:
      This builder
    • annotationProcessorPath

      public PyronautCompiler.Builder annotationProcessorPath(List<File> annotationProcessorPath)
      Set annotation processor path entries for processing.
      Parameters:
      annotationProcessorPath - The classpath files
      Returns:
      This builder
    • classpath

      public PyronautCompiler.Builder classpath(List<File> classpath)
      Set additional classpath entries for processing.
      Parameters:
      classpath - The classpath files
      Returns:
      This builder
    • runtimeClasspath

      public PyronautCompiler.Builder runtimeClasspath(List<File> 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

      public PyronautCompiler.Builder bootclasspath(List<File> bootclasspath)
      Set boot classpath entries.
      Parameters:
      bootclasspath - The boot classpath files
      Returns:
      This builder
    • parentClassLoader

      public PyronautCompiler.Builder parentClassLoader(ClassLoader 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

      public PyronautCompiler.Builder classElementCallback(Consumer<ClassElement> 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

      public PyronautCompiler.Builder options(List<String> compilerOptions)
      Sets compiler options.
      Parameters:
      compilerOptions - the compiler options
      Returns:
      this builder
    • verboseErrors

      public PyronautCompiler.Builder verboseErrors(boolean verboseErrors)
      Include full diagnostics and stack traces in thrown compiler errors.
      Parameters:
      verboseErrors - Whether verbose errors should be thrown
      Returns:
      this builder
    • compilePythonBytecode

      public PyronautCompiler.Builder compilePythonBytecode(boolean 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

      public PyronautCompiler.Builder incremental(boolean incremental)
      Enable incremental disk compilation. Incremental compilation is disabled by default and has no effect on PyronautCompiler.buildClassLoader().
      Parameters:
      incremental - Whether disk compilation should reuse compatible previous outputs
      Returns:
      This builder
      Since:
      5.2.0
    • incrementalCacheDirectory

      public PyronautCompiler.Builder incrementalCacheDirectory(File 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

      public PyronautCompiler.Builder pythonIncrementalMode(PythonIncrementalMode pythonIncrementalMode)
      Set how incremental compilation handles dynamic or unresolved Python relationships. Defaults to PythonIncrementalMode.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

      public PyronautCompiler.Builder errorDumpDirectory(File 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

      public PyronautCompiler build()
      Build the PyronautCompiler instance.
      Returns:
      A new PyronautCompiler