use of io.micronaut.aot.core.config.MetadataUtils in project micronaut-aot by micronaut-projects.
the class MicronautAotOptimizer method exportConfiguration.
/**
* Scans the list of available optimization services and generates
* a configuration file which includes all entries.
*
* @param runtime the runtime for which to generate a properties file
* @param propertiesFile the generated properties file
*/
public static void exportConfiguration(String runtime, File propertiesFile) {
List<AOTModule> list = SourceGeneratorLoader.list(Runtime.valueOf(runtime.toUpperCase(Locale.ENGLISH)));
try (PrintWriter wrt = new PrintWriter(new FileOutputStream(propertiesFile))) {
Deque<AOTModule> queue = new ArrayDeque<>(list);
while (!queue.isEmpty()) {
AOTModule generator = queue.pop();
if (!generator.description().isEmpty()) {
Arrays.stream(generator.description().split("\r?\n")).forEach(line -> wrt.println("# " + line));
}
wrt.println(generator.id() + ".enabled = true");
Arrays.stream(generator.subgenerators()).map(MetadataUtils::findMetadata).filter(Optional::isPresent).map(Optional::get).sorted(Collections.reverseOrder()).forEachOrdered(queue::addFirst);
for (Option option : generator.options()) {
wrt.println(toPropertiesSample(option));
}
wrt.println();
}
// Add options which are generic to all AOT modules
wrt.println("# " + Environments.TARGET_ENVIRONMENTS_DESCRIPTION);
wrt.println(Environments.TARGET_ENVIRONMENTS_NAMES + " = " + Environments.TARGET_ENVIRONMENTS_SAMPLE);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
Aggregations