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

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


The following commit(s) were added to refs/heads/main by this push:
     new 399d68c  Added a first version of Camel-Kamelets-Bom
399d68c is described below

commit 399d68c98f6c8f147498a395241a039c362418e3
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Wed Jan 5 18:01:31 2022 +0100

    Added a first version of Camel-Kamelets-Bom
---
 kamelets/pulsar-sink.kamelet.yaml                  |  0
 kamelets/pulsar-source.kamelet.yaml                |  0
 kamelets/redis-sink.kamelet.yaml                   |  2 +-
 kamelets/wttrin-source.kamelet.yaml                |  0
 library/camel-kamelets-bom/pom.xml                 | 45 +++++++++++++++
 .../resources/kamelets/redis-sink.kamelet.yaml     |  2 +-
 pom.xml                                            | 30 ++++++++++
 script/version/UpdateDepsVersionKamelets.groovy    | 64 ++++++++++++++++++++++
 8 files changed, 141 insertions(+), 2 deletions(-)

diff --git a/kamelets/pulsar-sink.kamelet.yaml 
b/kamelets/pulsar-sink.kamelet.yaml
old mode 100755
new mode 100644
diff --git a/kamelets/pulsar-source.kamelet.yaml 
b/kamelets/pulsar-source.kamelet.yaml
old mode 100755
new mode 100644
diff --git a/kamelets/redis-sink.kamelet.yaml b/kamelets/redis-sink.kamelet.yaml
index 017dcf9..0fc863b 100644
--- a/kamelets/redis-sink.kamelet.yaml
+++ b/kamelets/redis-sink.kamelet.yaml
@@ -126,4 +126,4 @@ spec:
           parameters:
             command: "{{command}}"
             channels: "{{channels}}"
-            serializer: "#class:{{serializer}}"
\ No newline at end of file
+            serializer: "#class:{{serializer}}"
diff --git a/kamelets/wttrin-source.kamelet.yaml 
b/kamelets/wttrin-source.kamelet.yaml
old mode 100755
new mode 100644
diff --git a/library/camel-kamelets-bom/pom.xml 
b/library/camel-kamelets-bom/pom.xml
new file mode 100644
index 0000000..2f30db1
--- /dev/null
+++ b/library/camel-kamelets-bom/pom.xml
@@ -0,0 +1,45 @@
+<?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/maven-v4_0_0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel.kamelets</groupId>
+        <artifactId>camel-kamelets-parent</artifactId>
+        <version>main-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>camel-kamelets-bom</artifactId>
+    <packaging>pom</packaging>
+
+    <name>Camel Kamelets BOM</name>
+    <description>Camel Kamelets BOM</description>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-dbcp2</artifactId>
+        <version>${version.org.apache.commons.commons-dbcp2}</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+</project>
diff --git 
a/library/camel-kamelets/src/main/resources/kamelets/redis-sink.kamelet.yaml 
b/library/camel-kamelets/src/main/resources/kamelets/redis-sink.kamelet.yaml
index 017dcf9..0fc863b 100644
--- a/library/camel-kamelets/src/main/resources/kamelets/redis-sink.kamelet.yaml
+++ b/library/camel-kamelets/src/main/resources/kamelets/redis-sink.kamelet.yaml
@@ -126,4 +126,4 @@ spec:
           parameters:
             command: "{{command}}"
             channels: "{{channels}}"
-            serializer: "#class:{{serializer}}"
\ No newline at end of file
+            serializer: "#class:{{serializer}}"
diff --git a/pom.xml b/pom.xml
index 0478dde..14234f6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,7 @@
         <module>library/camel-kamelets</module>
         <module>library/camel-kamelets-catalog</module>
         <module>library/camel-kamelets-utils</module>
+        <module>library/camel-kamelets-bom</module>
     </modules>
 
     <properties>
@@ -53,6 +54,7 @@
         <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
         
<maven-checksum-maven-plugin.version>1.11</maven-checksum-maven-plugin.version>
         <maven-antrun-plugin.version>3.0.0</maven-antrun-plugin.version>
+        <maven-groovy-plugin.version>2.1.1</maven-groovy-plugin.version>
         <apache-rat-plugin.version>0.13</apache-rat-plugin.version>
 
         <camel.version>3.14.0</camel.version>
@@ -63,6 +65,8 @@
         <commons.io.version>2.11.0</commons.io.version>
         <junit.jupiter.version>5.8.1</junit.jupiter.version>
         <classgraph.version>4.8.138</classgraph.version>
+
+        
<version.org.apache.commons.commons-dbcp2>2.8.0</version.org.apache.commons.commons-dbcp2>
     </properties>
 
     <developers>
@@ -278,6 +282,32 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.gmaven</groupId>
+                <artifactId>groovy-maven-plugin</artifactId>
+                <version>${maven-groovy-plugin.version}</version>
+                <inherited>false</inherited>
+                <executions>
+                    <execution>
+                        <id>UpdateKamelets</id>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>execute</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                <scriptpath>
+                    <path>${project.basedir}/script/version</path>
+                </scriptpath>
+                    <source>
+                    import UpdateDepsVersionKamelets
+                    new 
UpdateDepsVersionKamelets().updateKameletDirectory("./kamelets/",  [
+                        "version.org.apache.commons.commons-dbcp2": 
"${version.org.apache.commons.commons-dbcp2}"
+                    ])
+                    </source>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
     <profiles>
diff --git a/script/version/UpdateDepsVersionKamelets.groovy 
b/script/version/UpdateDepsVersionKamelets.groovy
new file mode 100644
index 0000000..52114c0
--- /dev/null
+++ b/script/version/UpdateDepsVersionKamelets.groovy
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+import java.io.File
+import java.nio.file.Files
+import java.nio.file.Paths
+import java.nio.file.StandardCopyOption
+import java.util.regex.Pattern
+import java.util.Map
+import java.util.Properties
+
+def updateKameletDirectory(String directoryName, Map properties) {
+    println "#### Update Dependencies Version Kamelets BEGIN"
+
+    // compute version replacement
+    def libVersions = [:]
+    properties.each {prop -> 
+        if (prop.key.startsWith("version.")) {
+            String ga = prop.key.substring("version.".length())
+            int split = ga.lastIndexOf(".")
+            if (split > 0 && split < ga.length() - 1) {
+                String groupId = ga.substring(0, split)
+                String artifactId = ga.substring(split + 1)
+                String libSelector = "mvn:" + Pattern.quote(groupId) + ":" + 
Pattern.quote(artifactId) + ":[A-Za-z0-9-.]+"
+                String libNewVersion = "mvn:" + groupId + ":" + artifactId + 
":" + prop.value
+                libVersions[libSelector] = libNewVersion
+                println "#### Going to replace in all files \"${libSelector}\" 
with \"${libNewVersion}\""
+            }
+        }
+    }
+
+    File directory = new File(directoryName)
+    File[] files = directory.listFiles()
+
+    for (File f in files) {
+        if (f.getName().endsWith(".kamelet.yaml")) {
+            String kameletFile = f.getName() 
+            new File( kameletFile + ".bak" ).withWriter { w ->
+                new File( directoryName + kameletFile ).eachLine { line ->
+                    libVersions.each { line = line.replaceAll(it.key, it.value)
+                                     w << line +  
System.getProperty("line.separator") }
+                }
+            }
+            Files.copy(Paths.get(kameletFile + ".bak"), 
Paths.get(directoryName + kameletFile), StandardCopyOption.REPLACE_EXISTING)
+            boolean deleted = new File(kameletFile + ".bak").delete()
+        }
+    }
+
+    println "#### Update Dependencies Version Kamelets END"
+}

Reply via email to