You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/10/30 12:13:03 UTC

[camel-quarkus] 03/06: Support new yaml format to extension meatdata validation script

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

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

commit 90ed33c07925bc00875225edeb0fcd6bd17125e1
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed Oct 30 07:17:23 2019 +0100

    Support new yaml format to extension meatdata validation script
---
 build/scripts/validate-extension-metadata.groovy   | 45 ++++++++++++++--------
 .../main/resources/META-INF/quarkus-extension.json | 10 -----
 .../main/resources/META-INF/quarkus-extension.yaml |  8 ++++
 extensions/pom.xml                                 |  7 ++++
 pom.xml                                            |  3 +-
 poms/bom/pom.xml                                   |  5 +++
 6 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/build/scripts/validate-extension-metadata.groovy b/build/scripts/validate-extension-metadata.groovy
index 89db0ee..e3d0202 100644
--- a/build/scripts/validate-extension-metadata.groovy
+++ b/build/scripts/validate-extension-metadata.groovy
@@ -16,36 +16,47 @@
  */
 
 import groovy.io.FileType
-import groovy.json.JsonSlurper
 
-final String quarkusExtensionJsonRelPath = 'runtime/src/main/resources/META-INF/quarkus-extension.json'
+final String quarkusExtensionRelPath = 'runtime/src/main/resources/META-INF/quarkus-extension.yaml'
 final List<String> messages = []
-project.basedir.eachFile FileType.DIRECTORIES, { extensionParentDir ->
-    if (new File(extensionParentDir, 'runtime/pom.xml').exists()) {
-        final File extensionJsonFile = new File(extensionParentDir, quarkusExtensionJsonRelPath)
-        final String shortName = extensionParentDir.getName()
-        final String shortPath = shortName + '/' + quarkusExtensionJsonRelPath
-        final boolean internal = (shortName.startsWith('core') || shortName.endsWith('-common'))
-        if (!extensionJsonFile.exists()) {
+
+project.basedir.eachFile(FileType.DIRECTORIES) {
+    if (new File(it, 'runtime/pom.xml').exists()) {
+        final File extensionFile = new File(it, quarkusExtensionRelPath)
+        final String shortPath = it.name + '/' + quarkusExtensionRelPath
+
+        if (!extensionFile.exists()) {
             messages.add(shortPath + ' is missing')
         } else {
-            final Map extensionJson = new JsonSlurper().parseText(extensionJsonFile.getText("UTF-8"))
-            if (extensionJson['name'] == null) {
+            def yaml = new org.yaml.snakeyaml.Yaml()
+            def descriptor = yaml.load(extensionFile.getText("UTF-8"))
+
+            if (!descriptor.name) {
                 messages.add(shortPath + ' must contain name')
             }
-            if (!(extensionJson['labels'] instanceof List)
-                    || !extensionJson['labels'].contains("camel")
-                    || !extensionJson['labels'].contains("integration")) {
-                messages.add(shortPath + ' must contain a list of labels with at least "integration" and "camel" labels present')
+
+            // metadata
+            if (!descriptor.metadata) {
+                messages.add(shortPath + ' must contain metadata section')
+                return
             }
-            if (extensionJson['guide'] == null || !"https://quarkus.io/guides/camel".equals(extensionJson['guide'])) {
+            if (!descriptor.metadata.guide?.equals('https://quarkus.io/guides/camel')) {
                 messages.add(shortPath + ' must contain a link to the guide https://quarkus.io/guides/camel')
             }
+
+            // keywords
+            if (!descriptor.metadata.keywords) {
+                messages.add(shortPath + ' must contain keywords section')
+                return
+            }
+            if (!descriptor.metadata.keywords?.contains('camel')) {
+                messages.add(shortPath + ' must contain a list of keywords with at least "camel" present')
+            }
         }
     }
 }
 
 if (!messages.isEmpty()) {
     throw new RuntimeException("\nQuarkus extension metadata validation failures:\n\n    "
-            + messages.join("\n    "))
+            + messages.join('\n    '))
 }
\ No newline at end of file
diff --git a/extensions/pdf/runtime/src/main/resources/META-INF/quarkus-extension.json b/extensions/pdf/runtime/src/main/resources/META-INF/quarkus-extension.json
deleted file mode 100644
index 1aca726..0000000
--- a/extensions/pdf/runtime/src/main/resources/META-INF/quarkus-extension.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
-  "name": "Camel Quarkus PDF",
-  "labels": [
-    "integration",
-    "camel",
-    "pdf"
-  ],
-  "guide": "https://quarkus.io/guides/camel"
-}
-
diff --git a/extensions/pdf/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/pdf/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000..14fc389
--- /dev/null
+++ b/extensions/pdf/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,8 @@
+---
+name: "Camel Quarkus PDF"
+metadata:
+  keywords:
+  - "integration"
+  - "camel"
+  - "pdf"
+  guide: "https://quarkus.io/guides/camel"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 2ba2bbc..c899992 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -93,6 +93,13 @@
                         </configuration>
                     </execution>
                 </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.yaml</groupId>
+                        <artifactId>snakeyaml</artifactId>
+                        <version>${snakeyaml.version}</version>
+                    </dependency>
+                </dependencies>
             </plugin>
             <plugin>
                 <groupId>io.quarkus</groupId>
diff --git a/pom.xml b/pom.xml
index a256df9..3b18e0d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,6 +45,7 @@
         <quarkus.version>0.27.0</quarkus.version>
         <jetty.version>9.4.18.v20190429</jetty.version>
         <xstream.version>1.4.11</xstream.version>
+        <snakeyaml.version>1.25</snakeyaml.version>
 
         <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
         <maven.compiler.target>1.8</maven.compiler.target>
@@ -448,7 +449,7 @@
         <profile>
             <id>oss-snapshots</id>
             <activation>
-                <activeByDefault>true</activeByDefault>
+                <activeByDefault>false</activeByDefault>
             </activation>
             <repositories>
                 <repository>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 3a4611d..385aa39 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -515,6 +515,11 @@
                 <artifactId>camel-quarkus-pdf</artifactId>
                 <version>${camel-quarkus.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.yaml</groupId>
+                <artifactId>snakeyaml</artifactId>
+                <version>${snakeyaml.version}</version>
+            </dependency>
 
         </dependencies>
     </dependencyManagement>