Skip to content

Commit

Permalink
Velocity Support apache#837
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriOndrusek committed Sep 17, 2020
1 parent a96274a commit 9e1e170
Show file tree
Hide file tree
Showing 18 changed files with 372 additions and 138 deletions.
8 changes: 4 additions & 4 deletions docs/modules/ROOT/pages/reference/components/velocity.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
= Velocity
:cq-artifact-id: camel-quarkus-velocity
:cq-artifact-id-base: velocity
: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-jvm-since: 1.2.0
:cq-native-since: 1.2.0
:cq-camel-part-name: velocity
:cq-camel-part-title: Velocity
:cq-camel-part-description: Transform messages using a Velocity template.
Expand Down
10 changes: 5 additions & 5 deletions docs/modules/ROOT/pages/reference/extensions/velocity.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

= Velocity
:cq-artifact-id: camel-quarkus-velocity
:cq-native-supported: false
:cq-status: Preview
:cq-native-supported: true
:cq-status: Stable
:cq-description: Transform messages using a Velocity template.
:cq-deprecated: false
:cq-jvm-since: 1.1.0
:cq-native-since: n/a
:cq-jvm-since: 1.2.0
: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.2.0## [.badge-key]##Native since##[.badge-supported]##1.2.0##

Transform messages using a Velocity template.

Expand Down
1 change: 0 additions & 1 deletion extensions-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
<module>thrift</module>
<module>twilio</module>
<module>univocity-parsers</module>
<module>velocity</module>
<module>web3j</module>
<module>weka</module>
<module>wordpress</module>
Expand Down

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
<module>timer</module>
<module>twitter</module>
<module>validator</module>
<module>velocity</module>
<module>vertx</module>
<module>vertx-http</module>
<module>vertx-websocket</module>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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.velocity.deployment;

import java.util.ArrayList;
import java.util.TreeMap;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import org.apache.camel.component.velocity.CamelVelocityClasspathResourceLoader;
import org.apache.camel.support.MessageSupport;
import org.jboss.jandex.IndexView;

import static java.util.stream.Collectors.toCollection;

class VelocityProcessor {

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

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

@BuildStep
NativeImageResourceBuildItem initResources() {
return new NativeImageResourceBuildItem(
"org/apache/velocity/runtime/defaults/velocity.properties",
"org/apache/velocity/runtime/defaults/directive.properties");
}

@BuildStep
ReflectiveClassBuildItem registerForReflection(CombinedIndexBuildItem combinedIndex) {
IndexView index = combinedIndex.getIndex();

ArrayList<String> dtos = index.getKnownClasses().stream().map(ci -> ci.name().toString())
.filter(n -> n.startsWith("org.apache.velocity.runtime") ||
n.startsWith("org.apache.velocity.util.introspection"))
.sorted()
.collect(toCollection(ArrayList::new));

dtos.add(CamelVelocityClasspathResourceLoader.class.getName());

return new ReflectiveClassBuildItem(false, false, dtos.toArray(new String[dtos.size()]));
}

@BuildStep
ReflectiveClassBuildItem registerForReflectionWithMethods() {
return new ReflectiveClassBuildItem(true, false,
TreeMap.class.getName(),
MessageSupport.class.getName());
}

@BuildStep
IndexDependencyBuildItem registerDependencyForIndex() {
return new IndexDependencyBuildItem("org.apache.velocity", "velocity-engine-core");
}
}
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 @@ -33,7 +33,8 @@
<description>Transform messages using a Velocity template.</description>

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

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
name: "Camel Velocity"
description: "Transform messages using a Velocity template"
metadata:
unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/velocity.html"
categories:
- "integration"
status:
- "preview"
- "stable"
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
<module>tika</module>
<module>twitter</module>
<module>validator</module>
<module>velocity</module>
<module>vertx</module>
<module>vertx-websocket</module>
<module>weather</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,15 @@
<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>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-velocity-integration-test</artifactId>
<name>Camel Quarkus :: Velocity :: Integration Test</name>
<artifactId>camel-quarkus-integration-test-velocity</artifactId>
<name>Camel Quarkus :: Integration Tests :: Velocity</name>
<description>Integration tests for Camel Quarkus Velocity 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-support-policy-deployment,camel-quarkus-velocity-deployment</mvnd.builder.rule>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -63,6 +53,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</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-velocity-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,35 @@
</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 9e1e170

Please sign in to comment.