You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/03/02 18:47:31 UTC

[GitHub] [camel-quarkus] carlosthe19916 opened a new pull request #835: Camel-freemarker component

carlosthe19916 opened a new pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835
 
 
   Added camel-freemarker component.
   Changes:
   - The same test used for apache-camel-freemarker
   - We can add the list of locations where the templates can be found in the classpath using: `quarkus.camel.freemarker.locations=myFolder1,myFolder2`
   
   Looking forward to have some feedback.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on issue #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on issue #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#issuecomment-594042675
 
 
   Could you please rebase and squash your commits? It would make it easier to review locally.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387108087
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.freemarker.deployment;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.freemarker.CamelFreemarkerConfig;
+import org.apache.commons.io.FilenameUtils;
+import org.jboss.logging.Logger;
+
+class FreemarkerNativeImageProcessor {
+    private static final String CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL = "classpath";
+    private static final String JAR_APPLICATION_MIGRATIONS_PROTOCOL = "jar";
+    private static final String FILE_APPLICATION_MIGRATIONS_PROTOCOL = "file";
+
+    private static final Logger LOGGER = Logger.getLogger(FreemarkerNativeImageProcessor.class);
+
+    @BuildStep(loadsApplicationClasses = true)
+    void build(
+            BuildProducer<NativeImageResourceBuildItem> resourceProducer,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        registerNativeImageResources(resourceProducer, camelFreemarkerConfig);
 
 Review comment:
   Could you please inline `registerNativeImageResources()` into `build()`? I think it will be easier to read that way.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387719646
 
 

 ##########
 File path: integration-tests/freemarker/src/main/resources/application.properties
 ##########
 @@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+#
+# Quarkus
+#
+quarkus.camel.freemarker.locations = org/apache/camel/component/freemarker
 
 Review comment:
   > Only files with the extension `.ftl` will be included.
   
   Thanks for the info, I have not noticed that and I must say I do not think we should be selecting only `*.ftl` files. I commonly used other or no extensions for FreeMarker template files in the past. I think many people do that because because of syntax highlighting in editors. There is even a couple of examples in this repo: https://github.com/apache/camel-quarkus/tree/master/tooling/create-extension-templates
   
   I think we should either include whole subtrees or we should have path includes and excludes like we have in https://github.com/apache/camel-quarkus/blob/master/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelConfig.java#L74-L100 WDYT?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387662659
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.freemarker.deployment;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.freemarker.CamelFreemarkerConfig;
+import org.apache.commons.io.FilenameUtils;
+import org.jboss.logging.Logger;
+
+class FreemarkerNativeImageProcessor {
+    private static final String CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL = "classpath";
+    private static final String JAR_APPLICATION_MIGRATIONS_PROTOCOL = "jar";
+    private static final String FILE_APPLICATION_MIGRATIONS_PROTOCOL = "file";
+
+    private static final Logger LOGGER = Logger.getLogger(FreemarkerNativeImageProcessor.class);
+
+    @BuildStep(loadsApplicationClasses = true)
+    void build(
+            BuildProducer<NativeImageResourceBuildItem> resourceProducer,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        registerNativeImageResources(resourceProducer, camelFreemarkerConfig);
 
 Review comment:
   Thanks for the good advice, I'll do it inline just like you suggested :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387133718
 
 

 ##########
 File path: extensions/freemarker/runtime/pom.xml
 ##########
 @@ -0,0 +1,82 @@
+<?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-freemarker-parent</artifactId>
+        <version>1.1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>camel-quarkus-freemarker</artifactId>
+    <name>Camel Quarkus :: Freemarker :: Runtime</name>
+
+    <properties>
+        <firstVersion>0.4.0</firstVersion>
 
 Review comment:
   ```suggestion
           <firstVersion>1.0.0-M5</firstVersion>
   ```
   
   and re-run `mvn process-resources -Pformat -Denforce=false`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on issue #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on issue #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#issuecomment-597736887
 
 
   @ppalaga I've also added a new Config property called `classModels` which should be used to pass all Java Classes that will be marked for reflection. Freemarker uses POJOs for processing the templates but if those POJOs were not marked for reflection using Quarkus, then an exception will happen... Because of this change, I've removed this line https://github.com/apache/camel-quarkus/pull/835/commits/0e2d854d776a9e656b2bfafc40826ee330710b1b#diff-d5f7db497629630202e093f916c76b9eL65 WDYT?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r389525486
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.freemarker.deployment;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.freemarker.CamelFreemarkerConfig;
+import org.apache.commons.io.FilenameUtils;
+import org.jboss.logging.Logger;
+
+class FreemarkerNativeImageProcessor {
+    private static final String CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL = "classpath";
+    private static final String JAR_APPLICATION_MIGRATIONS_PROTOCOL = "jar";
+    private static final String FILE_APPLICATION_MIGRATIONS_PROTOCOL = "file";
+
+    private static final Logger LOGGER = Logger.getLogger(FreemarkerNativeImageProcessor.class);
+
+    @BuildStep(loadsApplicationClasses = true)
+    void build(
+            BuildProducer<NativeImageResourceBuildItem> resourceProducer,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        registerNativeImageResources(resourceProducer, camelFreemarkerConfig);
+    }
+
+    private void registerNativeImageResources(
+            BuildProducer<NativeImageResourceBuildItem> resource,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> templates = discoverFreemarkerTemplates(camelFreemarkerConfig);
+        final List<String> nativeResources = new ArrayList<>(templates);
+        resource.produce(new NativeImageResourceBuildItem(nativeResources.toArray(new String[0])));
+    }
+
+    private List<String> discoverFreemarkerTemplates(
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> resources = new ArrayList<>();
+        try {
+            List<String> locations = new ArrayList<>(camelFreemarkerConfig.locations);
+            if (locations.isEmpty()) {
+                locations.add("freemarker/templates");
+            }
+
+            // Locations can be a comma separated list
+            for (String location : locations) {
+                // Strip any 'classpath:' protocol prefixes because they are assumed
+                // but not recognized by ClassLoader.getResources()
+                if (location != null && location.startsWith(CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL + ':')) {
 
 Review comment:
   Thanks for the research, I have learned something.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387661984
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerProcessor.java
 ##########
 @@ -0,0 +1,54 @@
+/*
+ * 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.freemarker.deployment;
+
+import freemarker.ext.jython.JythonModel;
+import freemarker.ext.jython.JythonWrapper;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultExchange;
+
+class FreemarkerProcessor {
+    private static final String FEATURE = "camel-freemarker";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    RuntimeInitializedClassBuildItem jythonModel() {
+        return new RuntimeInitializedClassBuildItem(JythonModel.class.getCanonicalName());
+    }
+
+    @BuildStep
+    RuntimeInitializedClassBuildItem jythonWrapper() {
+        return new RuntimeInitializedClassBuildItem(JythonWrapper.class.getCanonicalName());
+    }
+
+    @BuildStep
+    void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
+        reflectiveClass.produce(new ReflectiveClassBuildItem(true, true,
+                Exchange.class,
 
 Review comment:
   Yes, adding Exchange for reflection is needed. According to this documentation: [freemarker context](https://camel.apache.org/components/latest/freemarker-component.html#_freemarker_context), it should be possible to use `exchange.properties` in the `.ftl` templates just like this example: https://github.com/carlosthe19916/camel-quarkus/blob/7d45a783e5b27d341b6a07df49b34087f636dad3/integration-tests/freemarker/src/main/resources/org/apache/camel/component/freemarker/example.ftl#L19. Without using reflection for Exchange it won't work.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387131974
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerProcessor.java
 ##########
 @@ -0,0 +1,54 @@
+/*
+ * 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.freemarker.deployment;
+
+import freemarker.ext.jython.JythonModel;
+import freemarker.ext.jython.JythonWrapper;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultExchange;
+
+class FreemarkerProcessor {
+    private static final String FEATURE = "camel-freemarker";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    RuntimeInitializedClassBuildItem jythonModel() {
+        return new RuntimeInitializedClassBuildItem(JythonModel.class.getCanonicalName());
+    }
+
+    @BuildStep
+    RuntimeInitializedClassBuildItem jythonWrapper() {
+        return new RuntimeInitializedClassBuildItem(JythonWrapper.class.getCanonicalName());
+    }
+
+    @BuildStep
+    void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
+        reflectiveClass.produce(new ReflectiveClassBuildItem(true, true,
+                Exchange.class,
 
 Review comment:
   Is Exchange really required here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r389515876
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.freemarker.deployment;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.freemarker.CamelFreemarkerConfig;
+import org.apache.commons.io.FilenameUtils;
+import org.jboss.logging.Logger;
+
+class FreemarkerNativeImageProcessor {
+    private static final String CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL = "classpath";
+    private static final String JAR_APPLICATION_MIGRATIONS_PROTOCOL = "jar";
+    private static final String FILE_APPLICATION_MIGRATIONS_PROTOCOL = "file";
+
+    private static final Logger LOGGER = Logger.getLogger(FreemarkerNativeImageProcessor.class);
+
+    @BuildStep(loadsApplicationClasses = true)
+    void build(
+            BuildProducer<NativeImageResourceBuildItem> resourceProducer,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        registerNativeImageResources(resourceProducer, camelFreemarkerConfig);
+    }
+
+    private void registerNativeImageResources(
+            BuildProducer<NativeImageResourceBuildItem> resource,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> templates = discoverFreemarkerTemplates(camelFreemarkerConfig);
+        final List<String> nativeResources = new ArrayList<>(templates);
+        resource.produce(new NativeImageResourceBuildItem(nativeResources.toArray(new String[0])));
+    }
+
+    private List<String> discoverFreemarkerTemplates(
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> resources = new ArrayList<>();
+        try {
+            List<String> locations = new ArrayList<>(camelFreemarkerConfig.locations);
+            if (locations.isEmpty()) {
+                locations.add("freemarker/templates");
+            }
+
+            // Locations can be a comma separated list
+            for (String location : locations) {
+                // Strip any 'classpath:' protocol prefixes because they are assumed
+                // but not recognized by ClassLoader.getResources()
+                if (location != null && location.startsWith(CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL + ':')) {
 
 Review comment:
   @ppalaga good point. I've verified that `my/path1,,my/path2` will cause just 2 locations but `my/path1, ,my/path2` (notice the blank space) will generate 3 locations and generate an exception... I've added a basic filter to validate it https://github.com/carlosthe19916/camel-quarkus/blob/7c027254d03024ec7d64aeffd040ae05da4677ff/extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java#L66
   
   I also added this case to the test here https://github.com/carlosthe19916/camel-quarkus/blob/7c027254d03024ec7d64aeffd040ae05da4677ff/integration-tests/freemarker/src/main/resources/application.properties#L20

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387141230
 
 

 ##########
 File path: integration-tests/freemarker/src/main/resources/application.properties
 ##########
 @@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+#
+# Quarkus
+#
+quarkus.camel.freemarker.locations = org/apache/camel/component/freemarker
 
 Review comment:
   Given that `org/apache/camel/component/freemarker` will be scanned recursivelly, I wonder whether all the class files are going to get included as native image resources? I would be interesting to compare the size of the native image using this locations value and using a new path that does not contain any class files.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387728766
 
 

 ##########
 File path: extensions/freemarker/runtime/pom.xml
 ##########
 @@ -0,0 +1,82 @@
+<?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-freemarker-parent</artifactId>
+        <version>1.1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>camel-quarkus-freemarker</artifactId>
+    <name>Camel Quarkus :: Freemarker :: Runtime</name>
+
+    <properties>
+        <firstVersion>0.4.0</firstVersion>
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r386894794
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,120 @@
+package org.apache.camel.quarkus.component.freemarker.deployment;
 
 Review comment:
   @oscerd Added, thanks

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387698516
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.freemarker.deployment;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.freemarker.CamelFreemarkerConfig;
+import org.apache.commons.io.FilenameUtils;
+import org.jboss.logging.Logger;
+
+class FreemarkerNativeImageProcessor {
+    private static final String CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL = "classpath";
+    private static final String JAR_APPLICATION_MIGRATIONS_PROTOCOL = "jar";
+    private static final String FILE_APPLICATION_MIGRATIONS_PROTOCOL = "file";
+
+    private static final Logger LOGGER = Logger.getLogger(FreemarkerNativeImageProcessor.class);
+
+    @BuildStep(loadsApplicationClasses = true)
+    void build(
+            BuildProducer<NativeImageResourceBuildItem> resourceProducer,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        registerNativeImageResources(resourceProducer, camelFreemarkerConfig);
+    }
+
+    private void registerNativeImageResources(
+            BuildProducer<NativeImageResourceBuildItem> resource,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> templates = discoverFreemarkerTemplates(camelFreemarkerConfig);
+        final List<String> nativeResources = new ArrayList<>(templates);
+        resource.produce(new NativeImageResourceBuildItem(nativeResources.toArray(new String[0])));
+    }
+
+    private List<String> discoverFreemarkerTemplates(
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> resources = new ArrayList<>();
+        try {
+            List<String> locations = new ArrayList<>(camelFreemarkerConfig.locations);
+            if (locations.isEmpty()) {
+                locations.add("freemarker/templates");
+            }
+
+            // Locations can be a comma separated list
+            for (String location : locations) {
+                // Strip any 'classpath:' protocol prefixes because they are assumed
+                // but not recognized by ClassLoader.getResources()
+                if (location != null && location.startsWith(CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL + ':')) {
 
 Review comment:
   Hm..., I wonder how the MicroProfile config impl used by Quarkus would parse a double comma value like this
   
   ```
   quarkus.camel.freemarker.locations = my/path1,,my/path2
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387132630
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerProcessor.java
 ##########
 @@ -0,0 +1,54 @@
+/*
+ * 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.freemarker.deployment;
+
+import freemarker.ext.jython.JythonModel;
+import freemarker.ext.jython.JythonWrapper;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultExchange;
+
+class FreemarkerProcessor {
+    private static final String FEATURE = "camel-freemarker";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    RuntimeInitializedClassBuildItem jythonModel() {
+        return new RuntimeInitializedClassBuildItem(JythonModel.class.getCanonicalName());
+    }
+
+    @BuildStep
+    RuntimeInitializedClassBuildItem jythonWrapper() {
+        return new RuntimeInitializedClassBuildItem(JythonWrapper.class.getCanonicalName());
+    }
+
+    @BuildStep
+    void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
+        reflectiveClass.produce(new ReflectiveClassBuildItem(true, true,
 
 Review comment:
   Wouldn't `new ReflectiveClassBuildItem(true, false, ...` be enough?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r389517223
 
 

 ##########
 File path: integration-tests/freemarker/src/main/resources/application.properties
 ##########
 @@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+#
+# Quarkus
+#
+quarkus.camel.freemarker.locations = org/apache/camel/component/freemarker
 
 Review comment:
   Good point @ppalaga . Files with different extensions should still work. I agree and we should include the whole subtree but just to avoid adding files we don't want to add we can use `includePatterns` and `excludePatterns` as you suggested. Let me add it

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387663697
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.freemarker.deployment;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.freemarker.CamelFreemarkerConfig;
+import org.apache.commons.io.FilenameUtils;
+import org.jboss.logging.Logger;
+
+class FreemarkerNativeImageProcessor {
+    private static final String CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL = "classpath";
+    private static final String JAR_APPLICATION_MIGRATIONS_PROTOCOL = "jar";
+    private static final String FILE_APPLICATION_MIGRATIONS_PROTOCOL = "file";
+
+    private static final Logger LOGGER = Logger.getLogger(FreemarkerNativeImageProcessor.class);
+
+    @BuildStep(loadsApplicationClasses = true)
+    void build(
+            BuildProducer<NativeImageResourceBuildItem> resourceProducer,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        registerNativeImageResources(resourceProducer, camelFreemarkerConfig);
+    }
+
+    private void registerNativeImageResources(
+            BuildProducer<NativeImageResourceBuildItem> resource,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> templates = discoverFreemarkerTemplates(camelFreemarkerConfig);
+        final List<String> nativeResources = new ArrayList<>(templates);
+        resource.produce(new NativeImageResourceBuildItem(nativeResources.toArray(new String[0])));
+    }
+
+    private List<String> discoverFreemarkerTemplates(
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> resources = new ArrayList<>();
+        try {
+            List<String> locations = new ArrayList<>(camelFreemarkerConfig.locations);
+            if (locations.isEmpty()) {
+                locations.add("freemarker/templates");
+            }
+
+            // Locations can be a comma separated list
+            for (String location : locations) {
+                // Strip any 'classpath:' protocol prefixes because they are assumed
+                // but not recognized by ClassLoader.getResources()
+                if (location != null && location.startsWith(CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL + ':')) {
 
 Review comment:
   my mistake, it shouldn't be possible to have null values since it comes from `CamelFreemarkerConfig`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r391498846
 
 

 ##########
 File path: docs/modules/ROOT/pages/extensions/freemarker.adoc
 ##########
 @@ -0,0 +1,53 @@
+[[freemarker]]
+= Freemarker Extension
+
+*Since Camel Quarkus 0.3.0*
+
+The Freemarker extension component allows processing a message using a FreeMarker template. This can be ideal when using Templating to generate responses for requests.
+
+Maven users will need to add the following dependency to their `pom.xml` for this extension.
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+    <groupId>org.apache.camel.quarkus</groupId>
+    <artifactId>camel-quarkus-freemarker</artifactId>
+</dependency>
+------------------------------------------------------------
+
+== Usage
+
+The extension provides support for the Camel https://camel.apache.org/components/latest/freemarker-component.html[Freemarker Component].
+
+=== Configuration
+
+The Camel Freemarker extension exposes the following configuration properties.
+
+[cols="80,.^10,.^10"]
+|===
+|Configuration property |Type |Default
+
+|`quarkus.camel.freemarker.locations`
 
 Review comment:
   Could we perhaps remove the locations option now that we have includes and excludes? The includes option seems to offer a superset of `locations` functionality. The default can be changed to `freemarker/templates/**` and moved to the includes option too. WDYT?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] oscerd commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
oscerd commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r386836005
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,120 @@
+package org.apache.camel.quarkus.component.freemarker.deployment;
 
 Review comment:
   Please add the ASF license header.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r391101531
 
 

 ##########
 File path: integration-tests/freemarker/src/main/resources/application.properties
 ##########
 @@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+#
+# Quarkus
+#
+quarkus.camel.freemarker.locations = org/apache/camel/component/freemarker
 
 Review comment:
   @ppalaga sorry for being so slow in this. I've added `includePatterns` and `excludePatterns`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r391502520
 
 

 ##########
 File path: docs/modules/ROOT/pages/extensions/freemarker.adoc
 ##########
 @@ -0,0 +1,53 @@
+[[freemarker]]
+= Freemarker Extension
+
+*Since Camel Quarkus 0.3.0*
+
+The Freemarker extension component allows processing a message using a FreeMarker template. This can be ideal when using Templating to generate responses for requests.
+
+Maven users will need to add the following dependency to their `pom.xml` for this extension.
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+    <groupId>org.apache.camel.quarkus</groupId>
+    <artifactId>camel-quarkus-freemarker</artifactId>
+</dependency>
+------------------------------------------------------------
+
+== Usage
+
+The extension provides support for the Camel https://camel.apache.org/components/latest/freemarker-component.html[Freemarker Component].
+
+=== Configuration
+
+The Camel Freemarker extension exposes the following configuration properties.
+
+[cols="80,.^10,.^10"]
+|===
+|Configuration property |Type |Default
+
+|`quarkus.camel.freemarker.locations`
+
+ Comma-separated list of locations to scan recursively for templates.
+|List<String>
+|`freemarker/templates`
+
+|`quarkus.camel.freemarker.include-patterns`
+
+ Used for inclusive filtering scanning of Freemarker templates. By default all tree files inside 'locations' will be included.
 
 Review comment:
   Plase add:
   
   * Where we scan for the templates (classpath, filesystem)
   * Are `classpath:` and `filesystem:` prefixes supported? Which one is the default? (I do not insist on supporting `filesystem:`) We have other extensions documenting similar features properly, just grep for `classpath:` in the source tree.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387659823
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerProcessor.java
 ##########
 @@ -0,0 +1,54 @@
+/*
+ * 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.freemarker.deployment;
+
+import freemarker.ext.jython.JythonModel;
+import freemarker.ext.jython.JythonWrapper;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultExchange;
+
+class FreemarkerProcessor {
+    private static final String FEATURE = "camel-freemarker";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    RuntimeInitializedClassBuildItem jythonModel() {
+        return new RuntimeInitializedClassBuildItem(JythonModel.class.getCanonicalName());
+    }
+
+    @BuildStep
+    RuntimeInitializedClassBuildItem jythonWrapper() {
+        return new RuntimeInitializedClassBuildItem(JythonWrapper.class.getCanonicalName());
+    }
+
+    @BuildStep
+    void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
+        reflectiveClass.produce(new ReflectiveClassBuildItem(true, true,
 
 Review comment:
   You're right, I'll update that, Thanks :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387110340
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.freemarker.deployment;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.freemarker.CamelFreemarkerConfig;
+import org.apache.commons.io.FilenameUtils;
+import org.jboss.logging.Logger;
+
+class FreemarkerNativeImageProcessor {
+    private static final String CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL = "classpath";
+    private static final String JAR_APPLICATION_MIGRATIONS_PROTOCOL = "jar";
+    private static final String FILE_APPLICATION_MIGRATIONS_PROTOCOL = "file";
+
+    private static final Logger LOGGER = Logger.getLogger(FreemarkerNativeImageProcessor.class);
+
+    @BuildStep(loadsApplicationClasses = true)
+    void build(
+            BuildProducer<NativeImageResourceBuildItem> resourceProducer,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        registerNativeImageResources(resourceProducer, camelFreemarkerConfig);
+    }
+
+    private void registerNativeImageResources(
+            BuildProducer<NativeImageResourceBuildItem> resource,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> templates = discoverFreemarkerTemplates(camelFreemarkerConfig);
+        final List<String> nativeResources = new ArrayList<>(templates);
+        resource.produce(new NativeImageResourceBuildItem(nativeResources.toArray(new String[0])));
+    }
+
+    private List<String> discoverFreemarkerTemplates(
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> resources = new ArrayList<>();
+        try {
+            List<String> locations = new ArrayList<>(camelFreemarkerConfig.locations);
+            if (locations.isEmpty()) {
+                locations.add("freemarker/templates");
 
 Review comment:
   Could you please declare `freemarker/templates` as a default directly on `CamelFreemarkerConfig.locations` using `@ConfigItem(defaultValue = "freemarker/templates")`?
   
   Could you please document the config param and the default in `docs/modules/ROOT/pages/extensions/freemarker.adoc`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387111844
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.freemarker.deployment;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.freemarker.CamelFreemarkerConfig;
+import org.apache.commons.io.FilenameUtils;
+import org.jboss.logging.Logger;
+
+class FreemarkerNativeImageProcessor {
+    private static final String CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL = "classpath";
+    private static final String JAR_APPLICATION_MIGRATIONS_PROTOCOL = "jar";
+    private static final String FILE_APPLICATION_MIGRATIONS_PROTOCOL = "file";
+
+    private static final Logger LOGGER = Logger.getLogger(FreemarkerNativeImageProcessor.class);
+
+    @BuildStep(loadsApplicationClasses = true)
+    void build(
+            BuildProducer<NativeImageResourceBuildItem> resourceProducer,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        registerNativeImageResources(resourceProducer, camelFreemarkerConfig);
+    }
+
+    private void registerNativeImageResources(
+            BuildProducer<NativeImageResourceBuildItem> resource,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> templates = discoverFreemarkerTemplates(camelFreemarkerConfig);
+        final List<String> nativeResources = new ArrayList<>(templates);
+        resource.produce(new NativeImageResourceBuildItem(nativeResources.toArray(new String[0])));
+    }
+
+    private List<String> discoverFreemarkerTemplates(
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> resources = new ArrayList<>();
+        try {
+            List<String> locations = new ArrayList<>(camelFreemarkerConfig.locations);
+            if (locations.isEmpty()) {
+                locations.add("freemarker/templates");
+            }
+
+            // Locations can be a comma separated list
+            for (String location : locations) {
+                // Strip any 'classpath:' protocol prefixes because they are assumed
+                // but not recognized by ClassLoader.getResources()
+                if (location != null && location.startsWith(CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL + ':')) {
 
 Review comment:
   Is a null location possible actually?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r389512742
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.freemarker.deployment;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.freemarker.CamelFreemarkerConfig;
+import org.apache.commons.io.FilenameUtils;
+import org.jboss.logging.Logger;
+
+class FreemarkerNativeImageProcessor {
+    private static final String CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL = "classpath";
+    private static final String JAR_APPLICATION_MIGRATIONS_PROTOCOL = "jar";
+    private static final String FILE_APPLICATION_MIGRATIONS_PROTOCOL = "file";
+
+    private static final Logger LOGGER = Logger.getLogger(FreemarkerNativeImageProcessor.class);
+
+    @BuildStep(loadsApplicationClasses = true)
+    void build(
+            BuildProducer<NativeImageResourceBuildItem> resourceProducer,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        registerNativeImageResources(resourceProducer, camelFreemarkerConfig);
+    }
+
+    private void registerNativeImageResources(
+            BuildProducer<NativeImageResourceBuildItem> resource,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> templates = discoverFreemarkerTemplates(camelFreemarkerConfig);
+        final List<String> nativeResources = new ArrayList<>(templates);
+        resource.produce(new NativeImageResourceBuildItem(nativeResources.toArray(new String[0])));
+    }
+
+    private List<String> discoverFreemarkerTemplates(
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        List<String> resources = new ArrayList<>();
+        try {
+            List<String> locations = new ArrayList<>(camelFreemarkerConfig.locations);
+            if (locations.isEmpty()) {
+                locations.add("freemarker/templates");
 
 Review comment:
   I've added the default location `freemarker/templates` to CamelFreemarkerConfig and also added some docs in `docs/modules/ROOT/pages/extensions/freemarker.adoc`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] ppalaga commented on issue #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
ppalaga commented on issue #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#issuecomment-598104198
 
 
   It would be cool if the extension could do most/all of the following tasks at build time:
   
   * Create a `freemarker.template.Configuration`
   * Parse/warmup the templates.
   
   That would make it truly quarkyfied!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387694745
 
 

 ##########
 File path: integration-tests/freemarker/src/main/resources/application.properties
 ##########
 @@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+#
+# Quarkus
+#
+quarkus.camel.freemarker.locations = org/apache/camel/component/freemarker
 
 Review comment:
   Only files with the extension `.ftl` will be included. You can see there is a filter for that [here](https://github.com/carlosthe19916/camel-quarkus/blob/7d45a783e5b27d341b6a07df49b34087f636dad3/extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java#L119)... I've also created 2 native images, the first one using `org/apache/camel/component/freemarker` and the second one using `myfreemarkerfolder` and the sizes are exactly the same (45.8 MB)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-quarkus] carlosthe19916 commented on a change in pull request #835: Camel-freemarker component

Posted by GitBox <gi...@apache.org>.
carlosthe19916 commented on a change in pull request #835: Camel-freemarker component
URL: https://github.com/apache/camel-quarkus/pull/835#discussion_r387698284
 
 

 ##########
 File path: extensions/freemarker/deployment/src/main/java/org/apache/camel/quarkus/component/freemarker/deployment/FreemarkerNativeImageProcessor.java
 ##########
 @@ -0,0 +1,136 @@
+/*
+ * 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.freemarker.deployment;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import org.apache.camel.quarkus.component.freemarker.CamelFreemarkerConfig;
+import org.apache.commons.io.FilenameUtils;
+import org.jboss.logging.Logger;
+
+class FreemarkerNativeImageProcessor {
+    private static final String CLASSPATH_APPLICATION_MIGRATIONS_PROTOCOL = "classpath";
+    private static final String JAR_APPLICATION_MIGRATIONS_PROTOCOL = "jar";
+    private static final String FILE_APPLICATION_MIGRATIONS_PROTOCOL = "file";
+
+    private static final Logger LOGGER = Logger.getLogger(FreemarkerNativeImageProcessor.class);
+
+    @BuildStep(loadsApplicationClasses = true)
+    void build(
+            BuildProducer<NativeImageResourceBuildItem> resourceProducer,
+            CamelFreemarkerConfig camelFreemarkerConfig) throws IOException, URISyntaxException {
+        registerNativeImageResources(resourceProducer, camelFreemarkerConfig);
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services