Class LogbackPrecompiler.Request.Builder

java.lang.Object
io.micronaut.aot.logback.LogbackPrecompiler.Request.Builder
Enclosing class:
LogbackPrecompiler.Request

@Internal public static final class LogbackPrecompiler.Request.Builder extends Object
Since:
3.2.0
  • Method Details

    • applicationOutput

      public LogbackPrecompiler.Request.Builder applicationOutput(List<Path> roots)
      The application's own output, in class path order: its resource roots and class directories, or a jar. Required.

      Pass the class directories as well as the resources. Two rules need them: the engine stands down when the application carries a Logback or SLF4J class of its own, and when a Configurator is already registered, which an annotation processor does by writing the service file to the class output. The roots are one layer of the class path: when two of them hold the same name, the first wins. There are two exceptions, because wherever the roots are class path entries of their own both files are found: when two roots hold a logback.xml the engine stands down, as Logback reports the file that occurs twice, and the packaged application* and bootstrap* files of every root are read, since Micronaut can merge them. Only the entries LogbackPrecompiler.applicationInputs() describes are read; of everything else, the name. Every root has to exist.

      Parameters:
      roots - directories or jars
      Returns:
      this builder
    • runtimeClasspath

      public LogbackPrecompiler.Request.Builder runtimeClasspath(List<Path> entries)
      The runtime class path after the application, in order: jars or directories. Required.

      Each entry is one layer: a jar gives the names of its central directory, a directory the names of its files. logback-classic, logback-core and slf4j-api are taken from here, never from the caller's own class path, and the META-INF/MANIFEST.MF of the two Logback entries is read for their version. The packaged application* and bootstrap* configuration files of every entry are read as well, at its root, where Micronaut reads those of a dependency too, and under config/, which Micronaut reads only when overrideConfigLocations adds it. The engine stands down when one might set logger.config or logback.configurationFile, or might import configuration with micronaut.config.import, and warns when one might enable the distributed configuration client. Every entry has to exist.

      Parameters:
      entries - jars or directories
      Returns:
      this builder
    • targetRelease

      public LogbackPrecompiler.Request.Builder targetRelease(int release)
      The lowest Java release the application runs on. Required.

      The generated classes are class files of Java 25, so the engine stands down below that: a service file that names a class the JVM cannot load breaks Logback's initialisation.

      Parameters:
      release - a Java feature release, such as 25
      Returns:
      this builder
    • closedClassPath

      public LogbackPrecompiler.Request.Builder closedClassPath(boolean closed)
      Whether the class path given here is exactly the one the application runs on, as it is for a packager that fixes the class path at packaging time. false by default.

      When it is not, the class path can change after the build: a later test run sees the same output directory, an IDE leaves stale output, a file is mounted into a container image. The generated configurator then checks on every call, at startup and on each logging refresh, where Logback itself would look, that no logback-test.xml is visible and that the first visible logback.xml is the file that was compiled, by size and CRC-32, and hands over to Joran otherwise. A closed class path needs neither check: what was surveyed at build time is what runs.

      Parameters:
      closed - true only when nothing can be added to or changed on the class path
      Returns:
      this builder
    • build

      Builds the request.
      Returns:
      the request
      Throws:
      IllegalStateException - if a required input is not set