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 2015/09/14 11:14:20 UTC
camel git commit: CAMEL-9131: Add to catalog report which label we
categorize for options.
Repository: camel
Updated Branches:
refs/heads/master 2b7055f7e -> 6df2fb66c
CAMEL-9131: Add to catalog report which label we categorize for options.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6df2fb66
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6df2fb66
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6df2fb66
Branch: refs/heads/master
Commit: 6df2fb66c9c8aa48518c3c8b85ad45d21a6e97af
Parents: 2b7055f
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 14 11:15:13 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 14 11:15:32 2015 +0200
----------------------------------------------------------------------
.../maven/packaging/PrepareCatalogMojo.java | 56 ++++++++++++++++----
1 file changed, 47 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6df2fb66/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java
index 337c1bf..f89b2a5 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogMojo.java
@@ -285,7 +285,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
Set<File> duplicateJsonFiles = new TreeSet<File>();
Set<File> componentFiles = new TreeSet<File>();
Set<File> missingComponents = new TreeSet<File>();
- Map<String, Set<String>> usedLabels = new TreeMap<String, Set<String>>();
+ Map<String, Set<String>> usedComponentLabels = new TreeMap<String, Set<String>>();
+ Set<String> usedOptionLabels = new TreeSet<String>();
// find all json files in components and camel-core
if (componentsDir != null && componentsDir.isDirectory()) {
@@ -351,7 +352,7 @@ public class PrepareCatalogMojo extends AbstractMojo {
throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
}
- // check if we have a label as we want the components to include labels
+ // check if we have a component label as we want the components to include labels
try {
String text = loadText(new FileInputStream(file));
String name = asComponentName(file);
@@ -361,14 +362,43 @@ public class PrepareCatalogMojo extends AbstractMojo {
String label = matcher.group(1);
String[] labels = label.split(",");
for (String s : labels) {
- Set<String> components = usedLabels.get(s);
+ Set<String> components = usedComponentLabels.get(s);
if (components == null) {
components = new TreeSet<String>();
- usedLabels.put(s, components);
+ usedComponentLabels.put(s, components);
}
components.add(name);
}
}
+
+ // check all the component options and grab the label(s) they use
+ List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("componentProperties", text, true);
+ for (Map<String, String> row : rows) {
+ String label = row.get("label");
+
+ if (label != null && !label.isEmpty()) {
+ String[] parts = label.split(",");
+ for (String part : parts) {
+ usedOptionLabels.add(part);
+ }
+ break;
+ }
+ }
+
+ // check all the endpoint options and grab the label(s) they use
+ rows = JSonSchemaHelper.parseJsonSchema("properties", text, true);
+ for (Map<String, String> row : rows) {
+ String label = row.get("label");
+
+ if (label != null && !label.isEmpty()) {
+ String[] parts = label.split(",");
+ for (String part : parts) {
+ usedOptionLabels.add(part);
+ }
+ break;
+ }
+ }
+
} catch (IOException e) {
// ignore
}
@@ -401,7 +431,7 @@ public class PrepareCatalogMojo extends AbstractMojo {
throw new MojoFailureException("Error writing to file " + all);
}
- printComponentsReport(jsonFiles, duplicateJsonFiles, missingComponents, usedLabels);
+ printComponentsReport(jsonFiles, duplicateJsonFiles, missingComponents, usedComponentLabels, usedOptionLabels);
}
protected void executeDataFormats() throws MojoExecutionException, MojoFailureException {
@@ -687,7 +717,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
getLog().info("================================================================================");
}
- private void printComponentsReport(Set<File> json, Set<File> duplicate, Set<File> missing, Map<String, Set<String>> usedLabels) {
+ private void printComponentsReport(Set<File> json, Set<File> duplicate, Set<File> missing, Map<String,
+ Set<String>> usedComponentLabels, Set<String> usedOptionsLabels) {
getLog().info("================================================================================");
getLog().info("");
getLog().info("Camel component catalog report");
@@ -703,16 +734,23 @@ public class PrepareCatalogMojo extends AbstractMojo {
getLog().warn("\t\t" + asComponentName(file));
}
}
- if (!usedLabels.isEmpty()) {
+ if (!usedComponentLabels.isEmpty()) {
getLog().info("");
- getLog().info("\tUsed labels: " + usedLabels.size());
- for (Map.Entry<String, Set<String>> entry : usedLabels.entrySet()) {
+ getLog().info("\tUsed component labels: " + usedComponentLabels.size());
+ for (Map.Entry<String, Set<String>> entry : usedComponentLabels.entrySet()) {
getLog().info("\t\t" + entry.getKey() + ":");
for (String name : entry.getValue()) {
getLog().info("\t\t\t" + name);
}
}
}
+ if (!usedOptionsLabels.isEmpty()) {
+ getLog().info("");
+ getLog().info("\tUsed component/endpoint options labels: " + usedOptionsLabels.size());
+ for (String name : usedOptionsLabels) {
+ getLog().info("\t\t\t" + name);
+ }
+ }
if (!missing.isEmpty()) {
getLog().info("");
getLog().warn("\tMissing components detected: " + missing.size());