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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6473b89  Improve dev mode #314
     new a95a223  Merge pull request #327 from lburgazzoli/github-314
6473b89 is described below

commit 6473b8973f527337bd971d657eb62231aecb17bd
Author: lburgazzoli <lburgazz...@gmail.com>
AuthorDate: Wed Oct 23 19:02:31 2019 +0200

    Improve dev mode #314
---
 examples/pom.xml                                   |   1 +
 examples/timer-log-xml/README.adoc                 |  28 ++++++
 examples/timer-log-xml/pom.xml                     | 108 +++++++++++++++++++++
 .../src/main/java/org/acme/timer/package-info.java |  24 ++---
 .../src/main/resources/application.properties      |  33 +++++++
 .../src/main/resources/routes/my-routes.xml}       |  37 +++----
 .../quarkus/core/deployment/BuildProcessor.java    |   5 +-
 .../core/deployment/HotDeploymentProcessor.java    |  57 ++++++++++-
 8 files changed, 245 insertions(+), 48 deletions(-)

diff --git a/examples/pom.xml b/examples/pom.xml
index dac1d04..78cb5e2 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -34,6 +34,7 @@
     <modules>
         <module>observability</module>
         <module>timer-log</module>
+        <module>timer-log-xml</module>
         <module>rest-json</module>
     </modules>
 
diff --git a/examples/timer-log-xml/README.adoc 
b/examples/timer-log-xml/README.adoc
new file mode 100644
index 0000000..c02846b
--- /dev/null
+++ b/examples/timer-log-xml/README.adoc
@@ -0,0 +1,28 @@
+= timer-log-xml
+
+This is a basic hello world example that uses XML to set-up
+a Camel timer that triggers every second and prints to the
+log.
+
+To run it:
+
+[source,text]
+----
+$ mvn clean compile quarkus:dev -DnoDeps
+----
+This compiles the project and starts the Quarkus tooling in the 
https://quarkus.io/guides/maven-tooling#development-mode[develpment mode].
+Then look at the log output in the console. As we run the example
+in Quarkus Dev Mode, you can edit the source code and have live updates.
+For example try to change the logging output to be `Bye XML`.
+
+== Native build
+
+To build as native:
+
+[source,text]
+----
+$ mvn package -Pnative
+----
+
+This requires having GraalVM and other tools installed.
+See the https://quarkus.io/guides/building-native-image-guide[Quarkus Native 
Guide] for details.
diff --git a/examples/timer-log-xml/pom.xml b/examples/timer-log-xml/pom.xml
new file mode 100644
index 0000000..23e388a
--- /dev/null
+++ b/examples/timer-log-xml/pom.xml
@@ -0,0 +1,108 @@
+<?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";>
+    <parent>
+        <groupId>org.apache.camel.quarkus</groupId>
+        <artifactId>camel-quarkus-bom</artifactId>
+        <version>0.2.1-SNAPSHOT</version>
+        <relativePath>../../poms/bom/pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>camel-quarkus-examples-timer-log-xml</artifactId>
+    <name>Camel Quarkus :: Examples :: Timer Log XML</name>
+    <description>Camel Quarkus Example :: Timer to Log XML</description>
+
+    <properties>
+        <!-- to use docker build instead of native
+        <native-image.docker-build>true</native-image.docker-build>
+        <native-image.container-runtime>docker</native-image.container-runtime>
+        -->
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-timer</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-log</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-core-xml</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>io.quarkus</groupId>
+                <artifactId>quarkus-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>build</id>
+                        <goals>
+                            <goal>build</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <workingDir>${project.basedir}</workingDir>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>native</id>
+            <activation>
+                <property>
+                    <name>native</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>io.quarkus</groupId>
+                        <artifactId>quarkus-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>native-image</id>
+                                <goals>
+                                    <goal>native-image</goal>
+                                </goals>
+                                <configuration>
+                                    <enableServer>false</enableServer>
+                                    <cleanupServer>true</cleanupServer>
+                                    <disableReports>true</disableReports>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>
diff --git 
a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/HotDeploymentProcessor.java
 b/examples/timer-log-xml/src/main/java/org/acme/timer/package-info.java
similarity index 58%
copy from 
extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/HotDeploymentProcessor.java
copy to examples/timer-log-xml/src/main/java/org/acme/timer/package-info.java
index 60f5b6a..58fa320 100644
--- 
a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/HotDeploymentProcessor.java
+++ b/examples/timer-log-xml/src/main/java/org/acme/timer/package-info.java
@@ -1,31 +1,19 @@
-/*
+/**
  * 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
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * 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.core.deployment;
+package org.acme.timer;
 
-import java.util.Collections;
-import java.util.List;
-
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem;
-import org.apache.camel.quarkus.core.CamelConfig;
-
-class HotDeploymentProcessor {
-    @BuildStep
-    List<HotDeploymentWatchedFileBuildItem> configFile(CamelConfig.Runtime 
config) {
-        return Collections.emptyList();
-    }
-}
+// Added to avoid quarkus-maven-plugin warning about empty source tree
\ No newline at end of file
diff --git a/examples/timer-log-xml/src/main/resources/application.properties 
b/examples/timer-log-xml/src/main/resources/application.properties
new file mode 100644
index 0000000..b5d428d
--- /dev/null
+++ b/examples/timer-log-xml/src/main/resources/application.properties
@@ -0,0 +1,33 @@
+## ---------------------------------------------------------------------------
+## 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.log.file.enable = false
+quarkus.ssl.native=true
+
+quarkus.log.category."org.apache.camel.main".level = DEBUG
+
+#
+# Camel
+#
+camel.context.name = quarkus-camel-example-timer-log-xml
+
+#
+# Camel Main
+#
+camel.main.xml-routes = file:src/main/resources/routes/my-routes.xml
diff --git a/examples/pom.xml 
b/examples/timer-log-xml/src/main/resources/routes/my-routes.xml
similarity index 54%
copy from examples/pom.xml
copy to examples/timer-log-xml/src/main/resources/routes/my-routes.xml
index dac1d04..550b49b 100644
--- a/examples/pom.xml
+++ b/examples/timer-log-xml/src/main/resources/routes/my-routes.xml
@@ -1,40 +1,27 @@
 <?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-parent</artifactId>
-        <version>0.2.1-SNAPSHOT</version>
-    </parent>
-
-    <artifactId>camel-quarkus-examples</artifactId>
-    <packaging>pom</packaging>
-
-    <name>Camel Quarkus :: Examples</name>
-
-    <modules>
-        <module>observability</module>
-        <module>timer-log</module>
-        <module>rest-json</module>
-    </modules>
-
-</project>
+<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+        xmlns="http://camel.apache.org/schema/spring";
+        xsi:schemaLocation="
+            http://camel.apache.org/schema/spring
+            http://camel.apache.org/schema/spring/camel-spring.xsd";>
+
+    <route id="xml-route">
+        <from uri="timer:from-xml?period=1s"/>
+        <log message="Hello XML!"/>
+    </route>
+
+</routes>
\ No newline at end of file
diff --git 
a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
 
b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
index a0839b0..33975db 100644
--- 
a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
+++ 
b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java
@@ -77,7 +77,10 @@ class BuildProcessor {
                     // to the camel context directly by extension so it does 
not make sense to
                     // instantiate them in this phase.
                     //
-                    boolean blacklisted = 
si.path.endsWith("reactive-executor") || si.path.endsWith("platform-http");
+                    boolean blacklisted = si.path.endsWith("reactive-executor")
+                        || si.path.endsWith("platform-http")
+                        || si.path.endsWith("properties-component-factory");
+
                     if (blacklisted) {
                         LOGGER.debug("Ignore service: {}", si);
                     }
diff --git 
a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/HotDeploymentProcessor.java
 
b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/HotDeploymentProcessor.java
index 60f5b6a..36dc821 100644
--- 
a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/HotDeploymentProcessor.java
+++ 
b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/HotDeploymentProcessor.java
@@ -16,16 +16,65 @@
  */
 package org.apache.camel.quarkus.core.deployment;
 
-import java.util.Collections;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import io.quarkus.deployment.annotations.BuildStep;
 import io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem;
-import org.apache.camel.quarkus.core.CamelConfig;
+import org.eclipse.microprofile.config.ConfigProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+/*
+ * camel-main does not yet support filtering with pattern/glob so
+ * each entry of camel.main.xml-[routes|rests] is be a path thus
+ * can be safely added to the list of files to watch to trigger
+ * hot deployment.
+ *
+ * See https://issues.apache.org/jira/browse/CAMEL-14100
+ */
 class HotDeploymentProcessor {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(HotDeploymentProcessor.class);
+    private static final String[] EMPTY_STRING_ARRAY = new String[0];
+    private static final String FILE_PREFIX = "file:";
+
+    @BuildStep
+    List<HotDeploymentWatchedFileBuildItem> xmlRoutes() {
+        return locations("camel.main.xml-routes");
+    }
+
     @BuildStep
-    List<HotDeploymentWatchedFileBuildItem> configFile(CamelConfig.Runtime 
config) {
-        return Collections.emptyList();
+    List<HotDeploymentWatchedFileBuildItem> xmlRests() {
+        return locations("camel.main.xml-rests");
+    }
+
+    private static List<HotDeploymentWatchedFileBuildItem> locations(String 
property) {
+        String[] locations = ConfigProvider.getConfig()
+            .getOptionalValue(property, String[].class)
+            .orElse(EMPTY_STRING_ARRAY);
+
+        List<HotDeploymentWatchedFileBuildItem> items = Stream.of(locations)
+            .filter(location -> location.startsWith(FILE_PREFIX))
+            .map(location -> location.substring(FILE_PREFIX.length()))
+            .distinct()
+            .map(Paths::get)
+            .filter(Files::exists)
+            .map(Path::toAbsolutePath)
+            .map(Path::toString)
+            .map(HotDeploymentWatchedFileBuildItem::new)
+            .collect(Collectors.toList());
+
+        if (!items.isEmpty()) {
+            LOGGER.info("HotDeployment files ({}):", property);
+            for (HotDeploymentWatchedFileBuildItem item : items) {
+                LOGGER.info("- {}", item.getLocation());
+            }
+        }
+
+        return items;
     }
 }

Reply via email to