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 2014/11/17 15:15:36 UTC
camel git commit: CAMEL-7999: Output list of used labels in
camel-catalog build so we can keep on usage of labels.
Repository: camel
Updated Branches:
refs/heads/master 056f418a3 -> 7c6ac1ccd
CAMEL-7999: Output list of used labels in camel-catalog build so we can keep on usage of labels.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7c6ac1cc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7c6ac1cc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7c6ac1cc
Branch: refs/heads/master
Commit: 7c6ac1ccdfd16c3663425db250e3c1cd495d2899
Parents: 056f418
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 17 15:15:17 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 17 15:15:27 2014 +0100
----------------------------------------------------------------------
.../maven/packaging/PrepareCatalogMojo.java | 39 +++++++++++++++++++-
1 file changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7c6ac1cc/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 8c10a3d..de1b0a0 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
@@ -30,7 +30,12 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -49,6 +54,8 @@ public class PrepareCatalogMojo extends AbstractMojo {
public static final int BUFFER_SIZE = 128 * 1024;
+ private static final Pattern LABEL_PATTERN = Pattern.compile("\\\"label\\\":\\s\\\"([\\w,]+)\\\"");
+
/**
* The maven project.
*
@@ -103,6 +110,7 @@ public class PrepareCatalogMojo extends AbstractMojo {
Set<File> missingComponents = new LinkedHashSet<File>();
Set<File> missingLabels = new LinkedHashSet<File>();
Set<File> missingUriPaths = new LinkedHashSet<File>();
+ Map<String, Set<String>> usedLabels = new TreeMap<String, Set<String>>();
// find all json files in components and camel-core
if (componentsDir != null && componentsDir.isDirectory()) {
@@ -165,6 +173,22 @@ public class PrepareCatalogMojo extends AbstractMojo {
// just do a basic label check
if (text.contains("\"label\": \"\"")) {
missingLabels.add(file);
+ } else {
+ String name = asComponentName(file);
+ Matcher matcher = LABEL_PATTERN.matcher(text);
+ // grab the label, and remember it in the used labels
+ if (matcher.find()) {
+ String label = matcher.group(1);
+ String[] labels = label.split(",");
+ for (String s : labels) {
+ Set<String> components = usedLabels.get(s);
+ if (components == null) {
+ components = new TreeSet<String>();
+ usedLabels.put(s, components);
+ }
+ components.add(name);
+ }
+ }
}
if (!text.contains("\"kind\": \"path\"")) {
missingUriPaths.add(file);
@@ -203,10 +227,11 @@ public class PrepareCatalogMojo extends AbstractMojo {
throw new MojoFailureException("Error writing to file " + all);
}
- printReport(jsonFiles, duplicateJsonFiles, missingComponents, missingUriPaths, missingLabels);
+ printReport(jsonFiles, duplicateJsonFiles, missingComponents, missingUriPaths, missingLabels, usedLabels);
}
- private void printReport(Set<File> json, Set<File> duplicate, Set<File> missing, Set<File> missingUriPaths, Set<File> missingLabels) {
+ private void printReport(Set<File> json, Set<File> duplicate, Set<File> missing, Set<File> missingUriPaths,
+ Set<File> missingLabels, Map<String, Set<String>> usedLabels) {
getLog().info("================================================================================");
getLog().info("");
getLog().info("Camel component catalog report");
@@ -230,6 +255,16 @@ public class PrepareCatalogMojo extends AbstractMojo {
}
}
getLog().info("");
+ if (!usedLabels.isEmpty()) {
+ getLog().warn("\tUsed labels: " + usedLabels.size());
+ for (Map.Entry<String, Set<String>> entry : usedLabels.entrySet()) {
+ getLog().info("\t\t" + entry.getKey() + ":");
+ for (String name : entry.getValue()) {
+ getLog().info("\t\t\t" + name);
+ }
+ }
+ }
+ getLog().info("");
if (!missingUriPaths.isEmpty()) {
getLog().warn("\tMissing @UriPath detected: " + missingUriPaths.size());
for (File file : missingUriPaths) {