Followup #278 Assert that quarkus-extension.json exists for each
extension
diff --git a/build/scripts/validate-extension-metadata.groovy b/build/scripts/validate-extension-metadata.groovy
new file mode 100644
index 0000000..89db0ee
--- /dev/null
+++ b/build/scripts/validate-extension-metadata.groovy
@@ -0,0 +1,51 @@
+/*
+ * 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 groovy.io.FileType
+import groovy.json.JsonSlurper
+
+final String quarkusExtensionJsonRelPath = 'runtime/src/main/resources/META-INF/quarkus-extension.json'
+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()) {
+ messages.add(shortPath + ' is missing')
+ } else {
+ final Map extensionJson = new JsonSlurper().parseText(extensionJsonFile.getText("UTF-8"))
+ if (extensionJson['name'] == null) {
+ 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')
+ }
+ if (extensionJson['guide'] == null || !"https://quarkus.io/guides/camel".equals(extensionJson['guide'])) {
+ messages.add(shortPath + ' must contain a link to the guide https://quarkus.io/guides/camel')
+ }
+ }
+ }
+}
+
+if (!messages.isEmpty()) {
+ throw new RuntimeException("\nQuarkus extension metadata validation failures:\n\n "
+ + messages.join("\n "))
+}
\ No newline at end of file
diff --git a/extensions/pom.xml b/extensions/pom.xml
index cd87a41..f2e2049 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -72,6 +72,23 @@
<build>
<plugins>
<plugin>
+ <groupId>org.codehaus.gmaven</groupId>
+ <artifactId>groovy-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>validate-extension-metadata</id>
+ <inherited>false</inherited>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <phase>verify</phase>
+ <configuration>
+ <source>file:///${project.basedir}/../build/scripts/validate-extension-metadata.groovy</source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<inherited>false</inherited>