[camel] branch master updated: CAMEL-13981: logging in the annotation processor

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: CAMEL-13981: logging in the annotation processor

zregvart
This is an automated email from the ASF dual-hosted git repository.

zregvart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 7c59319  CAMEL-13981: logging in the annotation processor
7c59319 is described below

commit 7c593199ebbec2ff4f17165c667e457362213ff9
Author: Zoran Regvart <[hidden email]>
AuthorDate: Mon Sep 16 15:59:49 2019 +0200

    CAMEL-13981: logging in the annotation processor
   
    This adds logging to the ModelAnnotationProcessor that ends up invoking
    the CoreEipAnnotationProcessorHelper that should generate the
    DefinitionPropertiesPlaceholderProviderHelper class.
   
    The only way to see those messages is if their level is set to WARNING,
    so this might trigger some tools to consider these as warnings.
   
    With MCOMPILER-224[1] we should be also able to see the NOTICE output,
    this is not the case in practice.
   
    [1] https://issues.apache.org/jira/browse/MCOMPILER-224
---
 parent/pom.xml                                            |  2 ++
 .../camel/tools/apt/CoreEipAnnotationProcessorHelper.java |  2 ++
 .../apache/camel/tools/apt/ModelAnnotationProcessor.java  | 15 ++++++++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index 1f0f245..db5f000 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -5407,6 +5407,8 @@
                         <target>${jdk.version}</target>
                         <maxmem>512M</maxmem>
                         <fork>${compiler.fork}</fork>
+                        <showDeprecation>true</showDeprecation>
+                        <showWarnings>true</showWarnings>
                         <compilerArgs>
                             <!-- SB2 actuator endpoint requires MethodParameter metadata -->
                             <arg>-parameters</arg>
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessorHelper.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessorHelper.java
index 06b2d79..fa0be2b 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessorHelper.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/CoreEipAnnotationProcessorHelper.java
@@ -34,6 +34,7 @@ import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.ElementFilter;
 import javax.lang.model.util.Elements;
+import javax.tools.Diagnostic.Kind;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementRef;
@@ -131,6 +132,7 @@ public class CoreEipAnnotationProcessorHelper {
         // if last then generate source code for helper that contains all the generated property placeholder providers
         // (this allows fast property placeholders at runtime without reflection overhead)
         if (last) {
+            processingEnv.getMessager().printMessage(Kind.WARNING, String.format("Generating placeholder definitions helper for %d definitions", propertyPlaceholderDefinitions.size()));
             generatePropertyPlaceholderDefinitionsHelper(processingEnv, roundEnv, propertyPlaceholderDefinitions);
         }
     }
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/ModelAnnotationProcessor.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/ModelAnnotationProcessor.java
index 5d1e380..d312ca8 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/ModelAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/ModelAnnotationProcessor.java
@@ -16,17 +16,18 @@
  */
 package org.apache.camel.tools.apt;
 
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
+
+import javax.annotation.processing.Messager;
 import javax.annotation.processing.RoundEnvironment;
 import javax.annotation.processing.SupportedAnnotationTypes;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import static org.apache.camel.tools.apt.helper.Strings.canonicalClassName;
@@ -44,6 +45,10 @@ public class ModelAnnotationProcessor extends AbstractCamelAnnotationProcessor {
     protected void doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws Exception {
         Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(XmlRootElement.class);
 
+        final Messager messager = processingEnv.getMessager();
+
+        messager.printMessage(Kind.WARNING, String.format("Found %d elements annotated with XmlRootElement", elements.size()));
+
         Set<? extends Element> coreElements = elements.stream()
                 .filter(new Predicate<Element>() {
                     @Override
@@ -58,6 +63,8 @@ public class ModelAnnotationProcessor extends AbstractCamelAnnotationProcessor {
                     }
                 }).collect(Collectors.toSet());
 
+        messager.printMessage(Kind.WARNING, String.format("Found %d core elements", coreElements.size()));
+
         Set<? extends Element> springElements = elements.stream()
                 .filter(new Predicate<Element>() {
                     @Override
@@ -72,10 +79,12 @@ public class ModelAnnotationProcessor extends AbstractCamelAnnotationProcessor {
                     }
                 }).collect(Collectors.toSet());
 
+        messager.printMessage(Kind.WARNING, String.format("Found %d spring elements", springElements.size()));
+
         // we want them to be sorted
         Set<String> propertyPlaceholderDefinitions = new TreeSet<>(String::compareToIgnoreCase);
 
-        Iterator it = coreElements.iterator();
+        Iterator<? extends Element> it = coreElements.iterator();
         while (it.hasNext()) {
             TypeElement classElement = (TypeElement) it.next();
             coreProcessor.processModelClass(processingEnv, roundEnv, classElement, propertyPlaceholderDefinitions, !it.hasNext());