Skip to content

Commit 68f3183

Browse files
Fix docling native support
1 parent 61cac69 commit 68f3183

File tree

6 files changed

+90
-4
lines changed

6 files changed

+90
-4
lines changed

extensions/docling/deployment/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
<groupId>org.apache.camel.quarkus</groupId>
4343
<artifactId>camel-quarkus-support-httpclient5-deployment</artifactId>
4444
</dependency>
45+
<dependency>
46+
<groupId>io.quarkus</groupId>
47+
<artifactId>quarkus-jackson-deployment</artifactId>
48+
</dependency>
4549
</dependencies>
4650

4751
<build>

extensions/docling/deployment/src/main/java/org/apache/camel/quarkus/component/docling/deployment/DoclingProcessor.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@
1616
*/
1717
package org.apache.camel.quarkus.component.docling.deployment;
1818

19+
import java.util.Set;
20+
import java.util.stream.Collectors;
21+
22+
import io.quarkus.deployment.annotations.BuildProducer;
1923
import io.quarkus.deployment.annotations.BuildStep;
24+
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
2025
import io.quarkus.deployment.builditem.FeatureBuildItem;
26+
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
27+
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
28+
import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
29+
import org.jboss.jandex.ClassInfo;
30+
import org.jboss.jandex.DotName;
2131

2232
class DoclingProcessor {
2333

@@ -27,4 +37,41 @@ class DoclingProcessor {
2737
FeatureBuildItem feature() {
2838
return new FeatureBuildItem(FEATURE);
2939
}
40+
41+
@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
42+
void indexDependencies(BuildProducer<IndexDependencyBuildItem> indexedDependency) {
43+
indexedDependency.produce(new IndexDependencyBuildItem("ai.docling", "docling-core"));
44+
indexedDependency.produce(new IndexDependencyBuildItem("ai.docling", "docling-serve-api"));
45+
}
46+
47+
@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
48+
void registerForReflection(
49+
CombinedIndexBuildItem combinedIndex,
50+
BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
51+
52+
// Register Docling model and associated builder classes for reflection for Jackson serialization / deserialization
53+
Set<String> doclingValidationBuilderClasses = combinedIndex.getIndex()
54+
.getClassesInPackage("ai.docling.serve.api.validation")
55+
.stream()
56+
.map(ClassInfo::name)
57+
.map(DotName::toString)
58+
.filter(className -> className.endsWith("$Builder"))
59+
.collect(Collectors.toUnmodifiableSet());
60+
61+
reflectiveClass.produce(ReflectiveClassBuildItem.builder(doclingValidationBuilderClasses.toArray(new String[0]))
62+
.methods(true)
63+
.build());
64+
65+
Set<String> doclingCoreBuilderClasses = combinedIndex.getIndex()
66+
.getClassesInPackage("ai.docling.core")
67+
.stream()
68+
.map(ClassInfo::name)
69+
.map(DotName::toString)
70+
.filter(className -> className.endsWith("$Builder"))
71+
.collect(Collectors.toUnmodifiableSet());
72+
73+
reflectiveClass.produce(ReflectiveClassBuildItem.builder(doclingCoreBuilderClasses.toArray(new String[0]))
74+
.methods(true)
75+
.build());
76+
}
3077
}

extensions/docling/runtime/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@
4848
<groupId>org.apache.camel.quarkus</groupId>
4949
<artifactId>camel-quarkus-support-httpclient5</artifactId>
5050
</dependency>
51+
<dependency>
52+
<groupId>io.quarkus</groupId>
53+
<artifactId>quarkus-jackson</artifactId>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.graalvm.sdk</groupId>
57+
<artifactId>graal-sdk</artifactId>
58+
<scope>provided</scope>
59+
</dependency>
5160
</dependencies>
5261

5362
<build>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package ai.docling.serve.client;
18+
19+
import com.oracle.svm.core.annotate.Substitute;
20+
import com.oracle.svm.core.annotate.TargetClass;
21+
22+
// Remove references to Jackson 3.x
23+
@TargetClass(DoclingServeClientBuilderFactory.class)
24+
final class DoclingServeClientBuilderFactorySubstitutions {
25+
@Substitute
26+
public static <C extends DoclingServeClient, B extends DoclingServeClient.DoclingServeClientBuilder<C, B>> B newBuilder(
27+
ClassLoader classLoader) {
28+
return (B) DoclingServeJackson2Client.builder();
29+
}
30+
}

integration-tests/docling/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
</dependencies>
7575

7676
<profiles>
77-
<!-- https://github.com/apache/camel-quarkus/issues/8085
7877
<profile>
7978
<id>native</id>
8079
<activation>
@@ -102,7 +101,6 @@
102101
</plugins>
103102
</build>
104103
</profile>
105-
-->
106104
<profile>
107105
<id>virtualDependencies</id>
108106
<activation>

integration-tests/docling/src/test/java/org/apache/camel/quarkus/component/docling/it/DoclingTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.apache.camel.quarkus.component.docling.it;
1818

1919
import io.quarkus.test.common.QuarkusTestResource;
20-
import io.quarkus.test.junit.DisabledOnIntegrationTest;
2120
import io.quarkus.test.junit.QuarkusTest;
2221
import io.restassured.RestAssured;
2322
import io.restassured.http.ContentType;
@@ -28,7 +27,6 @@
2827
import static org.hamcrest.Matchers.is;
2928
import static org.hamcrest.Matchers.not;
3029

31-
@DisabledOnIntegrationTest // https://github.com/apache/camel-quarkus/issues/8085
3230
@QuarkusTest
3331
@QuarkusTestResource(DoclingTestResource.class)
3432
class DoclingTest {

0 commit comments

Comments
 (0)