You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2023/02/08 14:04:37 UTC

[camel-quarkus] branch main updated: Mail test fails in native mode #4519

This is an automated email from the ASF dual-hosted git repository.

ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new d612fa30f7 Mail test fails in native mode #4519
d612fa30f7 is described below

commit d612fa30f758413f8e45ea37681011fc5d0ab5f5
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Tue Feb 7 17:01:03 2023 +0100

    Mail test fails in native mode #4519
---
 .../mail/deployment/SupportMailProcessor.java      | 32 ++++++++++++++++++----
 integration-tests/mail/pom.xml                     |  4 ---
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/extensions-support/mail/deployment/src/main/java/org/apache/camel/quarkus/support/mail/deployment/SupportMailProcessor.java b/extensions-support/mail/deployment/src/main/java/org/apache/camel/quarkus/support/mail/deployment/SupportMailProcessor.java
index 72bc76ea7d..746d1fab32 100644
--- a/extensions-support/mail/deployment/src/main/java/org/apache/camel/quarkus/support/mail/deployment/SupportMailProcessor.java
+++ b/extensions-support/mail/deployment/src/main/java/org/apache/camel/quarkus/support/mail/deployment/SupportMailProcessor.java
@@ -39,19 +39,26 @@ import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
 import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
 import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
 import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
 import jakarta.mail.Provider;
 import org.jboss.jandex.DotName;
 
 class SupportMailProcessor {
 
     @BuildStep
-    void process(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
-            BuildProducer<NativeImageResourceBuildItem> resource) {
+    void process(CombinedIndexBuildItem combinedIndex, BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
+            BuildProducer<NativeImageResourceBuildItem> resource,
+            BuildProducer<ServiceProviderBuildItem> services) {
         List<String> providers = resources("META-INF/services/jakarta.mail.Provider")
                 .flatMap(this::lines)
                 .filter(s -> !s.startsWith("#"))
                 .collect(Collectors.toList());
 
+        List<String> streamProviders = resources("META-INF/services/jakarta.mail.util.StreamProvider")
+                .flatMap(this::lines)
+                .filter(s -> !s.startsWith("#"))
+                .collect(Collectors.toList());
+
         List<String> imp1 = providers.stream()
                 .map(this::loadClass)
                 .map(this::instantiate)
@@ -79,23 +86,38 @@ class SupportMailProcessor {
                 .collect(Collectors.toList());
 
         reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, false,
-                Stream.concat(providers.stream(), Stream.concat(imp1.stream(), Stream.concat(imp2.stream(), imp3.stream())))
+                Stream.concat(providers.stream(),
+                        Stream.concat(streamProviders.stream(),
+                                Stream.concat(imp1.stream(), Stream.concat(imp2.stream(), imp3.stream()))))
                         .distinct()
                         .toArray(String[]::new)));
 
         resource.produce(new NativeImageResourceBuildItem(
                 "META-INF/services/jakarta.mail.Provider",
+                "META-INF/services/jakarta.mail.util.StreamProvider",
                 "META-INF/javamail.charset.map",
                 "META-INF/javamail.default.address.map",
                 "META-INF/javamail.default.providers",
                 "META-INF/javamail.address.map",
                 "META-INF/javamail.providers",
                 "META-INF/mailcap"));
+
+        //jakarta activation spi
+        combinedIndex.getIndex().getKnownClasses()
+                .stream()
+                .map(classInfo -> classInfo.name().toString())
+                .filter(name -> name.startsWith("jakarta.activation.spi."))
+                .forEach(name -> combinedIndex.getIndex().getKnownDirectImplementors(DotName.createSimple(name))
+                        .stream()
+                        .forEach(service -> services.produce(
+                                new ServiceProviderBuildItem(name, service.name().toString()))));
     }
 
     @BuildStep
-    IndexDependencyBuildItem indexDependencies() {
-        return new IndexDependencyBuildItem("org.eclipse.angus", "angus-mail");
+    void registerDependencyForIndex(BuildProducer<IndexDependencyBuildItem> items) {
+        items.produce(new IndexDependencyBuildItem("jakarta.activation", "jakarta.activation-api"));
+        items.produce(new IndexDependencyBuildItem("org.eclipse.angus", "angus-activation"));
+        items.produce(new IndexDependencyBuildItem("org.eclipse.angus", "angus-mail"));
     }
 
     @BuildStep
diff --git a/integration-tests/mail/pom.xml b/integration-tests/mail/pom.xml
index 772446fa51..4eb7f72deb 100644
--- a/integration-tests/mail/pom.xml
+++ b/integration-tests/mail/pom.xml
@@ -30,10 +30,6 @@
     <name>Camel Quarkus :: Integration Tests :: Mail</name>
     <description>Integration tests for Camel Mail extension</description>
 
-    <properties>
-        <ci.native.tests.skip>true</ci.native.tests.skip><!-- https://github.com/apache/camel-quarkus/issues/4493 -->
-    </properties>
-
     <dependencies>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>