You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/02/07 17:22:45 UTC
[7/8] camel git commit: The validate goal should only check Camel
component json files and also skip connectors which is a facade
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/90e33ba7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/90e33ba7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/90e33ba7
Branch: refs/heads/master
Commit: 90e33ba7bfb876c727ebb0837bf6cbbc6c13675b
Parents: 5718035
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Feb 7 16:56:20 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 7 18:22:26 2017 +0100
----------------------------------------------------------------------
.../maven/packaging/ValidateComponentMojo.java | 34 ++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/90e33ba7/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"));
+ }
+ }
+
}