Package io.micronaut.aot
Class MicronautAotOptimizer
java.lang.Object
io.micronaut.aot.MicronautAotOptimizer
- All Implemented Interfaces:
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
Modifier and TypeClassDescriptionstatic final class
The main AOT optimizer runner. -
Field Summary
Fields inherited from interface io.micronaut.aot.ConfigKeys
CLASSPATH, GENERATED_PACKAGE, OUTPUT_DIRECTORY, RUNTIME
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
execute
(Properties props) This convenience method uses properties to load the configuration.static void
exportConfiguration
(String runtime, File propertiesFile) Scans the list of available optimization services and generates a configuration file which includes all entries.static MicronautAotOptimizer.Runner
runner
(String generatedPackage, File outputSourcesDirectory, File outputClassesDirectory, File logsDirectory, Configuration config)
-
Field Details
-
OUTPUT_RESOURCES_FILE_NAME
- See Also:
-
-
Method Details
-
exportConfiguration
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 filepropertiesFile
- the generated properties file
-
execute
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)
-