You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2023/08/23 07:45:58 UTC

[sling-slingfeature-maven-plugin] branch master updated: SLING-12009 : Report errors and warnings at the end of the scan

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

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 6dc3286  SLING-12009 : Report errors and warnings at the end of the scan
6dc3286 is described below

commit 6dc3286a6750b5b62393c68904aaaaffa2d704db
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Aug 23 09:45:46 2023 +0200

    SLING-12009 : Report errors and warnings at the end of the scan
---
 .../feature/maven/mojos/AnalyseFeaturesMojo.java   | 51 ++++++++++++++--------
 1 file changed, 33 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/AnalyseFeaturesMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/AnalyseFeaturesMojo.java
index 8cac43b..0ffc1a6 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AnalyseFeaturesMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AnalyseFeaturesMojo.java
@@ -22,6 +22,7 @@ import java.net.URL;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -100,7 +101,7 @@ public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
 
         FeatureProvider featureProvider = getFeatureProvider();
 
-        boolean hasErrors = false;
+        final Map<Feature, AnalyserResult> results = new LinkedHashMap<>();
         for (final Scan an : list) {
             try {
                 Map<String, Map<String, String>> taskConfiguration = an.getTaskConfiguration();
@@ -148,23 +149,7 @@ public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
                             fwk = this.framework;
                         }
                         final AnalyserResult result = analyser.analyse(f, ProjectHelper.toArtifactId(fwk), featureProvider);
-                        if ( logWarnings ) {
-                            for (final String msg : result.getWarnings()) {
-                                getLog().warn(msg);
-                            }
-                        }
-                        for (final String msg : result.getErrors()) {
-                            getLog().error(msg);
-                        }
-
-                        if (!result.getErrors().isEmpty()) {
-                            getLog().error("Analyser detected errors on feature '" + f.getId().toMvnId()
-                                    + "'. See log output for error messages.");
-                            hasErrors = true;
-                        } else {
-                            getLog().debug(MessageUtils.buffer().a("feature ").project(f.getId().toMvnId())
-                                    .a(" succesfully passed all analysis").toString());
-                        }
+                        results.put(f, result);
                     } catch (Exception t) {
                         throw new MojoFailureException(
                                 "Exception during analysing feature " + f.getId().toMvnId() + " : " + t.getMessage(),
@@ -178,6 +163,36 @@ public class AnalyseFeaturesMojo extends AbstractIncludingFeatureMojo {
                 getLog().debug("Features analysis complete");
             }
         }
+        boolean hasErrors = false;
+        for(final Map.Entry<Feature, AnalyserResult> entry : results.entrySet()) {
+            final Feature f = entry.getKey();
+            final AnalyserResult result = entry.getValue();
+            if ( (result.getWarnings().isEmpty() || !logWarnings) && result.getErrors().isEmpty() ) {
+                getLog().debug(MessageUtils.buffer().a("feature ").project(f.getId().toMvnId())
+                        .a(" succesfully passed all analysis").toString());
+            } else {
+                final String message;
+                if (!result.getErrors().isEmpty()) {
+                    if (logWarnings && !result.getWarnings().isEmpty()) {
+                        message ="errors and warnings";
+                    } else {
+                        message = "errors";
+                    }
+                    hasErrors = true;
+                } else {
+                    message = "warnings";
+                }
+                getLog().error("Analyser detected " + message + " on feature '" + f.getId().toMvnId() + "'.");
+                if ( logWarnings ) {
+                    for (final String msg : result.getWarnings()) {
+                        getLog().warn(msg);
+                    }
+                }
+                 for (final String msg : result.getErrors()) {
+                    getLog().error(msg);
+                }
+            }
+        }
         if (hasErrors) {
             if ( failOnAnalyserErrors ) {
                 throw new MojoFailureException(