diff --git a/extensions/kafka-streams/deployment/src/main/java/io/quarkus/kafka/streams/deployment/KafkaStreamsProcessor.java b/extensions/kafka-streams/deployment/src/main/java/io/quarkus/kafka/streams/deployment/KafkaStreamsProcessor.java index ebb06368d0ed8..71ff4ebc25cf9 100644 --- a/extensions/kafka-streams/deployment/src/main/java/io/quarkus/kafka/streams/deployment/KafkaStreamsProcessor.java +++ b/extensions/kafka-streams/deployment/src/main/java/io/quarkus/kafka/streams/deployment/KafkaStreamsProcessor.java @@ -2,7 +2,6 @@ import static io.quarkus.kafka.streams.runtime.KafkaStreamsPropertiesUtil.buildKafkaStreamsProperties; -import java.io.IOException; import java.util.Properties; import jakarta.inject.Singleton; @@ -16,7 +15,6 @@ import org.apache.kafka.streams.processor.internals.StreamsPartitionAssignor; import org.rocksdb.RocksDBException; import org.rocksdb.Status; -import org.rocksdb.util.Environment; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.deployment.SyntheticBeanBuildItem; @@ -28,16 +26,16 @@ import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.LaunchModeBuildItem; +import io.quarkus.deployment.builditem.NativeImageFeatureBuildItem; import io.quarkus.deployment.builditem.nativeimage.JniRuntimeAccessBuildItem; -import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem; -import io.quarkus.deployment.pkg.builditem.NativeImageRunnerBuildItem; import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.kafka.streams.runtime.KafkaStreamsProducer; import io.quarkus.kafka.streams.runtime.KafkaStreamsRecorder; import io.quarkus.kafka.streams.runtime.KafkaStreamsRuntimeConfig; import io.quarkus.kafka.streams.runtime.KafkaStreamsSupport; +import io.quarkus.kafka.streams.runtime.graal.KafkaStreamsFeature; import io.quarkus.smallrye.health.deployment.spi.HealthBuildItem; class KafkaStreamsProcessor { @@ -53,12 +51,9 @@ FeatureBuildItem feature() { void build(BuildProducer reflectiveClasses, BuildProducer jniRuntimeAccessibleClasses, BuildProducer reinitialized, - BuildProducer nativeLibs, - LaunchModeBuildItem launchMode, - NativeImageRunnerBuildItem nativeImageRunner) throws IOException { + LaunchModeBuildItem launchMode) { registerClassesThatAreLoadedThroughReflection(reflectiveClasses, launchMode); registerClassesThatAreAccessedViaJni(jniRuntimeAccessibleClasses); - addSupportForRocksDbLib(nativeLibs, nativeImageRunner); enableLoadOfNativeLibs(reinitialized); } @@ -174,18 +169,6 @@ private void registerClassesThatAreAccessedViaJni(BuildProducer nativeLibs, - NativeImageRunnerBuildItem nativeImageRunnerFactory) { - // for RocksDB, either add linux64 native lib when targeting containers - if (nativeImageRunnerFactory.isContainerBuild()) { - nativeLibs.produce(new NativeImageResourceBuildItem("librocksdbjni-linux64.so")); - } - // otherwise the native lib of the platform this build runs on - else { - nativeLibs.produce(new NativeImageResourceBuildItem(Environment.getJniLibraryFileName("rocksdb"))); - } - } - private void enableLoadOfNativeLibs(BuildProducer reinitialized) { reinitialized.produce(new RuntimeReinitializedClassBuildItem("org.rocksdb.RocksDB")); } @@ -236,4 +219,9 @@ void addHealthChecks(KafkaStreamsBuildTimeConfig buildTimeConfig, BuildProducer< "io.quarkus.kafka.streams.runtime.health.KafkaStreamsStateHealthCheck", buildTimeConfig.healthEnabled)); } + + @BuildStep + NativeImageFeatureBuildItem kafkaStreamsFeature() { + return new NativeImageFeatureBuildItem(KafkaStreamsFeature.class.getName()); + } } diff --git a/extensions/kafka-streams/runtime/src/main/java/io/quarkus/kafka/streams/runtime/graal/KafkaStreamsFeature.java b/extensions/kafka-streams/runtime/src/main/java/io/quarkus/kafka/streams/runtime/graal/KafkaStreamsFeature.java new file mode 100644 index 0000000000000..6fee5bc96b238 --- /dev/null +++ b/extensions/kafka-streams/runtime/src/main/java/io/quarkus/kafka/streams/runtime/graal/KafkaStreamsFeature.java @@ -0,0 +1,15 @@ +package io.quarkus.kafka.streams.runtime.graal; + +import org.graalvm.nativeimage.hosted.Feature; +import org.graalvm.nativeimage.hosted.RuntimeResourceAccess; +import org.rocksdb.util.Environment; + +public class KafkaStreamsFeature implements Feature { + + @Override + public void afterRegistration(AfterRegistrationAccess access) { + String libraryFileName = Environment.getJniLibraryFileName("rocksdb"); + RuntimeResourceAccess.addResource(Environment.class.getModule(), libraryFileName); + } + +}