Skip to content

Commit

Permalink
Geocoder native support fixes #1645 (#1856)
Browse files Browse the repository at this point in the history
* Geocoder native support fixes #1645
  • Loading branch information
zbendhiba committed Oct 1, 2020
1 parent 0c0954d commit da5b9be
Show file tree
Hide file tree
Showing 26 changed files with 688 additions and 133 deletions.
19 changes: 15 additions & 4 deletions docs/modules/ROOT/pages/reference/extensions/geocoder.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
= Geocoder
:cq-artifact-id: camel-quarkus-geocoder
:cq-native-supported: false
:cq-status: Preview
:cq-native-supported: true
:cq-status: Stable
:cq-description: Find geocodes (latitude and longitude) for a given address or the other way round.
:cq-deprecated: false
:cq-jvm-since: 1.1.0
:cq-native-since: n/a
:cq-native-since: 1.2.0

[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##1.2.0##

Find geocodes (latitude and longitude) for a given address or the other way round.

Expand All @@ -31,3 +31,14 @@ Please refer to the above link for usage and configuration details.
----

Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.

== SSL in native mode

This extension auto-enables SSL support in native mode. Hence you do not need to add
`quarkus.ssl.native=true` to your `application.properties` yourself. See also
https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide].

== Additional Camel Quarkus configuration

Locales different from the build machine's default locale do not work well in native mode due to https://github.com/oracle/graal/issues/1645[this GraalVM bug]. The `google-maps-services` library this extension depends on uses `Locale.English` to format double latitude and longitude values. As a consequence of these two facts, the locale on the building machine must be set to some English locale, such as `en_US.UTF-8`, `en_GB.UTF-8` or `en_IE.UTF-8` so that the calls to the Google Maps API work properly. On Linux, you need to check the value of the `LANG` environment variable, e.g. via `echo $LANG` and change the value via `export LANG=en_US.UTF-8` if necessary.

6 changes: 3 additions & 3 deletions docs/modules/ROOT/partials/reference/components/geocoder.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
:cq-artifact-id: camel-quarkus-geocoder
:cq-artifact-id-base: geocoder
:cq-native-supported: false
:cq-status: Preview
:cq-native-supported: true
:cq-status: Stable
:cq-deprecated: false
:cq-jvm-since: 1.1.0
:cq-native-since: n/a
:cq-native-since: 1.2.0
:cq-camel-part-name: geocoder
:cq-camel-part-title: Geocoder
:cq-camel-part-description: Find geocodes (latitude and longitude) for a given address or the other way round.
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion extensions-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<module>flink</module>
<module>freemarker</module>
<module>ganglia</module>
<module>geocoder</module>
<module>google-bigquery</module>
<module>google-pubsub</module>
<module>groovy</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-geocoder</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-httpclient-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jsonpath-deployment</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.geocoder.deployment;

import java.util.ArrayList;
import java.util.List;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;

class GeocoderProcessor {

private static final String FEATURE = "camel-geocoder";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
ExtensionSslNativeSupportBuildItem activateSslNativeSupport() {
return new ExtensionSslNativeSupportBuildItem(FEATURE);
}

@BuildStep
List<ReflectiveClassBuildItem> registerReflectiveClasses() {
List<ReflectiveClassBuildItem> items = new ArrayList<ReflectiveClassBuildItem>();
items.add(new ReflectiveClassBuildItem(false, true, "com.google.maps.GeocodingApi$Response"));
items.add(new ReflectiveClassBuildItem(false, true, "com.google.maps.model.GeocodingResult"));
items.add(new ReflectiveClassBuildItem(false, true, "com.google.maps.model.AddressComponent"));
items.add(new ReflectiveClassBuildItem(false, true, "com.google.maps.model.Geometry"));
items.add(new ReflectiveClassBuildItem(false, true, "com.google.maps.model.AddressType"));
items.add(new ReflectiveClassBuildItem(false, true, "com.google.maps.model.PlusCode"));
items.add(new ReflectiveClassBuildItem(false, true, "com.google.maps.model.Bounds"));
items.add(new ReflectiveClassBuildItem(false, true, "com.google.maps.model.LatLng"));
items.add(new ReflectiveClassBuildItem(false, true, "com.google.maps.model.LocationType"));
return items;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@
<modules>
<module>deployment</module>
<module>runtime</module>
<module>integration-test</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<properties>
<camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
<camel.quarkus.nativeSince>1.2.0</camel.quarkus.nativeSince>
</properties>

<dependencyManagement>
Expand All @@ -56,6 +57,24 @@
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-geocoder</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jsonpath</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Locales different from the build machine's default locale do not work well in native mode due to https://github.com/oracle/graal/issues/1645[this GraalVM bug]. The `google-maps-services` library this extension depends on uses `Locale.English` to format double latitude and longitude values. As a consequence of these two facts, the locale on the building machine must be set to some English locale, such as `en_US.UTF-8`, `en_GB.UTF-8` or `en_IE.UTF-8` so that the calls to the Google Maps API work properly. On Linux, you need to check the value of the `LANG` environment variable, e.g. via `echo $LANG` and change the value via `export LANG=en_US.UTF-8` if necessary.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
name: "Camel Geocoder"
description: "Find geocodes (latitude and longitude) for a given address or the other way round"
metadata:
unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/geocoder.html"
categories:
- "integration"
status:
- "preview"
- "stable"
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<module>flatpack</module>
<module>fop</module>
<module>ftp</module>
<module>geocoder</module>
<module>git</module>
<module>github</module>
<module>google-calendar</module>
Expand Down
10 changes: 10 additions & 0 deletions integration-tests/geocoder/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
== Camel Quarkus Geocoder Integration Tests

To run `camel-quarkus-geocoder` integration tests using google maps service, you will need a google cloud https://developers.google.com/maps/documentation/javascript/get-api-key[API key].

Then set the following environment variable:

[source,shell]
----
GOOGLE_API_KEY=your-api-id
----
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-build-parent-it</artifactId>
<artifactId>camel-quarkus-integration-tests</artifactId>
<version>1.2.0-SNAPSHOT</version>
<relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-geocoder-integration-test</artifactId>
<name>Camel Quarkus :: Geocoder :: Integration Test</name>
<artifactId>camel-quarkus-integration-test-geocoder</artifactId>
<name>Camel Quarkus :: Integration Tests :: Geocoder</name>
<description>Integration tests for Camel Quarkus Geocoder extension</description>

<properties>
<!-- mvnd, a.k.a. Maven Daemon: https://github.com/mvndaemon/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 the rule whenever you change the dependencies of this module by running -->
<!-- mvn process-resources -Pformat from the root directory -->
<mvnd.builder.rule>camel-quarkus-geocoder-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -63,6 +52,11 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>


<!-- test dependencies -->
<dependency>
Expand All @@ -75,6 +69,21 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>

<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-geocoder-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand All @@ -92,4 +101,34 @@
</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>

0 comments on commit da5b9be

Please sign in to comment.