Class MicronautAotOptimizer

java.lang.Object
io.micronaut.aot.MicronautAotOptimizer
All Implemented Interfaces:
ConfigKeys

public final class MicronautAotOptimizer extends Object implements ConfigKeys
The Micronaut AOT optimizer is the main entry point for code generation at build time. Its role is to generate a bunch of source code for various optimizations which can be computed at build time. Typically, generated code will involve the generation of an "optimized" entry point for the application, which delegates to the main entry point, but also performs some static initialization by making calls to the StaticOptimizations class. The Micronaut AOT optimizer is experimental and won't do anything by its own: it must be integrated in some form, for example via a build plugin, which in turn will make the generated classes visible to the user. For example, the build tool may call this class to generate the optimization code, and in addition create an optimized jar, an optimized native binary or even a full distribution. The optimizer works by passing in the whole application runtime classpath and a set of configuration options. It then analyzes the classpath, for example to identify the services to be loaded, or to provide some alternative implementations to existing classes.
  • Field Details

  • Method Details

    • exportConfiguration

      public static void exportConfiguration(String runtime, File propertiesFile)
      Scans the list of available optimization services and generates a configuration file which includes all entries.
      Parameters:
      runtime - the runtime for which to generate a properties file
      propertiesFile - the generated properties file
    • execute

      public static void execute(Properties props)
      This convenience method uses properties to load the configuration. This is useful because the optimizer must be found on the same classloader as the application under optimization, otherwise it would mean that we could have a clash between Micronaut runtime versions.
      Parameters:
      props - the configuration properties
    • runner

      public static MicronautAotOptimizer.Runner runner(String generatedPackage, File outputSourcesDirectory, File outputClassesDirectory, File logsDirectory, Configuration config)