use of io.quarkus.deployment.builditem.LiveReloadBuildItem in project quarkus-operator-sdk by quarkiverse.
the class OperatorSDKProcessor method createConfigurationServiceAndOperator.
@BuildStep
ConfigurationServiceBuildItem createConfigurationServiceAndOperator(OutputTargetBuildItem outputTarget, CombinedIndexBuildItem combinedIndexBuildItem, BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<ReflectiveClassBuildItem> reflectionClasses, BuildProducer<ForceNonWeakReflectiveClassBuildItem> forcedReflectionClasses, BuildProducer<GeneratedCRDInfoBuildItem> generatedCRDInfo, LiveReloadBuildItem liveReload) {
final CRDConfiguration crdConfig = buildTimeConfiguration.crd;
final boolean validateCustomResources = ConfigurationUtils.shouldValidateCustomResources(buildTimeConfiguration.checkCRDAndValidateLocalModel, buildTimeConfiguration.crd.validate, log);
// apply should imply generate: we cannot apply if we're not generating!
final var crdGeneration = new CRDGeneration(crdConfig.generate || crdConfig.apply);
final var index = combinedIndexBuildItem.getIndex();
final List<QuarkusControllerConfiguration> controllerConfigs = ClassUtils.getKnownReconcilers(index, log).map(ci -> createControllerConfiguration(ci, additionalBeans, reflectionClasses, forcedReflectionClasses, index, crdGeneration, liveReload)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
// retrieve the known CRD information to make sure we always have a full view
var storedCRDInfos = liveReload.getContextObject(ContextStoredCRDInfos.class);
if (storedCRDInfos == null) {
storedCRDInfos = new ContextStoredCRDInfos();
}
CRDGenerationInfo crdInfo = crdGeneration.generate(outputTarget, crdConfig, validateCustomResources, storedCRDInfos.getExisting());
storedCRDInfos.putAll(crdInfo.getCrds());
// record CRD generation info in context for future use
liveReload.setContextObject(ContextStoredCRDInfos.class, storedCRDInfos);
additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(OperatorProducer.class));
// if the app doesn't provide a main class, add the AppEventListener
if (index.getAllKnownImplementors(DotName.createSimple(QuarkusApplication.class.getName())).isEmpty()) {
additionalBeans.produce(AdditionalBeanBuildItem.builder().addBeanClass(AppEventListener.class).setDefaultScope(DotName.createSimple(Singleton.class.getName())).setUnremovable().build());
}
generatedCRDInfo.produce(new GeneratedCRDInfoBuildItem(crdInfo));
return new ConfigurationServiceBuildItem(Version.loadFromProperties(), controllerConfigs);
}
Aggregations