This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch 3.40.x in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 5145a52b3a667f4df57fbe12a76c9af365ba1e46 Author: James Netherton <[email protected]> AuthorDate: Fri Oct 9 11:55:16 2026 +0100 Fixes #9297. Replace the shaded grpc & netty in milvus-sdk-java with the Quarkus provided dependencies Add a camel-quarkus-milvus-client module that reverts the milvus-sdk-java grpc & netty package relocations and strips the shaded classes, native libraries, native-image configs and service files, so that camel-quarkus-milvus can use the dependencies provided by quarkus-grpc-common. This replaces the bytecode transformation previously done in MilvusProcessor. Co-authored-by: Claude Opus 5.5 <[email protected]> --- extensions/milvus/client/pom.xml | 126 +++++++++++++++++++++ .../milvus/deployment/MilvusProcessor.java | 73 ++---------- extensions/milvus/pom.xml | 1 + extensions/milvus/runtime/pom.xml | 11 ++ pom.xml | 1 + poms/bom/pom.xml | 32 ++++++ poms/bom/src/main/generated/flattened-full-pom.xml | 32 ++++++ .../src/main/generated/flattened-reduced-pom.xml | 32 ++++++ .../generated/flattened-reduced-verbose-pom.xml | 32 ++++++ .../quarkus/maven/UpdateExtensionDocPageMojo.java | 4 +- 10 files changed, 277 insertions(+), 67 deletions(-) diff --git a/extensions/milvus/client/pom.xml b/extensions/milvus/client/pom.xml new file mode 100644 index 0000000000..7f468bbb66 --- /dev/null +++ b/extensions/milvus/client/pom.xml @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-milvus-parent</artifactId> + <version>3.40.1-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-milvus-client</artifactId> + <name>Camel Quarkus :: Milvus :: Client</name> + + <description>io.milvus:milvus-sdk-java with grpc & netty package relocations reverted and associated classes stripped away + so that camel-quarkus-milvus can use the equivalent quarkus extensions as a replacement</description> + + <dependencies> + <dependency> + <groupId>io.milvus</groupId> + <artifactId>milvus-sdk-java</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <executions> + <execution> + <id>transform-milvus-sdk-java</id> + <goals> + <goal>shade</goal> + </goals> + <phase>package</phase> + <configuration> + <artifactSet> + <includes> + <include>io.milvus:milvus-sdk-java</include> + </includes> + </artifactSet> + <relocations> + <!-- The most specific patterns must come first --> + <relocation> + <pattern>io.milvus.shaded.io.grpc.netty.shaded.io.grpc</pattern> + <shadedPattern>io.grpc</shadedPattern> + </relocation> + <relocation> + <pattern>io.milvus.shaded.io.grpc.netty.shaded.io.netty</pattern> + <shadedPattern>io.netty</shadedPattern> + </relocation> + <relocation> + <pattern>io.milvus.shaded.io.grpc</pattern> + <shadedPattern>io.grpc</shadedPattern> + </relocation> + </relocations> + <filters> + <filter> + <artifact>io.milvus:milvus-sdk-java</artifact> + <excludes> + <!-- + Remove shaded grpc-netty-shaded packages & native libraries. + Replaced by grpc-netty, grpc-protobuf, grpc-stub & quarkus-netty. + --> + <exclude>io/milvus/shaded/**</exclude> + <exclude>META-INF/native/**</exclude> + <exclude>META-INF/native-image/**</exclude> + <exclude>META-INF/services/io.milvus.shaded.*</exclude> + <exclude>META-INF/services/reactor.blockhound.integration.BlockHoundIntegration</exclude> + <exclude>META-INF/io.netty.versions.properties</exclude> + <exclude>META-INF/maven/io.grpc/**</exclude> + <exclude>META-INF/maven/io.netty/**</exclude> + <exclude>META-INF/license/**</exclude> + </excludes> + </filter> + </filters> + <createSourcesJar>true</createSourcesJar> + <promoteTransitiveDependencies>true</promoteTransitiveDependencies> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <!-- + Quarkus resolves reactor modules to target/classes, which would otherwise be empty. + Unpack the transformed jar so that the classes are visible to the Jandex index. + --> + <id>unpack-transformed-milvus-sdk-java</id> + <goals> + <goal>run</goal> + </goals> + <phase>package</phase> + <configuration> + <target> + <unzip src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}" /> + </target> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/extensions/milvus/deployment/src/main/java/org/apache/camel/quarkus/component/milvus/deployment/MilvusProcessor.java b/extensions/milvus/deployment/src/main/java/org/apache/camel/quarkus/component/milvus/deployment/MilvusProcessor.java index dce0328658..18ab58ac55 100644 --- a/extensions/milvus/deployment/src/main/java/org/apache/camel/quarkus/component/milvus/deployment/MilvusProcessor.java +++ b/extensions/milvus/deployment/src/main/java/org/apache/camel/quarkus/component/milvus/deployment/MilvusProcessor.java @@ -16,80 +16,21 @@ */ package org.apache.camel.quarkus.component.milvus.deployment; -import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem; -import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.IndexDependencyBuildItem; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.commons.ClassRemapper; -import org.objectweb.asm.commons.Remapper; class MilvusProcessor { - - /** - * Intercepts all Milvus SDK classes during the Quarkus build process to perform - * bytecode transformation. This ensures the SDK points to the correct - * gRPC/Netty implementations, avoiding 'Class Not Found' - */ + private static final String FEATURE = "camel-milvus"; @BuildStep - void relocateAllShadedCalls( - CombinedIndexBuildItem index, - BuildProducer<BytecodeTransformerBuildItem> transformers) { - - index.getIndex().getKnownClasses().stream() - .filter(ci -> { - String name = ci.name().toString(); - return name.startsWith("io.milvus") && !name.startsWith("io.milvus.shaded"); - }) - .forEach(ci -> { - transformers.produce(new BytecodeTransformerBuildItem( - ci.name().toString(), - (name, cv) -> new ShadedRelocationVisitor(cv))); - }); + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); } - //This build step ensures that the Milvus Java SDK is indexed by Jandex. - @BuildStep - IndexDependencyBuildItem indexDependencie() { - return new IndexDependencyBuildItem("io.milvus", "milvus-sdk-java"); - } - - /** - * Custom ClassRemapper used during the Quarkus build step to intercept and - * redirect shaded Netty/gRPC calls within the Milvus SDK. - */ - - private static class ShadedRelocationVisitor extends ClassRemapper { - public ShadedRelocationVisitor(ClassVisitor cv) { - super(Opcodes.ASM9, cv, new Remapper(Opcodes.ASM9) { - @Override - public String map(String internalName) { - if (internalName == null) - return null; - - if (internalName.startsWith("io/milvus/shaded/io/grpc/netty/shaded/io/grpc")) { - return internalName.replace("io/milvus/shaded/io/grpc/netty/shaded/io/grpc", "io/grpc"); - } - if (internalName.startsWith("io/milvus/shaded/io/grpc/netty/shaded/io/netty")) { - return internalName.replace("io/milvus/shaded/io/grpc/netty/shaded/io/netty", "io/netty"); - } - if (internalName.startsWith("io/milvus/shaded/io/grpc")) { - return internalName.replace("io/milvus/shaded/io/grpc", "io/grpc"); - } - if (internalName.startsWith("io/grpc/netty/shaded/io/grpc")) { - return internalName.replace("io/grpc/netty/shaded/io/grpc", "io/grpc"); - } - if (internalName.startsWith("io/grpc/netty/shaded/io/netty")) { - return internalName.replace("io/grpc/netty/shaded/io/netty", "io/netty"); - } - return super.map(internalName); - } - }); - } + IndexDependencyBuildItem indexDependencies() { + // Enables quarkus-grpc-common to register the generated protobuf message classes for reflection + return new IndexDependencyBuildItem("org.apache.camel.quarkus", "camel-quarkus-milvus-client"); } - } diff --git a/extensions/milvus/pom.xml b/extensions/milvus/pom.xml index 36ee74b38c..abdccadba9 100644 --- a/extensions/milvus/pom.xml +++ b/extensions/milvus/pom.xml @@ -31,6 +31,7 @@ <packaging>pom</packaging> <modules> + <module>client</module> <module>deployment</module> <module>runtime</module> </modules> diff --git a/extensions/milvus/runtime/pom.xml b/extensions/milvus/runtime/pom.xml index 4037b5d076..b0dad46272 100644 --- a/extensions/milvus/runtime/pom.xml +++ b/extensions/milvus/runtime/pom.xml @@ -36,6 +36,10 @@ </properties> <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-milvus-client</artifactId> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-core</artifactId> @@ -47,6 +51,13 @@ <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-milvus</artifactId> + <exclusions> + <!-- replaced by camel-quarkus-milvus-client --> + <exclusion> + <groupId>io.milvus</groupId> + <artifactId>milvus-sdk-java</artifactId> + </exclusion> + </exclusions> </dependency> </dependencies> diff --git a/pom.xml b/pom.xml index 5a094122b2..0ac438705b 100644 --- a/pom.xml +++ b/pom.xml @@ -149,6 +149,7 @@ <mapstruct.version>${mapstruct-version}</mapstruct.version> <mbassador.version>1.3.0</mbassador.version><!-- @sync com.hierynomus:smbj:${smbj-version} dep:net.engio:mbassador --> <micrometer-tracing.version>1.7.1</micrometer-tracing.version><!-- Not in quarkus-bom yet, align with micrometer version in io.quarkus:quarkus-bom:${quarkus.version} - tracing 1.6.x matches core 1.16.x https://repo1.maven.org/maven2/io/micrometer/micrometer-tracing-bom/ --> + <milvus-sdk-java.version>${milvus-client-version}</milvus-sdk-java.version> <mina.version>${mina-version}</mina.version> <minio.version>9.0.3</minio.version><!-- @sync io.quarkiverse.minio:quarkus-minio-parent:${quarkiverse-minio.version} prop:minio.version --> <msal4j.version>1.23.1</msal4j.version><!-- @sync com.azure:azure-identity:${azure-identity.version} dep:com.microsoft.azure:msal4j --> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 79be665c03..d938a42f81 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -5767,6 +5767,11 @@ <artifactId>camel-quarkus-milvus</artifactId> <version>${camel-quarkus.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-milvus-client</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-milvus-deployment</artifactId> @@ -7881,6 +7886,33 @@ <artifactId>micrometer-tracing-bridge-otel</artifactId> <version>${micrometer-tracing.version}</version> </dependency> + <dependency> + <groupId>io.milvus</groupId> + <artifactId>milvus-sdk-java</artifactId> + <version>${milvus-sdk-java.version}</version> + <exclusions> + <exclusion> + <groupId>com.google.android</groupId> + <artifactId>annotations</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </exclusion> + <exclusion> + <groupId>org.checkerframework</groupId> + <artifactId>checker-qual</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib-common</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml index dca277c23c..e3df39cfaa 100644 --- a/poms/bom/src/main/generated/flattened-full-pom.xml +++ b/poms/bom/src/main/generated/flattened-full-pom.xml @@ -5652,6 +5652,11 @@ <artifactId>camel-quarkus-milvus</artifactId> <version>3.40.1-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-milvus-client</artifactId> + <version>3.40.1-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-milvus-deployment</artifactId> @@ -7763,6 +7768,33 @@ <artifactId>micrometer-tracing-bridge-otel</artifactId> <version>1.7.1</version> </dependency> + <dependency> + <groupId>io.milvus</groupId> + <artifactId>milvus-sdk-java</artifactId> + <version>2.6.22</version> + <exclusions> + <exclusion> + <groupId>com.google.android</groupId> + <artifactId>annotations</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </exclusion> + <exclusion> + <groupId>org.checkerframework</groupId> + <artifactId>checker-qual</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib-common</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml index 0cb454b03e..e05f7311bd 100644 --- a/poms/bom/src/main/generated/flattened-reduced-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml @@ -909,6 +909,33 @@ <artifactId>micrometer-tracing-bridge-otel</artifactId> <version>1.7.1</version> </dependency> + <dependency> + <groupId>io.milvus</groupId> + <artifactId>milvus-sdk-java</artifactId> + <version>2.6.22</version> + <exclusions> + <exclusion> + <groupId>com.google.android</groupId> + <artifactId>annotations</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </exclusion> + <exclusion> + <groupId>org.checkerframework</groupId> + <artifactId>checker-qual</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib-common</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> @@ -6995,6 +7022,11 @@ <artifactId>camel-quarkus-milvus</artifactId> <version>3.40.1-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-milvus-client</artifactId> + <version>3.40.1-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-milvus-deployment</artifactId> diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml index 64a90eff10..b263d6534a 100644 --- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml +++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml @@ -909,6 +909,33 @@ <artifactId>micrometer-tracing-bridge-otel</artifactId> <version>1.7.1</version> </dependency> + <dependency> + <groupId>io.milvus</groupId> + <artifactId>milvus-sdk-java</artifactId> + <version>2.6.22</version> + <exclusions> + <exclusion> + <groupId>com.google.android</groupId> + <artifactId>annotations</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </exclusion> + <exclusion> + <groupId>org.checkerframework</groupId> + <artifactId>checker-qual</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib-common</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> @@ -6995,6 +7022,11 @@ <artifactId>camel-quarkus-milvus</artifactId> <version>3.40.1-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-milvus-client</artifactId> + <version>3.40.1-SNAPSHOT</version> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-milvus-deployment</artifactId> diff --git a/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/UpdateExtensionDocPageMojo.java b/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/UpdateExtensionDocPageMojo.java index 07cc3609ca..4629a04fc6 100644 --- a/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/UpdateExtensionDocPageMojo.java +++ b/tooling/maven-plugin/src/main/java/org/apache/camel/quarkus/maven/UpdateExtensionDocPageMojo.java @@ -389,7 +389,9 @@ public class UpdateExtensionDocPageMojo extends AbstractDocGeneratorMojo { } for (Dependency dependency : dependencies) { if ("org.apache.camel.quarkus".equals(dependency.getGroupId()) - && !dependency.getArtifactId().endsWith("-component")) { + && !dependency.getArtifactId().endsWith("-component") + // An extension's own client module (e.g. camel-quarkus-kudu-client) has no deployment module + && !dependency.getArtifactId().equals(artifactId + "-client")) { final String depArtifactId = dependency.getArtifactId(); if (cache.computeIfAbsent( depArtifactId,
