This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push: new 4a58281 Add Google Mail extension 4a58281 is described below commit 4a58281b4816c155f9f1c5ea8504324081172243 Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Wed Mar 18 13:59:07 2020 +0000 Add Google Mail extension Fixes #807 --- .github/workflows/pr-build.yaml | 1 + .../pages/list-of-camel-quarkus-extensions.adoc | 8 +- .../google-http-client}/deployment/pom.xml | 8 +- .../SupportGoogleHTTPClientProcessor.java | 56 ++++---- .../{ => google-http-client}/pom.xml | 28 +--- .../google-http-client/runtime}/pom.xml | 23 ++-- .../main/resources/META-INF/quarkus-extension.yaml | 27 ++++ .../mail/deployment/pom.xml | 12 +- .../mail/deployment/SupportMailProcessor.java | 24 +--- extensions-support/{ => mail}/pom.xml | 28 +--- .../mail/runtime}/pom.xml | 25 ++-- .../main/resources/META-INF/quarkus-extension.yaml | 27 ++++ extensions-support/pom.xml | 2 + .../{jira => google-mail}/deployment/pom.xml | 18 ++- .../mail/deployment/GoogleMailProcessor.java | 66 ++++++++++ .../google-mail}/pom.xml | 32 ++--- extensions/{mail => google-mail}/runtime/pom.xml | 40 +++--- .../main/resources/META-INF/quarkus-extension.yaml | 31 +++++ extensions/jira/deployment/pom.xml | 4 + .../component/jira/deployment/JiraProcessor.java | 6 - extensions/jira/runtime/pom.xml | 4 + extensions/mail/deployment/pom.xml | 4 + .../component/mail/deployment/MailProcessor.java | 143 --------------------- extensions/mail/runtime/pom.xml | 23 +--- extensions/pom.xml | 1 + extensions/readme.adoc | 8 +- integration-tests/google/README.adoc | 13 ++ integration-tests/google/pom.xml | 113 ++++++++++++++++ .../component/google/it/GoogleMailResource.java | 129 +++++++++++++++++++ .../src/main/resources/application.properties | 22 ++++ .../component/google/it/GoogleComponentsIT.java | 29 +++++ .../component/google/it/GoogleComponentsTest.java | 70 ++++++++++ integration-tests/pom.xml | 1 + pom.xml | 1 + poms/bom-deployment/pom.xml | 15 +++ poms/bom/pom.xml | 37 ++++++ 36 files changed, 736 insertions(+), 343 deletions(-) diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml index f422a60..12bf179 100644 --- a/.github/workflows/pr-build.yaml +++ b/.github/workflows/pr-build.yaml @@ -176,6 +176,7 @@ jobs: - category: SAAS test-modules: > box + google jira salesforce slack diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index e564565..f2ae067 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -18,7 +18,7 @@ In case you are missing some Camel feature in the list: == Camel Components // components: START -Number of Camel components: 76 in 66 JAR artifacts (0 deprecated) +Number of Camel components: 78 in 67 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -123,6 +123,12 @@ Number of Camel components: 76 in 66 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/ftps-component.html[FTPS] (camel-quarkus-ftp) + `ftps:host:port/directoryName` | 1.0.0-M1 | The \ftps (FTP secure SSL/TLS) component is used for uploading or downloading files from FTP servers. +| link:https://camel.apache.org/components/latest/google-mail-component.html[Google Mail] (camel-quarkus-google-mail) + +`google-mail:apiName/methodName` | 1.0.0-M6 | The google-mail component provides access to Google Mail. + +| link:https://camel.apache.org/components/latest/google-mail-stream-component.html[Google Mail Stream] (camel-quarkus-google-mail) + +`google-mail-stream:index` | 1.0.0-M6 | The google-mail component provides access to Google Mail. + | xref:extensions/graphql.adoc[GraphQL] (camel-quarkus-graphql) + `graphql:httpUri` | 1.0.0-M5 | A Camel GraphQL Component diff --git a/extensions/mail/deployment/pom.xml b/extensions-support/google-http-client/deployment/pom.xml similarity index 89% copy from extensions/mail/deployment/pom.xml copy to extensions-support/google-http-client/deployment/pom.xml index 084cc84..f3e6a9b 100644 --- a/extensions/mail/deployment/pom.xml +++ b/extensions-support/google-http-client/deployment/pom.xml @@ -21,13 +21,13 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mail-parent</artifactId> + <artifactId>camel-quarkus-support-google-http-client-parent</artifactId> <version>1.1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-mail-deployment</artifactId> - <name>Camel Quarkus :: Mail :: Deployment</name> + <artifactId>camel-quarkus-support-google-http-client-deployment</artifactId> + <name>Camel Quarkus :: Support :: Google HTTP Client :: Deployment</name> <dependencyManagement> <dependencies> @@ -48,7 +48,7 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mail</artifactId> + <artifactId>camel-quarkus-support-google-http-client</artifactId> </dependency> </dependencies> diff --git a/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java b/extensions-support/google-http-client/deployment/src/main/java/org/apache/camel/quarkus/support/google/http/client/deployment/SupportGoogleHTTPClientProcessor.java similarity index 52% copy from extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java copy to extensions-support/google-http-client/deployment/src/main/java/org/apache/camel/quarkus/support/google/http/client/deployment/SupportGoogleHTTPClientProcessor.java index b791417..513cb49 100644 --- a/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java +++ b/extensions-support/google-http-client/deployment/src/main/java/org/apache/camel/quarkus/support/google/http/client/deployment/SupportGoogleHTTPClientProcessor.java @@ -14,60 +14,54 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.jira.deployment; - -import java.util.ArrayList; -import java.util.List; +package org.apache.camel.quarkus.support.google.http.client.deployment; +import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.AdditionalApplicationArchiveMarkerBuildItem; +import io.quarkus.deployment.builditem.CombinedIndexBuildItem; import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; -import org.apache.camel.component.jira.JiraConfiguration; -import org.apache.camel.quarkus.core.deployment.UnbannedReflectiveBuildItem; -import org.joda.time.DateTimeZone; +import org.jboss.jandex.DotName; +import org.jboss.jandex.IndexView; -class JiraProcessor { +class SupportGoogleHTTPClientProcessor { - private static final String FEATURE = "camel-jira"; + private static final String FEATURE = "camel-support-google-http-client"; @BuildStep - ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { - return new ExtensionSslNativeSupportBuildItem(FEATURE); + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); } @BuildStep - FeatureBuildItem feature() { - return new FeatureBuildItem(FEATURE); + AdditionalApplicationArchiveMarkerBuildItem applicationArchiveMarkers( + BuildProducer<AdditionalApplicationArchiveMarkerBuildItem> applicationArchiveMarker) { + return new AdditionalApplicationArchiveMarkerBuildItem("com/google/api/client"); } @BuildStep - RuntimeInitializedClassBuildItem configureRuntimeInitializedClasses() { + RuntimeInitializedClassBuildItem runtimeInitializedClasses() { return new RuntimeInitializedClassBuildItem("com.google.api.client.auth.oauth.OAuthParameters"); } @BuildStep - ReflectiveClassBuildItem registerForReflection() { - return new ReflectiveClassBuildItem(true, true, JiraConfiguration.class); - } + void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, CombinedIndexBuildItem combinedIndex) { + IndexView index = combinedIndex.getIndex(); + + // Google client API class reflection for JSON serialization / deserialization + String[] googleApis = index.getAllKnownSubclasses(DotName.createSimple("com.google.api.client.util.GenericData")) + .stream() + .map(classInfo -> classInfo.name().toString()) + .toArray(String[]::new); - @BuildStep() - UnbannedReflectiveBuildItem unbannedReflectiveItems() { - return new UnbannedReflectiveBuildItem(JiraConfiguration.class.getName()); + reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, googleApis)); } @BuildStep - NativeImageResourceBuildItem nativeImageResources() { - // Add Joda timezone resources into the native image as it is required by com.atlassian.jira.rest.client.internal.json.JsonParseUtil - List<String> timezones = new ArrayList<>(); - for (String timezone : DateTimeZone.getAvailableIDs()) { - String[] zoneParts = timezone.split("/"); - if (zoneParts.length == 2) { - timezones.add(String.format("org/joda/time/tz/data/%s/%s", zoneParts[0], zoneParts[1])); - } - } - return new NativeImageResourceBuildItem(timezones); + ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { + return new ExtensionSslNativeSupportBuildItem(FEATURE); } } diff --git a/extensions-support/pom.xml b/extensions-support/google-http-client/pom.xml similarity index 62% copy from extensions-support/pom.xml copy to extensions-support/google-http-client/pom.xml index 1f74b06..1837e8a 100644 --- a/extensions-support/pom.xml +++ b/extensions-support/google-http-client/pom.xml @@ -18,34 +18,20 @@ --> <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-parent</artifactId> + <artifactId>camel-quarkus-build-parent</artifactId> <version>1.1.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>camel-quarkus-extensions-support</artifactId> - <name>Camel Quarkus :: Extensions :: Support</name> + <artifactId>camel-quarkus-support-google-http-client-parent</artifactId> + <name>Camel Quarkus :: Support :: Google HTTP Client</name> <packaging>pom</packaging> <modules> - <!-- extensions a..z; do not remove this comment, it is important when sorting via mvn process-resources -Pformat --> - <module>ahc</module> - <module>aws</module> - <module>common</module> - <module>commons-logging</module> - <module>consul-client</module> - <module>httpclient</module> - <module>jackson-dataformat-xml</module> - <module>jetty</module> - <module>policy</module> - <module>retrofit</module> - <module>spring</module> - <module>xstream</module> - <module>xml</module> - <module>xalan</module> + <module>deployment</module> + <module>runtime</module> </modules> </project> diff --git a/extensions/mail/deployment/pom.xml b/extensions-support/google-http-client/runtime/pom.xml similarity index 78% copy from extensions/mail/deployment/pom.xml copy to extensions-support/google-http-client/runtime/pom.xml index 084cc84..344a40f 100644 --- a/extensions/mail/deployment/pom.xml +++ b/extensions-support/google-http-client/runtime/pom.xml @@ -21,19 +21,23 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mail-parent</artifactId> + <artifactId>camel-quarkus-support-google-http-client-parent</artifactId> <version>1.1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-mail-deployment</artifactId> - <name>Camel Quarkus :: Mail :: Deployment</name> + <artifactId>camel-quarkus-support-google-http-client</artifactId> + <name>Camel Quarkus :: Support :: Google HTTP Client :: Runtime</name> + + <properties> + <firstVersion>1.0.0-M6</firstVersion> + </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-bom-deployment</artifactId> + <artifactId>camel-quarkus-bom</artifactId> <version>${project.version}</version> <type>pom</type> <scope>import</scope> @@ -44,17 +48,21 @@ <dependencies> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-core-deployment</artifactId> + <artifactId>camel-quarkus-core</artifactId> </dependency> <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mail</artifactId> + <groupId>com.google.http-client</groupId> + <artifactId>google-http-client</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> + </plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> @@ -69,5 +77,4 @@ </plugin> </plugins> </build> - </project> diff --git a/extensions-support/google-http-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions-support/google-http-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..c3eb0c3 --- /dev/null +++ b/extensions-support/google-http-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,27 @@ +# +# 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. +# + +--- +name: "Camel Quarkus Support Google HTTP Client" +description: "Camel Quarkus Support Google HTTP Client" +metadata: + unlisted: true + keywords: + - "camel" + guide: "https://quarkus.io/guides/camel" + categories: + - "integration" diff --git a/extensions/mail/deployment/pom.xml b/extensions-support/mail/deployment/pom.xml similarity index 87% copy from extensions/mail/deployment/pom.xml copy to extensions-support/mail/deployment/pom.xml index 084cc84..22ea9ff 100644 --- a/extensions/mail/deployment/pom.xml +++ b/extensions-support/mail/deployment/pom.xml @@ -21,13 +21,13 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mail-parent</artifactId> + <artifactId>camel-quarkus-support-mail-parent</artifactId> <version>1.1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-mail-deployment</artifactId> - <name>Camel Quarkus :: Mail :: Deployment</name> + <artifactId>camel-quarkus-support-mail-deployment</artifactId> + <name>Camel Quarkus :: Support :: Mail :: Deployment</name> <dependencyManagement> <dependencies> @@ -43,12 +43,12 @@ <dependencies> <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-core-deployment</artifactId> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-core-deployment</artifactId> </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mail</artifactId> + <artifactId>camel-quarkus-support-mail</artifactId> </dependency> </dependencies> diff --git a/extensions/mail/deployment/src/main/java/org/apache/camel/quarkus/component/mail/deployment/MailProcessor.java b/extensions-support/mail/deployment/src/main/java/org/apache/camel/quarkus/support/mail/deployment/SupportMailProcessor.java similarity index 89% copy from extensions/mail/deployment/src/main/java/org/apache/camel/quarkus/component/mail/deployment/MailProcessor.java copy to extensions-support/mail/deployment/src/main/java/org/apache/camel/quarkus/support/mail/deployment/SupportMailProcessor.java index b708764..a30a023 100644 --- a/extensions/mail/deployment/src/main/java/org/apache/camel/quarkus/component/mail/deployment/MailProcessor.java +++ b/extensions-support/mail/deployment/src/main/java/org/apache/camel/quarkus/support/mail/deployment/SupportMailProcessor.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.mail.deployment; +package org.apache.camel.quarkus.support.mail.deployment; import java.io.BufferedReader; import java.io.IOException; @@ -22,8 +22,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.Enumeration; import java.util.Iterator; import java.util.List; @@ -38,15 +36,13 @@ import javax.mail.Provider; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; -import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; -class MailProcessor { +class SupportMailProcessor { - private static final String FEATURE = "camel-mail"; + private static final String FEATURE = "camel-support-mail"; @Inject BuildProducer<ReflectiveClassBuildItem> reflectiveClass; @@ -54,12 +50,6 @@ class MailProcessor { @Inject BuildProducer<NativeImageResourceBuildItem> resource; - @Inject - BuildProducer<ServiceProviderBuildItem> services; - - @Inject - ApplicationArchivesBuildItem applicationArchivesBuildItem; - @BuildStep FeatureBuildItem feature() { return new FeatureBuildItem(FEATURE); @@ -137,14 +127,6 @@ class MailProcessor { } } - private Stream<String> lines(Path path) { - try { - return Files.lines(path); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - private Stream<String> lines(URL url) { try (InputStream is = url.openStream()) { try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) { diff --git a/extensions-support/pom.xml b/extensions-support/mail/pom.xml similarity index 62% copy from extensions-support/pom.xml copy to extensions-support/mail/pom.xml index 1f74b06..8d7d063 100644 --- a/extensions-support/pom.xml +++ b/extensions-support/mail/pom.xml @@ -18,34 +18,20 @@ --> <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-parent</artifactId> + <artifactId>camel-quarkus-build-parent</artifactId> <version>1.1.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>camel-quarkus-extensions-support</artifactId> - <name>Camel Quarkus :: Extensions :: Support</name> + <artifactId>camel-quarkus-support-mail-parent</artifactId> + <name>Camel Quarkus :: Support :: Mail</name> <packaging>pom</packaging> <modules> - <!-- extensions a..z; do not remove this comment, it is important when sorting via mvn process-resources -Pformat --> - <module>ahc</module> - <module>aws</module> - <module>common</module> - <module>commons-logging</module> - <module>consul-client</module> - <module>httpclient</module> - <module>jackson-dataformat-xml</module> - <module>jetty</module> - <module>policy</module> - <module>retrofit</module> - <module>spring</module> - <module>xstream</module> - <module>xml</module> - <module>xalan</module> + <module>deployment</module> + <module>runtime</module> </modules> </project> diff --git a/extensions/mail/deployment/pom.xml b/extensions-support/mail/runtime/pom.xml similarity index 78% copy from extensions/mail/deployment/pom.xml copy to extensions-support/mail/runtime/pom.xml index 084cc84..300749c 100644 --- a/extensions/mail/deployment/pom.xml +++ b/extensions-support/mail/runtime/pom.xml @@ -21,19 +21,23 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mail-parent</artifactId> + <artifactId>camel-quarkus-support-mail-parent</artifactId> <version>1.1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-mail-deployment</artifactId> - <name>Camel Quarkus :: Mail :: Deployment</name> + <artifactId>camel-quarkus-support-mail</artifactId> + <name>Camel Quarkus :: Support :: Mail :: Runtime</name> + + <properties> + <firstVersion>1.0.0-M6</firstVersion> + </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-bom-deployment</artifactId> + <artifactId>camel-quarkus-bom</artifactId> <version>${project.version}</version> <type>pom</type> <scope>import</scope> @@ -43,18 +47,22 @@ <dependencies> <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-core-deployment</artifactId> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-core</artifactId> </dependency> <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-mail</artifactId> + <groupId>com.sun.mail</groupId> + <artifactId>jakarta.mail</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> + </plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> @@ -69,5 +77,4 @@ </plugin> </plugins> </build> - </project> diff --git a/extensions-support/mail/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions-support/mail/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..3701dd0 --- /dev/null +++ b/extensions-support/mail/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,27 @@ +# +# 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. +# + +--- +name: "Camel Quarkus Support Mail" +description: "Camel Quarkus Support Mail" +metadata: + unlisted: true + keywords: + - "camel" + guide: "https://quarkus.io/guides/camel" + categories: + - "integration" diff --git a/extensions-support/pom.xml b/extensions-support/pom.xml index 1f74b06..e6fc68f 100644 --- a/extensions-support/pom.xml +++ b/extensions-support/pom.xml @@ -38,9 +38,11 @@ <module>common</module> <module>commons-logging</module> <module>consul-client</module> + <module>google-http-client</module> <module>httpclient</module> <module>jackson-dataformat-xml</module> <module>jetty</module> + <module>mail</module> <module>policy</module> <module>retrofit</module> <module>spring</module> diff --git a/extensions/jira/deployment/pom.xml b/extensions/google-mail/deployment/pom.xml similarity index 77% copy from extensions/jira/deployment/pom.xml copy to extensions/google-mail/deployment/pom.xml index 85190b0..8a96e21 100644 --- a/extensions/jira/deployment/pom.xml +++ b/extensions/google-mail/deployment/pom.xml @@ -17,17 +17,19 @@ 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"> +<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-jira-parent</artifactId> + <artifactId>camel-quarkus-google-mail-parent</artifactId> <version>1.1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-jira-deployment</artifactId> - <name>Camel Quarkus :: Jira :: Deployment</name> + <artifactId>camel-quarkus-google-mail-deployment</artifactId> + <name>Camel Quarkus :: Google Mail :: Deployment</name> <dependencyManagement> <dependencies> @@ -48,11 +50,15 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-jira</artifactId> + <artifactId>camel-quarkus-support-google-http-client-deployment</artifactId> </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-support-commons-logging-deployment</artifactId> + <artifactId>camel-quarkus-support-mail-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-google-mail</artifactId> </dependency> </dependencies> diff --git a/extensions/google-mail/deployment/src/main/java/org/apache/camel/quarkus/component/google/mail/deployment/GoogleMailProcessor.java b/extensions/google-mail/deployment/src/main/java/org/apache/camel/quarkus/component/google/mail/deployment/GoogleMailProcessor.java new file mode 100644 index 0000000..5046dcf --- /dev/null +++ b/extensions/google-mail/deployment/src/main/java/org/apache/camel/quarkus/component/google/mail/deployment/GoogleMailProcessor.java @@ -0,0 +1,66 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.google.mail.deployment; + +import java.util.Collection; + +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.AdditionalApplicationArchiveMarkerBuildItem; +import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import org.apache.camel.quarkus.core.deployment.UnbannedReflectiveBuildItem; +import org.jboss.jandex.AnnotationInstance; +import org.jboss.jandex.AnnotationTarget; +import org.jboss.jandex.DotName; +import org.jboss.jandex.IndexView; + +class GoogleMailProcessor { + + private static final String FEATURE = "camel-google-mail"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + void applicationArchiveMarkers(BuildProducer<AdditionalApplicationArchiveMarkerBuildItem> applicationArchiveMarker) { + applicationArchiveMarker.produce(new AdditionalApplicationArchiveMarkerBuildItem("com/google/api/services/gmail")); + } + + @BuildStep + void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, + BuildProducer<UnbannedReflectiveBuildItem> unbannedClass, CombinedIndexBuildItem combinedIndex) { + IndexView index = combinedIndex.getIndex(); + + // Google mail component configuration class reflection + Collection<AnnotationInstance> uriParams = index + .getAnnotations(DotName.createSimple("org.apache.camel.spi.UriParams")); + + String[] googleMailConfigClasses = uriParams.stream() + .map(annotation -> annotation.target()) + .filter(annotationTarget -> annotationTarget.kind().equals(AnnotationTarget.Kind.CLASS)) + .map(annotationTarget -> annotationTarget.asClass().name().toString()) + .filter(className -> className.startsWith("org.apache.camel.component.google.mail")) + .toArray(String[]::new); + + reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, googleMailConfigClasses)); + unbannedClass.produce(new UnbannedReflectiveBuildItem(googleMailConfigClasses)); + } +} diff --git a/extensions-support/pom.xml b/extensions/google-mail/pom.xml similarity index 52% copy from extensions-support/pom.xml copy to extensions/google-mail/pom.xml index 1f74b06..49afb66 100644 --- a/extensions-support/pom.xml +++ b/extensions/google-mail/pom.xml @@ -17,35 +17,23 @@ 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"> - +<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-parent</artifactId> + <artifactId>camel-quarkus-build-parent</artifactId> <version>1.1.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>camel-quarkus-extensions-support</artifactId> - <name>Camel Quarkus :: Extensions :: Support</name> + <artifactId>camel-quarkus-google-mail-parent</artifactId> + <name>Camel Quarkus :: Google Mail</name> <packaging>pom</packaging> <modules> - <!-- extensions a..z; do not remove this comment, it is important when sorting via mvn process-resources -Pformat --> - <module>ahc</module> - <module>aws</module> - <module>common</module> - <module>commons-logging</module> - <module>consul-client</module> - <module>httpclient</module> - <module>jackson-dataformat-xml</module> - <module>jetty</module> - <module>policy</module> - <module>retrofit</module> - <module>spring</module> - <module>xstream</module> - <module>xml</module> - <module>xalan</module> + <module>deployment</module> + <module>runtime</module> </modules> </project> diff --git a/extensions/mail/runtime/pom.xml b/extensions/google-mail/runtime/pom.xml similarity index 69% copy from extensions/mail/runtime/pom.xml copy to extensions/google-mail/runtime/pom.xml index 7f9ab56..c390dae 100644 --- a/extensions/mail/runtime/pom.xml +++ b/extensions/google-mail/runtime/pom.xml @@ -17,21 +17,23 @@ 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"> +<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-mail-parent</artifactId> + <artifactId>camel-quarkus-google-mail-parent</artifactId> <version>1.1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-mail</artifactId> - <name>Camel Quarkus :: Mail :: Runtime</name> + <artifactId>camel-quarkus-google-mail</artifactId> + <name>Camel Quarkus :: Google Mail :: Runtime</name> + <description>The google-mail component provides access to Google Mail.</description> <properties> - <jakarta-mail-version>1.6.4</jakarta-mail-version> - <firstVersion>0.2.0</firstVersion> + <firstVersion>1.0.0-M6</firstVersion> </properties> <dependencyManagement> @@ -43,18 +45,6 @@ <type>pom</type> <scope>import</scope> </dependency> - <dependency> - <groupId>com.sun.mail</groupId> - <artifactId>jakarta.mail</artifactId> - <version>${jakarta-mail-version}</version> - <exclusions> - <!-- javax activation is part of the JDK now --> - <exclusion> - <groupId>com.sun.activation</groupId> - <artifactId>jakarta.activation</artifactId> - </exclusion> - </exclusions> - </dependency> </dependencies> </dependencyManagement> @@ -63,15 +53,17 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-core</artifactId> </dependency> - - <!-- camel --> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-mail</artifactId> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-google-http-client</artifactId> </dependency> <dependency> - <groupId>com.sun.mail</groupId> - <artifactId>jakarta.mail</artifactId> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mail</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-google-mail</artifactId> </dependency> </dependencies> diff --git a/extensions/google-mail/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/google-mail/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..e03e462 --- /dev/null +++ b/extensions/google-mail/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,31 @@ +# +# 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. +# + +--- +name: "Google Mail" +description: "The google-mail component provides access to Google Mail." +metadata: + keywords: + - "api" + - "camel" + - "cloud" + - "google" + - "mail" + guide: "https://quarkus.io/guides/camel" + categories: + - "integration" + status: "stable" diff --git a/extensions/jira/deployment/pom.xml b/extensions/jira/deployment/pom.xml index 85190b0..bbb7b21 100644 --- a/extensions/jira/deployment/pom.xml +++ b/extensions/jira/deployment/pom.xml @@ -48,6 +48,10 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-google-http-client-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jira</artifactId> </dependency> <dependency> diff --git a/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java b/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java index b791417..f1634f3 100644 --- a/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java +++ b/extensions/jira/deployment/src/main/java/org/apache/camel/quarkus/component/jira/deployment/JiraProcessor.java @@ -24,7 +24,6 @@ import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; -import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import org.apache.camel.component.jira.JiraConfiguration; import org.apache.camel.quarkus.core.deployment.UnbannedReflectiveBuildItem; import org.joda.time.DateTimeZone; @@ -44,11 +43,6 @@ class JiraProcessor { } @BuildStep - RuntimeInitializedClassBuildItem configureRuntimeInitializedClasses() { - return new RuntimeInitializedClassBuildItem("com.google.api.client.auth.oauth.OAuthParameters"); - } - - @BuildStep ReflectiveClassBuildItem registerForReflection() { return new ReflectiveClassBuildItem(true, true, JiraConfiguration.class); } diff --git a/extensions/jira/runtime/pom.xml b/extensions/jira/runtime/pom.xml index 347a5af..02b64d0 100644 --- a/extensions/jira/runtime/pom.xml +++ b/extensions/jira/runtime/pom.xml @@ -76,6 +76,10 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-google-http-client</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-commons-logging</artifactId> </dependency> <dependency> diff --git a/extensions/mail/deployment/pom.xml b/extensions/mail/deployment/pom.xml index 084cc84..51cc86d 100644 --- a/extensions/mail/deployment/pom.xml +++ b/extensions/mail/deployment/pom.xml @@ -48,6 +48,10 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mail-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mail</artifactId> </dependency> </dependencies> diff --git a/extensions/mail/deployment/src/main/java/org/apache/camel/quarkus/component/mail/deployment/MailProcessor.java b/extensions/mail/deployment/src/main/java/org/apache/camel/quarkus/component/mail/deployment/MailProcessor.java index b708764..071c2ec 100644 --- a/extensions/mail/deployment/src/main/java/org/apache/camel/quarkus/component/mail/deployment/MailProcessor.java +++ b/extensions/mail/deployment/src/main/java/org/apache/camel/quarkus/component/mail/deployment/MailProcessor.java @@ -16,158 +16,15 @@ */ package org.apache.camel.quarkus.component.mail.deployment; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.UncheckedIOException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; -import java.util.Spliterator; -import java.util.Spliterators; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -import javax.inject.Inject; -import javax.mail.Provider; - -import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; -import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; -import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; class MailProcessor { private static final String FEATURE = "camel-mail"; - @Inject - BuildProducer<ReflectiveClassBuildItem> reflectiveClass; - - @Inject - BuildProducer<NativeImageResourceBuildItem> resource; - - @Inject - BuildProducer<ServiceProviderBuildItem> services; - - @Inject - ApplicationArchivesBuildItem applicationArchivesBuildItem; - @BuildStep FeatureBuildItem feature() { return new FeatureBuildItem(FEATURE); } - - @BuildStep - void process() throws IOException { - List<String> providers = resources("META-INF/services/javax.mail.Provider") - .flatMap(this::lines) - .filter(s -> !s.startsWith("#")) - .collect(Collectors.toList()); - - List<String> imp1 = providers.stream() - .map(this::loadClass) - .map(this::instantiate) - .map(Provider.class::cast) - .map(Provider::getClassName) - .collect(Collectors.toList()); - - List<String> imp2 = Stream.of("META-INF/javamail.default.providers", "META-INF/javamail.providers") - .flatMap(this::resources) - .flatMap(this::lines) - .filter(s -> !s.startsWith("#")) - .flatMap(s -> Stream.of(s.split(";"))) - .map(String::trim) - .filter(s -> s.startsWith("class=")) - .map(s -> s.substring("class=".length())) - .collect(Collectors.toList()); - - List<String> imp3 = resources("META-INF/mailcap") - .flatMap(this::lines) - .filter(s -> !s.startsWith("#")) - .flatMap(s -> Stream.of(s.split(";"))) - .map(String::trim) - .filter(s -> s.startsWith("x-java-content-handler=")) - .map(s -> s.substring("x-java-content-handler=".length())) - .collect(Collectors.toList()); - - reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, false, - Stream.concat(providers.stream(), Stream.concat(imp1.stream(), Stream.concat(imp2.stream(), imp3.stream()))) - .distinct() - .toArray(String[]::new))); - - resource.produce(new NativeImageResourceBuildItem( - "META-INF/services/javax.mail.Provider", - "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")); - } - - private Stream<URL> resources(String path) { - try { - return enumerationAsStream(getClass().getClassLoader().getResources(path)); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private Class<?> loadClass(String name) { - try { - return getClass().getClassLoader().loadClass(name); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - private <T> T instantiate(Class<T> clazz) { - try { - return clazz.newInstance(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private Stream<String> lines(Path path) { - try { - return Files.lines(path); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private Stream<String> lines(URL url) { - try (InputStream is = url.openStream()) { - try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) { - return br.lines().collect(Collectors.toList()).stream(); - } - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - private <T> Stream<T> enumerationAsStream(Enumeration<T> e) { - return StreamSupport.stream( - Spliterators.spliteratorUnknownSize( - new Iterator<T>() { - public T next() { - return e.nextElement(); - } - - public boolean hasNext() { - return e.hasMoreElements(); - } - }, - Spliterator.ORDERED), - false); - } } diff --git a/extensions/mail/runtime/pom.xml b/extensions/mail/runtime/pom.xml index 7f9ab56..20e543a 100644 --- a/extensions/mail/runtime/pom.xml +++ b/extensions/mail/runtime/pom.xml @@ -30,7 +30,6 @@ <name>Camel Quarkus :: Mail :: Runtime</name> <properties> - <jakarta-mail-version>1.6.4</jakarta-mail-version> <firstVersion>0.2.0</firstVersion> </properties> @@ -43,18 +42,6 @@ <type>pom</type> <scope>import</scope> </dependency> - <dependency> - <groupId>com.sun.mail</groupId> - <artifactId>jakarta.mail</artifactId> - <version>${jakarta-mail-version}</version> - <exclusions> - <!-- javax activation is part of the JDK now --> - <exclusion> - <groupId>com.sun.activation</groupId> - <artifactId>jakarta.activation</artifactId> - </exclusion> - </exclusions> - </dependency> </dependencies> </dependencyManagement> @@ -63,15 +50,13 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-core</artifactId> </dependency> - - <!-- camel --> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-mail</artifactId> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mail</artifactId> </dependency> <dependency> - <groupId>com.sun.mail</groupId> - <artifactId>jakarta.mail</artifactId> + <groupId>org.apache.camel</groupId> + <artifactId>camel-mail</artifactId> </dependency> </dependencies> diff --git a/extensions/pom.xml b/extensions/pom.xml index a42483d..d63a617 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -67,6 +67,7 @@ <module>file</module> <module>file-watch</module> <module>ftp</module> + <module>google-mail</module> <module>graphql</module> <module>gson</module> <module>http</module> diff --git a/extensions/readme.adoc b/extensions/readme.adoc index a1b1b04..a01ca12 100644 --- a/extensions/readme.adoc +++ b/extensions/readme.adoc @@ -5,7 +5,7 @@ Apache Camel Quarkus supports the following Camel artifacts as Quarkus Extension == Camel Components // components: START -Number of Camel components: 76 in 66 JAR artifacts (0 deprecated) +Number of Camel components: 78 in 67 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -110,6 +110,12 @@ Number of Camel components: 76 in 66 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/ftps-component.html[FTPS] (camel-quarkus-ftp) + `ftps:host:port/directoryName` | 1.0.0-M1 | The \ftps (FTP secure SSL/TLS) component is used for uploading or downloading files from FTP servers. +| link:https://camel.apache.org/components/latest/google-mail-component.html[Google Mail] (camel-quarkus-google-mail) + +`google-mail:apiName/methodName` | 1.0.0-M6 | The google-mail component provides access to Google Mail. + +| link:https://camel.apache.org/components/latest/google-mail-stream-component.html[Google Mail Stream] (camel-quarkus-google-mail) + +`google-mail-stream:index` | 1.0.0-M6 | The google-mail component provides access to Google Mail. + | xref:extensions/graphql.adoc[GraphQL] (camel-quarkus-graphql) + `graphql:httpUri` | 1.0.0-M5 | A Camel GraphQL Component diff --git a/integration-tests/google/README.adoc b/integration-tests/google/README.adoc new file mode 100644 index 0000000..85285a7 --- /dev/null +++ b/integration-tests/google/README.adoc @@ -0,0 +1,13 @@ +== Camel Quarkus Google API Integration Tests + +To run the set of Camel Google API component integration tests, you need a valid Google account and https://developers.google.com/identity/protocols/oauth2[OAuth credentials]. + +Once obtained, set the following environment variables: + +[source,shell] +---- +export GOOGLE_API_APPLICATION_NAME=your-application-name +export GOOGLE_API_CLIENT_ID=your-client-id +export GOOGLE_API_CLIENT_SECRET=your-client-secret +export GOOGLE_API_REFRESH_TOKEN=your-api-refresh-token +---- diff --git a/integration-tests/google/pom.xml b/integration-tests/google/pom.xml new file mode 100644 index 0000000..e2af1ca --- /dev/null +++ b/integration-tests/google/pom.xml @@ -0,0 +1,113 @@ +<?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-integration-tests</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-quarkus-integration-test-google</artifactId> + <name>Camel Quarkus :: Integration Tests :: Google APIs</name> + <description>Integration tests for Camel Quarkus Google APIs</description> + + <properties> + <!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd --> + <!-- The following rule tells mvnd to build the listed deployment modules before this module. --> + <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not --> + <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. --> + <!-- Please update rule whenever you change the dependencies of this module by running --> + <!-- mvn process-resources -Pformat from the root directory --> + <mvnd.builder.rule>camel-quarkus-google-mail-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-google-mail</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>build</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.package.type>native</quarkus.package.type> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> diff --git a/integration-tests/google/src/main/java/org/apache/camel/quarkus/component/google/it/GoogleMailResource.java b/integration-tests/google/src/main/java/org/apache/camel/quarkus/component/google/it/GoogleMailResource.java new file mode 100644 index 0000000..bb6f8d6 --- /dev/null +++ b/integration-tests/google/src/main/java/org/apache/camel/quarkus/component/google/it/GoogleMailResource.java @@ -0,0 +1,129 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.google.it; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import javax.inject.Inject; +import javax.mail.MessagingException; +import javax.mail.Session; +import javax.mail.internet.MimeMessage; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import com.google.api.client.googleapis.json.GoogleJsonResponseException; +import com.google.api.services.gmail.model.Message; +import com.google.api.services.gmail.model.Profile; +import org.apache.camel.CamelExecutionException; +import org.apache.camel.ProducerTemplate; + +import static javax.mail.Message.RecipientType.TO; + +@Path("/google-mail") +public class GoogleMailResource { + + private static final String EMAIL_SUBJECT = "Camel Quarkus Google Mail Test"; + private static final String USER_ID = "me"; + + @Inject + ProducerTemplate producerTemplate; + + @Path("/create") + @POST + @Consumes(MediaType.TEXT_PLAIN) + @Produces(MediaType.TEXT_PLAIN) + public Response createMail(String message) throws Exception { + Message email = createMessage(message); + Map<String, Object> headers = new HashMap<>(); + headers.put("CamelGoogleMail.userId", USER_ID); + headers.put("CamelGoogleMail.content", email); + final Message response = producerTemplate.requestBodyAndHeaders("google-mail://messages/send", null, headers, + Message.class); + return Response + .created(new URI("https://camel.apache.org/")) + .entity(response.getId()) + .build(); + } + + @Path("/read") + @GET + @Produces(MediaType.TEXT_PLAIN) + public Response readMail(@QueryParam("messageId") String messageId) { + Map<String, Object> headers = new HashMap<>(); + headers.put("CamelGoogleMail.userId", USER_ID); + headers.put("CamelGoogleMail.id", messageId); + + try { + Message response = producerTemplate.requestBodyAndHeaders("google-mail://messages/get", null, headers, + Message.class); + if (response != null && response.getPayload() != null) { + String body = new String(response.getPayload().getBody().decodeData(), StandardCharsets.UTF_8); + return Response.ok(body).build(); + } else { + return Response.status(Response.Status.NOT_FOUND).build(); + } + } catch (CamelExecutionException e) { + Exception exchangeException = e.getExchange().getException(); + if (exchangeException != null && exchangeException.getCause() instanceof GoogleJsonResponseException) { + GoogleJsonResponseException originalException = (GoogleJsonResponseException) exchangeException.getCause(); + return Response.status(originalException.getStatusCode()).build(); + } + throw e; + } + } + + @Path("/delete") + @DELETE + public Response deleteMail(@QueryParam("messageId") String messageId, String message) { + Map<String, Object> headers = new HashMap<>(); + headers.put("CamelGoogleMail.userId", USER_ID); + headers.put("CamelGoogleMail.id", messageId); + producerTemplate.requestBodyAndHeaders("google-mail://messages/delete", message, headers); + return Response.status(Response.Status.NO_CONTENT).build(); + } + + private Message createMessage(String body) throws MessagingException, IOException { + Session session = Session.getDefaultInstance(new Properties(), null); + + Profile profile = producerTemplate.requestBody("google-mail://users/getProfile?inBody=userId", USER_ID, Profile.class); + MimeMessage mm = new MimeMessage(session); + mm.addRecipients(TO, profile.getEmailAddress()); + mm.setSubject(EMAIL_SUBJECT); + mm.setContent(body, "text/plain"); + + Message message = new Message(); + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + mm.writeTo(baos); + message.setRaw(Base64.getUrlEncoder().encodeToString(baos.toByteArray())); + } + return message; + } +} diff --git a/integration-tests/google/src/main/resources/application.properties b/integration-tests/google/src/main/resources/application.properties new file mode 100644 index 0000000..1a9b4af --- /dev/null +++ b/integration-tests/google/src/main/resources/application.properties @@ -0,0 +1,22 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# Camel Google Mail +camel.component.google-mail.configuration.application-name={{env:GOOGLE_API_APPLICATION_NAME}} +camel.component.google-mail.configuration.client-id={{env:GOOGLE_API_CLIENT_ID}} +camel.component.google-mail.configuration.client-secret={{env:GOOGLE_API_CLIENT_SECRET}} +camel.component.google-mail.configuration.refresh-token={{env:GOOGLE_API_REFRESH_TOKEN}} diff --git a/integration-tests/google/src/test/java/org/apache/camel/quarkus/component/google/it/GoogleComponentsIT.java b/integration-tests/google/src/test/java/org/apache/camel/quarkus/component/google/it/GoogleComponentsIT.java new file mode 100644 index 0000000..6729ae0 --- /dev/null +++ b/integration-tests/google/src/test/java/org/apache/camel/quarkus/component/google/it/GoogleComponentsIT.java @@ -0,0 +1,29 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.google.it; + +import io.quarkus.test.junit.NativeImageTest; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; + +@EnabledIfEnvironmentVariable(named = "GOOGLE_API_APPLICATION_NAME", matches = ".+") +@EnabledIfEnvironmentVariable(named = "GOOGLE_API_CLIENT_ID", matches = ".+") +@EnabledIfEnvironmentVariable(named = "GOOGLE_API_CLIENT_SECRET", matches = ".+") +@EnabledIfEnvironmentVariable(named = "GOOGLE_API_REFRESH_TOKEN", matches = ".+") +@NativeImageTest +class GoogleComponentsIT extends GoogleComponentsTest { + +} diff --git a/integration-tests/google/src/test/java/org/apache/camel/quarkus/component/google/it/GoogleComponentsTest.java b/integration-tests/google/src/test/java/org/apache/camel/quarkus/component/google/it/GoogleComponentsTest.java new file mode 100644 index 0000000..4e58da3 --- /dev/null +++ b/integration-tests/google/src/test/java/org/apache/camel/quarkus/component/google/it/GoogleComponentsTest.java @@ -0,0 +1,70 @@ +/* + * 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. + */ +package org.apache.camel.quarkus.component.google.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; + +import static org.hamcrest.Matchers.is; + +@EnabledIfEnvironmentVariable(named = "GOOGLE_API_APPLICATION_NAME", matches = ".+") +@EnabledIfEnvironmentVariable(named = "GOOGLE_API_CLIENT_ID", matches = ".+") +@EnabledIfEnvironmentVariable(named = "GOOGLE_API_CLIENT_SECRET", matches = ".+") +@EnabledIfEnvironmentVariable(named = "GOOGLE_API_REFRESH_TOKEN", matches = ".+") +@QuarkusTest +class GoogleComponentsTest { + + @Test + public void testGoogleMailComponent() { + String message = "Hello Camel Quarkus Google Mail"; + + // Create + String messageId = RestAssured.given() + .contentType(ContentType.TEXT) + .body(message) + .post("/google-mail/create") + .then() + .statusCode(201) + .extract() + .body() + .asString(); + + // Read + RestAssured.given() + .queryParam("messageId", messageId) + .get("/google-mail/read") + .then() + .statusCode(200) + .body(is(message)); + + // Delete + RestAssured.given() + .queryParam("messageId", messageId) + .delete("/google-mail/delete") + .then() + .statusCode(204); + + RestAssured.given() + .queryParam("messageId", messageId) + .get("/google-mail/read") + .then() + .statusCode(404); + } +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index f6ad9e0..6a21f75 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -177,6 +177,7 @@ <module>fhir</module> <module>file</module> <module>ftp</module> + <module>google</module> <module>graphql</module> <module>http</module> <module>hystrix</module> diff --git a/pom.xml b/pom.xml index a10dd2f..06a708a 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,7 @@ <retrofit.version>2.5.0</retrofit.version> <consul-client.version>1.3.3</consul-client.version> <stax2.version>4.2</stax2.version> + <jakarta.mail.version>1.6.5</jakarta.mail.version> <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version> <maven.compiler.target>1.8</maven.compiler.target> diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml index 3429198..adf1cc2 100644 --- a/poms/bom-deployment/pom.xml +++ b/poms/bom-deployment/pom.xml @@ -256,6 +256,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-google-mail-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-graphql-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -511,6 +516,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-google-http-client-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-httpclient-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -526,6 +536,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mail-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-policy-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 294bd0e..a13bdfc 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -299,6 +299,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-google-mail</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-graphql</artifactId> <version>${camel.version}</version> </dependency> @@ -917,6 +922,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-google-mail</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-graphql</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -1182,6 +1192,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-google-http-client</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-httpclient</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -1197,6 +1212,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-mail</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-policy</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -1326,6 +1346,12 @@ <groupId>com.google.http-client</groupId> <artifactId>google-http-client</artifactId> <version>${google-http-client.version}</version> + <exclusions> + <exclusion> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>com.orbitz.consul</groupId> @@ -1343,6 +1369,17 @@ <version>${retrofit.version}</version> </dependency> <dependency> + <groupId>com.sun.mail</groupId> + <artifactId>jakarta.mail</artifactId> + <version>${jakarta.mail.version}</version> + <exclusions> + <exclusion> + <groupId>com.sun.activation</groupId> + <artifactId>jakarta.activation</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> <version>${xstream.version}</version>