Class MicronautAotOptimizer

  • All Implemented Interfaces:
    ConfigKeys

    public final class MicronautAotOptimizer
    extends java.lang.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.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  MicronautAotOptimizer.Runner
      The main AOT optimizer runner.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void execute​(java.util.Properties props)
      This convenience method uses properties to load the configuration.
      static void exportConfiguration​(java.lang.String runtime, java.io.File propertiesFile)
      Scans the list of available optimization services and generates a configuration file which includes all entries.
      static MicronautAotOptimizer.Runner runner​(java.lang.String generatedPackage, java.io.File outputSourcesDirectory, java.io.File outputClassesDirectory, java.io.File logsDirectory, io.micronaut.aot.core.Configuration config)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • OUTPUT_RESOURCES_FILE_NAME

        public static final java.lang.String OUTPUT_RESOURCES_FILE_NAME
        See Also:
        Constant Field Values
    • Method Detail

      • exportConfiguration

        public static void exportConfiguration​(java.lang.String runtime,
                                               java.io.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​(java.util.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​(java.lang.String generatedPackage,
                                                          java.io.File outputSourcesDirectory,
                                                          java.io.File outputClassesDirectory,
                                                          java.io.File logsDirectory,
                                                          io.micronaut.aot.core.Configuration config)