You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2021/12/17 11:30:37 UTC

[maven-plugin-tools] branch simplify-console-messages created (now 1eee7df)

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

cstamas pushed a change to branch simplify-console-messages
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git.


      at 1eee7df  Get rid of String.format use

This branch includes the following new commits:

     new 1eee7df  Get rid of String.format use

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.


[maven-plugin-tools] 01/01: Get rid of String.format use

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

cstamas pushed a commit to branch simplify-console-messages
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git

commit 1eee7df493ca0df696b40f788badd9c23fe3a1d0
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Fri Dec 17 12:29:56 2021 +0100

    Get rid of String.format use
    
    and craft strings along with OS native line ending just
    manually. String.format w/o any param looks very
    awkward.
---
 .../maven/plugin/plugin/AbstractGeneratorMojo.java | 29 +++++++++++++---------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
index 3a5aacc..da97cf6 100644
--- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
+++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java
@@ -176,6 +176,11 @@ public abstract class AbstractGeneratorMojo
     protected abstract Generator createGenerator();
 
     /**
+     * System/OS line separator: used to format console messages.
+     */
+    private static final String LS = System.lineSeparator();
+
+    /**
      * {@inheritDoc}
      */
     @Override
@@ -198,29 +203,29 @@ public abstract class AbstractGeneratorMojo
             && project.getArtifactId().toLowerCase().endsWith( "-plugin" ) 
             && !"org.apache.maven.plugins".equals( project.getGroupId() ) )
         {
-            getLog().error( String.format( "%n%nArtifact Ids of the format maven-___-plugin are reserved for %n"
-                                + "plugins in the Group Id org.apache.maven.plugins%n"
-                                + "Please change your artifactId to the format ___-maven-plugin%n"
-                                + "In the future this error will break the build.%n%n" ) );
+            getLog().error( LS + LS + "Artifact Ids of the format maven-___-plugin are reserved for" + LS
+                                + "plugins in the Group Id org.apache.maven.plugins" + LS
+                                + "Please change your artifactId to the format ___-maven-plugin" + LS
+                                + "In the future this error will break the build." + LS + LS );
         }
 
         Set<Artifact> wrongScopedArtifacts = mavenDependenciesNotInProvidedScope();
         if ( !wrongScopedArtifacts.isEmpty() )
         {
             StringBuilder errorMessage = new StringBuilder(
-                "%n%nMaven dependencies of Maven Plugins should be in provided scope.%n"
-                    + "Please make sure that all your dependencies declared in POM whose group ID is%n"
-                    + "org.apache.maven have set '<scope>provided</scope>' as well.%n"
-                    + "In the future this error will break the build.%n%n"
-                    + "The following dependencies are in wrong scope:%n"
+                LS + LS + "Maven dependencies of Maven Plugins should be in provided scope." + LS
+                    + "Please make sure that all your dependencies declared in POM whose group ID is" + LS
+                    + "org.apache.maven have set '<scope>provided</scope>' as well." + LS
+                    + "In the future this error will break the build." + LS + LS
+                    + "The following dependencies are in wrong scope:" + LS
             );
             for ( Artifact artifact : wrongScopedArtifacts )
             {
-                errorMessage.append( " * " ).append( artifact ).append( "%n" );
+                errorMessage.append( " * " ).append( artifact ).append( LS );
             }
-            errorMessage.append( "%nPlease fix your build!%n%n" );
+            errorMessage.append( LS ).append( "Please fix your build!" ).append( LS ).append( LS );
 
-            getLog().error( String.format( errorMessage.toString() ) );
+            getLog().error( errorMessage.toString() );
         }
 
         String defaultGoalPrefix = getDefaultGoalPrefix( project );