Search in sources :

Example 1 with RunTimeConfigurationDefaultBuildItem

use of io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem in project quarkus-github-action by quarkiverse.

the class GitHubActionProcessor method silentStartup.

@BuildStep
void silentStartup(BuildProducer<RunTimeConfigurationDefaultBuildItem> configurationDefaults) {
    configurationDefaults.produce(new RunTimeConfigurationDefaultBuildItem("quarkus.log.level", "WARNING"));
    configurationDefaults.produce(new RunTimeConfigurationDefaultBuildItem("quarkus.banner.enabled", "false"));
}
Also used : RunTimeConfigurationDefaultBuildItem(io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 2 with RunTimeConfigurationDefaultBuildItem

use of io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem in project camel-quarkus by apache.

the class KafkaProcessor method configureKafkaComponentForDevServices.

@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public void configureKafkaComponentForDevServices(DevServicesLauncherConfigResultBuildItem devServiceResult, KafkaBuildTimeConfig kafkaBuildTimeConfig, BuildProducer<RunTimeConfigurationDefaultBuildItem> runTimeConfig) {
    Config config = ConfigProvider.getConfig();
    Optional<String> brokers = config.getOptionalValue(CAMEL_KAFKA_BROKERS, String.class);
    if (brokers.isEmpty() && kafkaBuildTimeConfig.devservices.enabled.orElse(true)) {
        String kafkaBootstrapServers = devServiceResult.getConfig().get(KAFKA_BOOTSTRAP_SERVERS);
        if (kafkaBootstrapServers != null) {
            runTimeConfig.produce(new RunTimeConfigurationDefaultBuildItem(CAMEL_KAFKA_BROKERS, kafkaBootstrapServers));
        }
    }
}
Also used : GlobalDevServicesConfig(io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig) KafkaBuildTimeConfig(io.quarkus.kafka.client.deployment.KafkaBuildTimeConfig) Config(org.eclipse.microprofile.config.Config) RunTimeConfigurationDefaultBuildItem(io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 3 with RunTimeConfigurationDefaultBuildItem

use of io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem in project quarkus-logging-logback by quarkiverse.

the class LoggingLogbackProcessor method init.

@Record(ExecutionTime.STATIC_INIT)
@BuildStep
void init(LogbackRecorder recorder, RecorderContext context, BuildProducer<RunTimeConfigurationDefaultBuildItem> runTimeConfigurationDefaultBuildItemBuildProducer, BuildProducer<GeneratedClassBuildItem> generatedClasses, OutputTargetBuildItem outputTargetBuildItem, CurateOutcomeBuildItem curateOutcomeBuildItem, ShutdownContextBuildItem shutdownContextBuildItem) throws Exception {
    // first check the versions
    doVersionCheck();
    URL url = getUrl();
    if (url == null) {
        return;
    }
    context.registerSubstitution(StartEvent.class, StartSub.class, (Class) EventSubstitution.class);
    context.registerSubstitution(BodyEvent.class, BodySub.class, (Class) EventSubstitution.class);
    context.registerSubstitution(EndEvent.class, EndSub.class, (Class) EventSubstitution.class);
    final AtomicReference<List<SaxEvent>> events = new AtomicReference<>();
    JoranConfigurator configurator = new JoranConfigurator() {

        @Override
        public void doConfigure(List<SaxEvent> eventList) throws JoranException {
            events.set(eventList);
        }
    };
    configurator.setContext(new LoggerContext());
    configurator.doConfigure(url);
    List<String> loggerPath = Arrays.asList("configuration", "logger");
    List<String> rootPath = Arrays.asList("configuration", "root");
    String rootLevel = null;
    Map<String, String> levels = new HashMap<>();
    Set<String> allClasses = new HashSet<>();
    for (SaxEvent i : events.get()) {
        if (i instanceof StartEvent) {
            StartEvent s = ((StartEvent) i);
            if (Objects.equals(loggerPath, s.elementPath.getCopyOfPartList())) {
                String level = s.attributes.getValue("level");
                if (level != null) {
                    levels.put(s.attributes.getValue("name"), level);
                }
            } else if (Objects.equals(rootPath, s.elementPath.getCopyOfPartList())) {
                String level = s.attributes.getValue("level");
                if (level != null) {
                    rootLevel = level;
                }
            }
            int classIndex = s.attributes.getIndex("class");
            if (classIndex != -1) {
                allClasses.add(s.attributes.getValue(classIndex));
            }
        }
    }
    boolean disableConsole = false;
    Set<String> delayedClasses = new HashSet<>();
    for (String i : allClasses) {
        if (i.equals("ch.qos.logback.core.ConsoleAppender")) {
            disableConsole = true;
        }
        try {
            Class<?> c = Thread.currentThread().getContextClassLoader().loadClass(i);
            if (LifeCycle.class.isAssignableFrom(c)) {
                delayedClasses.add(i);
            }
        } catch (ClassNotFoundException exception) {
            throw new RuntimeException(exception);
        }
    }
    if (disableConsole) {
        runTimeConfigurationDefaultBuildItemBuildProducer.produce(new RunTimeConfigurationDefaultBuildItem("quarkus.log.console.enable", "false"));
    }
    for (String i : delayedClasses) {
        try (ClassCreator c = new ClassCreator(new GeneratedClassGizmoAdaptor(generatedClasses, (Function<String, String>) s -> s.substring(s.length() - LogbackRecorder.DELAYED.length())), i + LogbackRecorder.DELAYED, null, i, DelayedStart.class.getName())) {
            MethodCreator start = c.getMethodCreator("start", void.class);
            start.invokeStaticMethod(MethodDescriptor.ofMethod(LogbackRecorder.class, "addDelayed", void.class, DelayedStart.class), start.getThis());
            start.returnValue(null);
            MethodCreator method = c.getMethodCreator("doQuarkusDelayedStart", void.class);
            method.invokeSpecialMethod(MethodDescriptor.ofMethod(i, "start", void.class), method.getThis());
            method.returnValue(null);
        }
    }
    if (rootLevel != null) {
        runTimeConfigurationDefaultBuildItemBuildProducer.produce(new RunTimeConfigurationDefaultBuildItem("quarkus.log.level", rootLevel));
    }
    for (Map.Entry<String, String> e : levels.entrySet()) {
        runTimeConfigurationDefaultBuildItemBuildProducer.produce(new RunTimeConfigurationDefaultBuildItem("quarkus.log.category.\"" + e.getKey() + "\".level", e.getValue()));
    }
    Map<String, String> buildProperties = new HashMap<>(outputTargetBuildItem.getBuildSystemProperties().entrySet().stream().collect(Collectors.toMap(Object::toString, Object::toString)));
    buildProperties.put(PROJECT_VERSION, curateOutcomeBuildItem.getEffectiveModel().getAppArtifact().getVersion());
    recorder.init(events.get(), delayedClasses, shutdownContextBuildItem, buildProperties);
}
Also used : DelayedStart(io.quarkiverse.logback.runtime.DelayedStart) HashMap(java.util.HashMap) ClassCreator(io.quarkus.gizmo.ClassCreator) URL(java.net.URL) LogbackRecorder(io.quarkiverse.logback.runtime.LogbackRecorder) Function(java.util.function.Function) JoranConfigurator(ch.qos.logback.classic.joran.JoranConfigurator) StartEvent(ch.qos.logback.core.joran.event.StartEvent) List(java.util.List) EventSubstitution(io.quarkiverse.logback.runtime.events.EventSubstitution) HashSet(java.util.HashSet) AtomicReference(java.util.concurrent.atomic.AtomicReference) LoggerContext(ch.qos.logback.classic.LoggerContext) GeneratedClassGizmoAdaptor(io.quarkus.deployment.GeneratedClassGizmoAdaptor) MethodCreator(io.quarkus.gizmo.MethodCreator) SaxEvent(ch.qos.logback.core.joran.event.SaxEvent) RunTimeConfigurationDefaultBuildItem(io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem) Map(java.util.Map) HashMap(java.util.HashMap) Record(io.quarkus.deployment.annotations.Record) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 4 with RunTimeConfigurationDefaultBuildItem

use of io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem in project kogito-runtimes by kiegroup.

the class ProcessesAssetsProcessor method getGeneratedPersistenceFiles.

private Collection<GeneratedFile> getGeneratedPersistenceFiles(IndexView index, KogitoBuildContext context, BuildProducer<RunTimeConfigurationDefaultBuildItem> runTimeConfiguration, BuildProducer<NativeImageResourcePatternsBuildItem> resourcePatterns) {
    ClassInfo persistenceClass = index.getClassByName(persistenceFactoryClass);
    Collection<ClassInfo> modelClasses = index.getAllKnownImplementors(DotName.createSimple(Model.class.getCanonicalName()));
    JandexProtoGenerator protoGenerator = JandexProtoGenerator.builder(index).withPersistenceClass(persistenceClass).build(modelClasses);
    PersistenceGenerator persistenceGenerator = new PersistenceGenerator(context, protoGenerator, new JandexMarshallerGenerator(context, modelClasses));
    if (persistenceGenerator.persistenceType().equals(PersistenceGenerator.POSTGRESQL_PERSISTENCE_TYPE) || persistenceGenerator.persistenceType().equals(PersistenceGenerator.JDBC_PERSISTENCE_TYPE)) {
        resourcePatterns.produce(new NativeImageResourcePatternsBuildItem.Builder().includeGlob("sql/*.sql").build());
    } else if (persistenceGenerator.persistenceType().equals(PersistenceGenerator.KAFKA_PERSISTENCE_TYPE)) {
        String processIds = protoGenerator.getProcessIds().stream().map(s -> "kogito.process." + s).collect(joining(","));
        runTimeConfiguration.produce(new RunTimeConfigurationDefaultBuildItem(PersistenceGenerator.QUARKUS_KAFKA_STREAMS_TOPICS_PROP, processIds));
    }
    return persistenceGenerator.generate();
}
Also used : PersistenceGenerator(org.kie.kogito.codegen.process.persistence.PersistenceGenerator) NativeImageResourcePatternsBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourcePatternsBuildItem) RunTimeConfigurationDefaultBuildItem(io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem) ClassInfo(org.jboss.jandex.ClassInfo)

Aggregations

RunTimeConfigurationDefaultBuildItem (io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem)4 BuildStep (io.quarkus.deployment.annotations.BuildStep)3 LoggerContext (ch.qos.logback.classic.LoggerContext)1 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)1 SaxEvent (ch.qos.logback.core.joran.event.SaxEvent)1 StartEvent (ch.qos.logback.core.joran.event.StartEvent)1 DelayedStart (io.quarkiverse.logback.runtime.DelayedStart)1 LogbackRecorder (io.quarkiverse.logback.runtime.LogbackRecorder)1 EventSubstitution (io.quarkiverse.logback.runtime.events.EventSubstitution)1 GeneratedClassGizmoAdaptor (io.quarkus.deployment.GeneratedClassGizmoAdaptor)1 Record (io.quarkus.deployment.annotations.Record)1 NativeImageResourcePatternsBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageResourcePatternsBuildItem)1 GlobalDevServicesConfig (io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig)1 ClassCreator (io.quarkus.gizmo.ClassCreator)1 MethodCreator (io.quarkus.gizmo.MethodCreator)1 KafkaBuildTimeConfig (io.quarkus.kafka.client.deployment.KafkaBuildTimeConfig)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1