You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2022/07/25 16:57:57 UTC

[jackrabbit-filevault-package-maven-plugin] branch feature/JCRVLT-635-styled-validation-messages created (now 2e0dec4)

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

kwin pushed a change to branch feature/JCRVLT-635-styled-validation-messages
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault-package-maven-plugin.git


      at 2e0dec4  JCRVLT-635 emit styled validation messages

This branch includes the following new commits:

     new 2e0dec4  JCRVLT-635 emit styled validation messages

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[jackrabbit-filevault-package-maven-plugin] 01/01: JCRVLT-635 emit styled validation messages

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch feature/JCRVLT-635-styled-validation-messages
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault-package-maven-plugin.git

commit 2e0dec4bcaad8559ce8d90a762cdb698462143be
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri Jul 22 12:59:25 2022 +0200

    JCRVLT-635 emit styled validation messages
---
 pom.xml                                            |  9 ++++++++
 .../packaging/impl/ValidationMessagePrinter.java   | 24 ++++++++++++++--------
 .../expected-log-lines.txt                         |  2 +-
 .../expected-log-lines.txt                         |  2 +-
 .../invalid-project/expected-log-lines.txt         |  2 +-
 5 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/pom.xml b/pom.xml
index 741f82e..f4ff088 100644
--- a/pom.xml
+++ b/pom.xml
@@ -554,6 +554,15 @@
             <version>1.9.0</version>
             <scope>compile</scope>
         </dependency>
+
+        <!-- only use for package o.a.maven.shared.utils.logging, for other packages use plexus-utils -->
+        <dependency>
+            <groupId>org.apache.maven.shared</groupId>
+            <artifactId>maven-shared-utils</artifactId>
+            <version>3.3.4</version>
+            <scope>compile</scope>
+        </dependency>
+
         <!-- testing -->
         <dependency>
             <groupId>org.hamcrest</groupId>
diff --git a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/ValidationMessagePrinter.java b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/ValidationMessagePrinter.java
index 65adb8e..0985395 100644
--- a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/ValidationMessagePrinter.java
+++ b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/impl/ValidationMessagePrinter.java
@@ -36,6 +36,8 @@ import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
 import org.apache.jackrabbit.vault.validation.spi.Validator;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.shared.utils.logging.MessageBuilder;
+import org.apache.maven.shared.utils.logging.MessageUtils;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.sonatype.plexus.build.incremental.BuildContext;
@@ -146,21 +148,25 @@ public class ValidationMessagePrinter implements Closeable {
     }
 
     private static String getDetailMessage(ValidationViolation violation, Path baseDirectory) {
-        StringBuilder message = new StringBuilder("ValidationViolation: ");
-        message.append("\"").append(getMessage(violation)).append("\"");
+        MessageBuilder builder = MessageUtils.buffer();
+        builder.strong("ValidationViolation: ");
+        builder.a(violation.getMessage());
         if (violation.getFilePath() != null) {
-            message.append(", filePath=").append(baseDirectory.relativize(violation.getAbsoluteFilePath()));
-        }
-        if (violation.getNodePath() != null) {
-            message.append(", nodePath=").append(violation.getNodePath());
+            builder.a(" @ ").strong(baseDirectory.relativize(violation.getAbsoluteFilePath()));
         }
         if (violation.getLine() > 0) {
-            message.append(", line=").append(violation.getLine());
+            builder.strong(", line ").strong(violation.getLine());
         }
         if (violation.getColumn() > 0) {
-            message.append(", column=").append(violation.getColumn());
+            builder.strong(", column ").strong(violation.getColumn());
         }
-        return message.toString();
+        if (violation.getValidatorId() != null) {
+            builder.a(", validator: ").strong(violation.getValidatorId());
+        }
+        if (violation.getNodePath() != null) {
+            builder.a(", JCR node path: ").strong(violation.getNodePath());
+        }
+        return builder.toString();
     }
 
     private static String getValidatorNames(ValidationExecutor executor, String separator) {
diff --git a/src/test/resources/test-projects/generate-metadata-multimodule/expected-log-lines.txt b/src/test/resources/test-projects/generate-metadata-multimodule/expected-log-lines.txt
index 9f12a90..34f4750 100644
--- a/src/test/resources/test-projects/generate-metadata-multimodule/expected-log-lines.txt
+++ b/src/test/resources/test-projects/generate-metadata-multimodule/expected-log-lines.txt
@@ -1 +1 @@
-[WARNING] ValidationViolation: "jackrabbit-filter: Filter root's ancestor '/apps/bundles/install' is not covered by any of the specified dependencies nor a valid root.", filePath=%0%
\ No newline at end of file
+[WARNING] ValidationViolation: Filter root's ancestor '/apps/bundles/install' is not covered by any of the specified dependencies nor a valid root. @ %0%, validator: jackrabbit-filter
\ No newline at end of file
diff --git a/src/test/resources/test-projects/validator-projects/invalid-project-with-package-restrictions/expected-log-lines.txt b/src/test/resources/test-projects/validator-projects/invalid-project-with-package-restrictions/expected-log-lines.txt
index 4f5faa0..e192f2f 100644
--- a/src/test/resources/test-projects/validator-projects/invalid-project-with-package-restrictions/expected-log-lines.txt
+++ b/src/test/resources/test-projects/validator-projects/invalid-project-with-package-restrictions/expected-log-lines.txt
@@ -1 +1 @@
-[ERROR] ValidationViolation: "jackrabbit-filter: Invalid pattern given ('invalidpattern') which will never match for any descendants of the root path '/apps/wcm/core/content'.", filePath=%0%
\ No newline at end of file
+[ERROR] ValidationViolation: Invalid pattern given ('invalidpattern') which will never match for any descendants of the root path '/apps/wcm/core/content'. @ %0%, validator: jackrabbit-filter
\ No newline at end of file
diff --git a/src/test/resources/test-projects/validator-projects/invalid-project/expected-log-lines.txt b/src/test/resources/test-projects/validator-projects/invalid-project/expected-log-lines.txt
index 4f5faa0..e192f2f 100644
--- a/src/test/resources/test-projects/validator-projects/invalid-project/expected-log-lines.txt
+++ b/src/test/resources/test-projects/validator-projects/invalid-project/expected-log-lines.txt
@@ -1 +1 @@
-[ERROR] ValidationViolation: "jackrabbit-filter: Invalid pattern given ('invalidpattern') which will never match for any descendants of the root path '/apps/wcm/core/content'.", filePath=%0%
\ No newline at end of file
+[ERROR] ValidationViolation: Invalid pattern given ('invalidpattern') which will never match for any descendants of the root path '/apps/wcm/core/content'. @ %0%, validator: jackrabbit-filter
\ No newline at end of file