camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: The validate goal should only check Camel component json files and also skip connectors which is a facade
Date Tue, 07 Feb 2017 16:02:22 GMT
Repository: camel
Updated Branches:
  refs/heads/mention a419ffe7c -> 8c9d459d3


The validate goal should only check Camel component json files and also skip connectors which
is a facade


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/55e92a47
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/55e92a47
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/55e92a47

Branch: refs/heads/mention
Commit: 55e92a47086c6862b9e847331829fea09dad4b58
Parents: a419ffe
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Feb 7 16:56:20 2017 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Feb 7 16:56:20 2017 +0100

----------------------------------------------------------------------
 .../maven/packaging/ValidateComponentMojo.java  | 34 ++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/55e92a47/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
index 2c6b2c1..654bd0e 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
@@ -17,6 +17,9 @@
 package org.apache.camel.maven.packaging;
 
 import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -27,6 +30,7 @@ import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
 import org.sonatype.plexus.build.incremental.BuildContext;
 
+import static org.apache.camel.maven.packaging.PackageHelper.loadText;
 import static org.apache.camel.maven.packaging.StringHelper.indentCollection;
 import static org.apache.camel.maven.packaging.ValidateHelper.asName;
 import static org.apache.camel.maven.packaging.ValidateHelper.validate;
@@ -95,9 +99,8 @@ public class ValidateComponentMojo extends AbstractMojo {
         if (!validate) {
             getLog().info("Validation disabled");
         } else {
-
             final Set<File> jsonFiles = new TreeSet<File>();
-            PackageHelper.findJsonFiles(outDir, jsonFiles, new PackageHelper.CamelComponentsModelFilter());
+            PackageHelper.findJsonFiles(outDir, jsonFiles, new CamelComponentsFileFilter());
             boolean failed = false;
 
             for (File file : jsonFiles) {
@@ -139,4 +142,31 @@ public class ValidateComponentMojo extends AbstractMojo {
         }
     }
 
+    private class CamelComponentsFileFilter implements FileFilter {
+
+        @Override
+        public boolean accept(File pathname) {
+            if (pathname.isDirectory() && pathname.getName().equals("model")) {
+                // do not check the camel-core model packages as there is no components there
+                return false;
+            }
+
+            // skip connector metadata
+            if ("camel-connector-schema.json".equals(pathname.getName()) || "camel-component-schema.json".equals(pathname.getName()))
{
+                return false;
+            }
+
+            if (pathname.isFile() && pathname.getName().endsWith(".json")) {
+                // must be a components json file
+                try {
+                    String json = loadText(new FileInputStream(pathname));
+                    return json != null && json.contains("\"kind\": \"component\"");
+                } catch (IOException e) {
+                    // ignore
+                }
+            }
+            return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("component.properties"));
+        }
+    }
+
 }


Mime
View raw message