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/21 13:42:51 UTC
camel git commit: CAMEL-9131: Report components which has many
unlabelled endpoint options in the catalog.
Repository: camel
Updated Branches:
refs/heads/master 46d913a81 -> 2a49466d3
CAMEL-9131: Report components which has many unlabelled endpoint options in the catalog.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2a49466d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2a49466d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2a49466d
Branch: refs/heads/master
Commit: 2a49466d32b1a210648c44a400cd967e70ce0c27
Parents: 46d913a
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Sep 21 13:44:18 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 21 13:44:18 2015 +0200
----------------------------------------------------------------------
.../maven/packaging/PrepareCatalogMojo.java | 21 ++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2a49466d/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 c73ebab9..a691771 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
@@ -52,6 +52,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
private static final Pattern LABEL_PATTERN = Pattern.compile("\\\"label\\\":\\s\\\"([\\w,]+)\\\"");
+ private static final int UNUSED_LABELS_WARN = 20;
+
/**
* The maven project.
*
@@ -287,6 +289,7 @@ public class PrepareCatalogMojo extends AbstractMojo {
Set<File> missingComponents = new TreeSet<File>();
Map<String, Set<String>> usedComponentLabels = new TreeMap<String, Set<String>>();
Set<String> usedOptionLabels = new TreeSet<String>();
+ Set<String> unlabeledOptions = new TreeSet<String>();
// find all json files in components and camel-core
if (componentsDir != null && componentsDir.isDirectory()) {
@@ -385,6 +388,7 @@ public class PrepareCatalogMojo extends AbstractMojo {
}
// check all the endpoint options and grab the label(s) they use
+ int unused = 0;
rows = JSonSchemaHelper.parseJsonSchema("properties", text, true);
for (Map<String, String> row : rows) {
String label = row.get("label");
@@ -394,9 +398,15 @@ public class PrepareCatalogMojo extends AbstractMojo {
for (String part : parts) {
usedOptionLabels.add(part);
}
+ } else {
+ unused++;
}
}
+ if (unused >= UNUSED_LABELS_WARN) {
+ unlabeledOptions.add(name);
+ }
+
} catch (IOException e) {
// ignore
}
@@ -429,7 +439,7 @@ public class PrepareCatalogMojo extends AbstractMojo {
throw new MojoFailureException("Error writing to file " + all);
}
- printComponentsReport(jsonFiles, duplicateJsonFiles, missingComponents, usedComponentLabels, usedOptionLabels);
+ printComponentsReport(jsonFiles, duplicateJsonFiles, missingComponents, usedComponentLabels, usedOptionLabels, unlabeledOptions);
}
protected void executeDataFormats() throws MojoExecutionException, MojoFailureException {
@@ -716,7 +726,7 @@ public class PrepareCatalogMojo extends AbstractMojo {
}
private void printComponentsReport(Set<File> json, Set<File> duplicate, Set<File> missing, Map<String,
- Set<String>> usedComponentLabels, Set<String> usedOptionsLabels) {
+ Set<String>> usedComponentLabels, Set<String> usedOptionsLabels, Set<String> unusedLabels) {
getLog().info("================================================================================");
getLog().info("");
getLog().info("Camel component catalog report");
@@ -749,6 +759,13 @@ public class PrepareCatalogMojo extends AbstractMojo {
getLog().info("\t\t\t" + name);
}
}
+ if (!unusedLabels.isEmpty()) {
+ getLog().info("");
+ getLog().info("\tComponent with more than " + UNUSED_LABELS_WARN + " unlabelled options: " + unusedLabels.size());
+ for (String name : unusedLabels) {
+ getLog().info("\t\t\t" + name);
+ }
+ }
if (!missing.isEmpty()) {
getLog().info("");
getLog().warn("\tMissing components detected: " + missing.size());