maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gb...@apache.org
Subject svn commit: r1768264 - in /maven/plugins/trunk/maven-help-plugin/src: main/java/org/apache/maven/plugins/help/ test/java/org/apache/maven/plugins/help/
Date Sat, 05 Nov 2016 18:15:29 GMT
Author: gboue
Date: Sat Nov  5 18:15:28 2016
New Revision: 1768264

URL: http://svn.apache.org/viewvc?rev=1768264&view=rev
Log:
[MPH-107] Mojos use inconsistent line endings throughout

Using the system line separator instead of hard-coding "\n" in the different mojos.

Modified:
    maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java
    maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AllProfilesMojo.java
    maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
    maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
    maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
    maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
    maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java
    maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java
    maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
    maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java
    maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/EvaluateMojoTest.java

Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ActiveProfilesMojo.java
Sat Nov  5 18:15:28 2016
@@ -19,6 +19,8 @@ package org.apache.maven.plugins.help;
  * under the License.
  */
 
+import static org.apache.maven.plugins.help.HelpUtil.LS;
+
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -68,15 +70,15 @@ public class ActiveProfilesMojo
         {
             getActiveProfileStatement( project, message );
 
-            message.append( "\n\n" );
+            message.append( LS ).append( LS );
         }
 
         if ( output != null )
         {
             String formattedDateTime = DateFormatUtils.ISO_DATETIME_FORMAT.format( System.currentTimeMillis()
);
             StringBuilder sb = new StringBuilder();
-            sb.append( "Created by: " ).append( getClass().getName() ).append( "\n" );
-            sb.append( "Created on: " ).append( formattedDateTime ).append( "\n" ).append(
"\n" );
+            sb.append( "Created by: " ).append( getClass().getName() ).append( LS );
+            sb.append( "Created on: " ).append( formattedDateTime ).append( LS ).append(
LS );
             sb.append( message.toString() );
 
             try
@@ -138,9 +140,10 @@ public class ActiveProfilesMojo
         }
 
 
-        message.append( "\n" );
+        message.append( LS );
 
-        message.append( "Active Profiles for Project \'" ).append( project.getId() ).append(
"\': \n\n" );
+        message.append( "Active Profiles for Project \'" ).append( project.getId() ).append(
"\':" );
+        message.append( LS ).append( LS );
 
         if ( activeProfileIds.isEmpty() )
         {
@@ -148,19 +151,19 @@ public class ActiveProfilesMojo
         }
         else
         {
-            message.append( "The following profiles are active:\n" );
+            message.append( "The following profiles are active:" ).append( LS );
 
             for ( Map.Entry<String, List<String>> entry : activeProfileIds.entrySet()
)
             {
                 for ( String profileId : entry.getValue() )
                 {
-                    message.append( "\n - " ).append( profileId );
+                    message.append( LS ).append( " - " ).append( profileId );
                     message.append( " (source: " ).append( entry.getKey() ).append( ")" );
                 }
             }
         }
 
-        message.append( "\n" );
+        message.append( LS );
     }
 
     @SuppressWarnings( "unchecked" )

Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AllProfilesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AllProfilesMojo.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AllProfilesMojo.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/AllProfilesMojo.java
Sat Nov  5 18:15:28 2016
@@ -19,6 +19,8 @@ package org.apache.maven.plugins.help;
  * under the License.
  */
 
+import static org.apache.maven.plugins.help.HelpUtil.LS;
+
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Profile;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -84,7 +86,7 @@ public class AllProfilesMojo
 
         for ( MavenProject project : projects )
         {
-            descriptionBuffer.append( "Listing Profiles for Project: " ).append( project.getId()
).append( "\n" );
+            descriptionBuffer.append( "Listing Profiles for Project: " ).append( project.getId()
).append( LS );
 
             DefaultProfileManager pm =
                 new DefaultProfileManager( session.getContainer(), session.getExecutionProperties()
);
@@ -134,14 +136,16 @@ public class AllProfilesMojo
                 for ( Profile p : activeProfiles )
                 {
                     descriptionBuffer.append( "  Profile Id: " ).append( p.getId() );
-                    descriptionBuffer.append( " (Active: true , Source: " ).append( p.getSource()
).append( ")\n" );
+                    descriptionBuffer.append( " (Active: true , Source: " ).append( p.getSource()
).append( ")" );
+                    descriptionBuffer.append( LS );
                 }
 
                 // display inactive profiles
                 for ( Profile p : allProfilesByIds.values() )
                 {
                     descriptionBuffer.append( "  Profile Id: " ).append( p.getId() );
-                    descriptionBuffer.append( " (Active: false , Source: " ).append( p.getSource()
).append( ")\n" );
+                    descriptionBuffer.append( " (Active: false , Source: " ).append( p.getSource()
).append( ")" );
+                    descriptionBuffer.append( LS );
                 }
             }
         }

Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
Sat Nov  5 18:15:28 2016
@@ -19,6 +19,8 @@ package org.apache.maven.plugins.help;
  * under the License.
  */
 
+import static org.apache.maven.plugins.help.HelpUtil.LS;
+
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
@@ -413,15 +415,15 @@ public class DescribeMojo
         {
             String msg =
                 "You must specify either: both 'groupId' and 'artifactId' parameters OR a
'plugin' parameter"
-                    + " OR a 'cmd' parameter. For instance:\n"
-                    + "  # mvn help:describe -Dcmd=install\n"
-                    + "or\n"
-                    + "  # mvn help:describe -Dcmd=help:describe\n"
-                    + "or\n"
-                    + "  # mvn help:describe -Dplugin=org.apache.maven.plugins:maven-help-plugin\n"
-                    + "or\n"
-                    + "  # mvn help:describe -DgroupId=org.apache.maven.plugins -DartifactId=maven-help-plugin\n\n"
-                    + "Try 'mvn help:help -Ddetail=true' for more information.";
+                  + " OR a 'cmd' parameter. For instance:" + LS
+                  + "  # mvn help:describe -Dcmd=install" + LS
+                  + "or" + LS
+                  + "  # mvn help:describe -Dcmd=help:describe" + LS
+                  + "or" + LS
+                  + "  # mvn help:describe -Dplugin=org.apache.maven.plugins:maven-help-plugin"
+ LS
+                  + "or" + LS
+                  + "  # mvn help:describe -DgroupId=org.apache.maven.plugins -DartifactId=maven-help-plugin"
+ LS + LS
+                  + "Try 'mvn help:help -Ddetail=true' for more information.";
             throw new MojoFailureException( msg );
         }
 
@@ -433,18 +435,24 @@ public class DescribeMojo
             }
             catch ( ArtifactResolutionException e )
             {
-                throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId:
'" + groupId
-                    + "'\nartifactId: '" + artifactId + "'\nversion: '" + version + "'\n\n",
e );
+                throw new MojoExecutionException( "Error retrieving plugin descriptor for:"
+ LS
+                    + LS + "groupId: '" + groupId + "'"
+                    + LS + "artifactId: '" + artifactId + "'"
+                    + LS + "version: '" + version + "'" + LS + LS, e );
             }
             catch ( PluginManagerException e )
             {
-                throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId:
'" + groupId
-                    + "'\nartifactId: '" + artifactId + "'\nversion: '" + version + "'\n\n",
e );
+                throw new MojoExecutionException( "Error retrieving plugin descriptor for:"
+ LS
+                    + LS + "groupId: '" + groupId + "'"
+                    + LS + "artifactId: '" + artifactId + "'"
+                    + LS + "version: '" + version + "'" + LS + LS, e );
             }
             catch ( PluginVersionResolutionException e )
             {
-                throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId:
'" + groupId
-                    + "'\nartifactId: '" + artifactId + "'\nversion: '" + version + "'\n\n",
e );
+                throw new MojoExecutionException( "Error retrieving plugin descriptor for:"
+ LS
+                    + LS + "groupId: '" + groupId + "'"
+                    + LS + "artifactId: '" + artifactId + "'"
+                    + LS + "version: '" + version + "'" + LS + LS, e );
             }
             catch ( ArtifactNotFoundException e )
             {
@@ -452,13 +460,17 @@ public class DescribeMojo
             }
             catch ( InvalidVersionSpecificationException e )
             {
-                throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId:
'" + groupId
-                    + "'\nartifactId: '" + artifactId + "'\nversion: '" + version + "'\n\n",
e );
+                throw new MojoExecutionException( "Error retrieving plugin descriptor for:"
+ LS
+                    + LS + "groupId: '" + groupId + "'"
+                    + LS + "artifactId: '" + artifactId + "'"
+                    + LS + "version: '" + version + "'" + LS + LS, e );
             }
             catch ( InvalidPluginException e )
             {
-                throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId:
'" + groupId
-                    + "'\nartifactId: '" + artifactId + "'\nversion: '" + version + "'\n\n",
e );
+                throw new MojoExecutionException( "Error retrieving plugin descriptor for:"
+ LS
+                    + LS + "groupId: '" + groupId + "'"
+                    + LS + "artifactId: '" + artifactId + "'"
+                    + LS + "version: '" + version + "'" + LS + LS, e );
             }
             catch ( PluginNotFoundException e )
             {
@@ -547,7 +559,7 @@ public class DescribeMojo
         throws MojoFailureException, MojoExecutionException
     {
         append( buffer, pd.getId(), 0 );
-        buffer.append( "\n" );
+        buffer.append( LS );
 
         String name = pd.getName();
         if ( name == null )
@@ -576,7 +588,7 @@ public class DescribeMojo
         append( buffer, "Artifact Id", pd.getArtifactId(), 0 );
         append( buffer, "Version", pd.getVersion(), 0 );
         append( buffer, "Goal Prefix", pd.getGoalPrefix(), 0 );
-        buffer.append( "\n" );
+        buffer.append( LS );
 
         @SuppressWarnings( "unchecked" )
         List<MojoDescriptor> mojos = pd.getMojos();
@@ -590,7 +602,7 @@ public class DescribeMojo
         if ( ( detail || medium ) && !minimal )
         {
             append( buffer, "This plugin has " + mojos.size() + " goal" + ( mojos.size()
> 1 ? "s" : "" ) + ":", 0 );
-            buffer.append( "\n" );
+            buffer.append( LS );
 
             mojos = new ArrayList<MojoDescriptor>( mojos );
             PluginUtils.sortMojos( mojos );
@@ -606,14 +618,14 @@ public class DescribeMojo
                     describeMojoGuts( md, buffer, false );
                 }
 
-                buffer.append( "\n" );
+                buffer.append( LS );
             }
         }
 
         if ( !detail )
         {
             buffer.append( "For more information, run 'mvn help:describe [...] -Ddetail'"
);
-            buffer.append( "\n" );
+            buffer.append( LS );
         }
     }
 
@@ -629,15 +641,15 @@ public class DescribeMojo
         throws MojoFailureException, MojoExecutionException
     {
         buffer.append( "Mojo: '" ).append( md.getFullGoalName() ).append( "'" );
-        buffer.append( '\n' );
+        buffer.append( LS );
 
         describeMojoGuts( md, buffer, detail );
-        buffer.append( "\n" );
+        buffer.append( LS );
 
         if ( !detail )
         {
             buffer.append( "For more information, run 'mvn help:describe [...] -Ddetail'"
);
-            buffer.append( "\n" );
+            buffer.append( LS );
         }
     }
 
@@ -714,7 +726,7 @@ public class DescribeMojo
             }
         }
 
-        buffer.append( "\n" );
+        buffer.append( LS );
 
         describeMojoParameters( md, buffer );
     }
@@ -760,7 +772,7 @@ public class DescribeMojo
                 continue;
             }
 
-            buffer.append( "\n" );
+            buffer.append( LS );
 
             // DGF wouldn't it be nice if this worked?
             String defaultVal = parameter.getDefaultValue();
@@ -854,7 +866,7 @@ public class DescribeMojo
                 if ( lifecycle.getDefaultPhases() == null )
                 {
                     descriptionBuffer.append( "'" ).append( cmd );
-                    descriptionBuffer.append( "' is a phase corresponding to this plugin:\n"
);
+                    descriptionBuffer.append( "' is a phase corresponding to this plugin:"
).append( LS );
                     for ( String key : phases )
                     {
                         if ( !key.equals( cmd ) )
@@ -865,15 +877,15 @@ public class DescribeMojo
                         if ( lifecycleMapping.getPhases( "default" ).get( key ) != null )
                         {
                             descriptionBuffer.append( lifecycleMapping.getPhases( "default"
).get( key ) );
-                            descriptionBuffer.append( "\n" );
+                            descriptionBuffer.append( LS );
                         }
                     }
 
-                    descriptionBuffer.append( "\n" );
+                    descriptionBuffer.append( LS );
                     descriptionBuffer.append( "It is a part of the lifecycle for the POM
packaging '" );
                     descriptionBuffer.append( project.getPackaging() );
                     descriptionBuffer.append( "'. This lifecycle includes the following phases:"
);
-                    descriptionBuffer.append( "\n" );
+                    descriptionBuffer.append( LS );
                     for ( String key : phases )
                     {
                         descriptionBuffer.append( "* " ).append( key ).append( ": " );
@@ -886,7 +898,7 @@ public class DescribeMojo
 
                                 if ( !tok.hasMoreTokens() )
                                 {
-                                    descriptionBuffer.append( "\n" );
+                                    descriptionBuffer.append( LS );
                                 }
                                 else
                                 {
@@ -896,7 +908,7 @@ public class DescribeMojo
                         }
                         else
                         {
-                            descriptionBuffer.append( NOT_DEFINED ).append( "\n" );
+                            descriptionBuffer.append( NOT_DEFINED ).append( LS );
                         }
                     }
                 }
@@ -904,18 +916,18 @@ public class DescribeMojo
                 {
                     descriptionBuffer.append( "'" ).append( cmd );
                     descriptionBuffer.append( "' is a lifecycle with the following phases:
" );
-                    descriptionBuffer.append( "\n" );
+                    descriptionBuffer.append( LS );
 
                     for ( String key : phases )
                     {
                         descriptionBuffer.append( "* " ).append( key ).append( ": " );
                         if ( lifecycle.getDefaultPhases().get( key ) != null )
                         {
-                            descriptionBuffer.append( lifecycle.getDefaultPhases().get( key
) ).append( "\n" );
+                            descriptionBuffer.append( lifecycle.getDefaultPhases().get( key
) ).append( LS );
                         }
                         else
                         {
-                            descriptionBuffer.append( NOT_DEFINED ).append( "\n" );
+                            descriptionBuffer.append( NOT_DEFINED ).append( LS );
                         }
                     }
                 }
@@ -935,7 +947,8 @@ public class DescribeMojo
         // goals
         MojoDescriptor mojoDescriptor = HelpUtil.getMojoDescriptor( cmd, session, project,
cmd, true, false );
 
-        descriptionBuffer.append( "'" ).append( cmd ).append( "' is a plugin goal (aka mojo)"
).append( ".\n" );
+        descriptionBuffer.append( "'" ).append( cmd ).append( "' is a plugin goal (aka mojo)"
).append( "." );
+        descriptionBuffer.append( LS );
         plugin = mojoDescriptor.getPluginDescriptor().getId();
         goal = mojoDescriptor.getGoal();
 
@@ -1018,13 +1031,13 @@ public class DescribeMojo
     {
         if ( StringUtils.isEmpty( description ) )
         {
-            sb.append( UNKNOWN ).append( '\n' );
+            sb.append( UNKNOWN ).append( LS );
             return;
         }
 
         for ( String line : toLines( description, indent, INDENT_SIZE, LINE_LENGTH ) )
         {
-            sb.append( line ).append( '\n' );
+            sb.append( line ).append( LS );
         }
     }
 
@@ -1056,7 +1069,7 @@ public class DescribeMojo
         String description = key + ": " + value;
         for ( String line : toLines( description, indent, INDENT_SIZE, LINE_LENGTH ) )
         {
-            sb.append( line ).append( '\n' );
+            sb.append( line ).append( LS );
         }
     }
 
@@ -1096,7 +1109,7 @@ public class DescribeMojo
         l2.set( 0, l1.get( 0 ) );
         for ( String line : l2 )
         {
-            sb.append( line ).append( '\n' );
+            sb.append( line ).append( LS );
         }
     }
 

Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
Sat Nov  5 18:15:28 2016
@@ -19,6 +19,8 @@ package org.apache.maven.plugins.help;
  * under the License.
  */
 
+import static org.apache.maven.plugins.help.HelpUtil.LS;
+
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -142,9 +144,11 @@ public class EffectivePomMojo
         {
             StringBuilder message = new StringBuilder();
 
-            message.append( "\nEffective POMs, after inheritance, interpolation, and profiles
are applied:\n\n" );
+            message.append( LS );
+            message.append( "Effective POMs, after inheritance, interpolation, and profiles
are applied:" );
+            message.append( LS ).append( LS );
             message.append( effectivePom );
-            message.append( "\n" );
+            message.append( LS );
 
             if ( getLog().isInfoEnabled() )
             {

Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EffectiveSettingsMojo.java
Sat Nov  5 18:15:28 2016
@@ -19,6 +19,8 @@ package org.apache.maven.plugins.help;
  * under the License.
  */
 
+import static org.apache.maven.plugins.help.HelpUtil.LS;
+
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
@@ -121,9 +123,9 @@ public class EffectiveSettingsMojo
         {
             StringBuilder message = new StringBuilder();
 
-            message.append( "\nEffective user-specific configuration settings:\n\n" );
+            message.append( LS ).append( "Effective user-specific configuration settings:"
).append( LS ).append( LS );
             message.append( effectiveSettings );
-            message.append( "\n" );
+            message.append( LS );
 
             if ( getLog().isInfoEnabled() )
             {

Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
Sat Nov  5 18:15:28 2016
@@ -19,6 +19,8 @@ package org.apache.maven.plugins.help;
  * under the License.
  */
 
+import static org.apache.maven.plugins.help.HelpUtil.LS;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -392,7 +394,7 @@ public class EvaluateMojo
         }
         else
         {
-            getLog().info( "\n" + response.toString() );
+            getLog().info( LS + response.toString() );
         }
     }
 

Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/ExpressionsMojo.java
Sat Nov  5 18:15:28 2016
@@ -19,6 +19,8 @@ package org.apache.maven.plugins.help;
  * under the License.
  */
 
+import static org.apache.maven.plugins.help.HelpUtil.LS;
+
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Mojo;
@@ -66,12 +68,12 @@ public class ExpressionsMojo
         }
 
         StringBuilder sb = new StringBuilder();
-        sb.append( "Maven supports the following Plugin expressions:\n\n" );
+        sb.append( "Maven supports the following Plugin expressions:" ).append( LS ).append(
LS );
         for ( String expression : getExpressionsRoot() )
         {
             sb.append( "${" ).append( expression ).append( "}: " );
             sb.append( NO_DESCRIPTION_AVAILABLE );
-            sb.append( "\n\n" );
+            sb.append( LS ).append( LS );
         }
 
         for ( Map.Entry<String, Expression> entry : m.entrySet() )
@@ -81,7 +83,7 @@ public class ExpressionsMojo
 
             sb.append( "${" ).append( key ).append( "}: " );
             sb.append( trimCDATA( expression.getDescription() ) );
-            sb.append( "\n\n" );
+            sb.append( LS ).append( LS );
         }
 
         if ( output != null )

Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/HelpUtil.java
Sat Nov  5 18:15:28 2016
@@ -45,6 +45,8 @@ import org.codehaus.plexus.component.rep
 public class HelpUtil
 {
     
+    public static final String LS = System.getProperty( "line.separator" );
+    
     private HelpUtil()
     {
         // Utility classes should not have a public or default constructor.
@@ -133,7 +135,7 @@ public class HelpUtil
             PrintWriter writer = new PrintWriter( s );
             e.printStackTrace( writer );
 
-            throw new MojoFailureException( "InvocationTargetException: " + e.getMessage()
+ "\n" + s.toString() );
+            throw new MojoFailureException( "InvocationTargetException: " + e.getMessage()
+ LS + s.toString() );
         }
     }
 }

Modified: maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/SystemMojo.java
Sat Nov  5 18:15:28 2016
@@ -19,6 +19,8 @@ package org.apache.maven.plugins.help;
  * under the License.
  */
 
+import static org.apache.maven.plugins.help.HelpUtil.LS;
+
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Mojo;
@@ -52,37 +54,37 @@ public class SystemMojo
     {
         StringBuilder message = new StringBuilder();
 
-        message.append( '\n' );
-        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( '\n' );
+        message.append( LS );
+        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( LS );
         message.append( StringUtils.repeat( "=", REPEAT ) );
         message.append( " Platform Properties Details " );
-        message.append( StringUtils.repeat( "=", REPEAT ) ).append( '\n' );
-        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( '\n' );
-        message.append( '\n' );
-
-        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( '\n' );
-        message.append( "System Properties" ).append( '\n' );
-        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( '\n' );
+        message.append( StringUtils.repeat( "=", REPEAT ) ).append( LS );
+        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( LS );
+        message.append( LS );
+
+        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( LS );
+        message.append( "System Properties" ).append( LS );
+        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( LS );
 
         Properties systemProperties = System.getProperties();
         for ( Object o1 : systemProperties.keySet() )
         {
             String key = o1.toString();
-            message.append( "\n" );
+            message.append( LS );
             message.append( key ).append( "=" ).append( systemProperties.get( key ) );
         }
 
-        message.append( '\n' ).append( '\n' );
-        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( '\n' );
-        message.append( "Environment Variables" ).append( '\n' );
-        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( '\n' );
+        message.append( LS ).append( LS );
+        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( LS );
+        message.append( "Environment Variables" ).append( LS );
+        message.append( StringUtils.repeat( "=", LINE_LENGTH ) ).append( LS );
         try
         {
             Properties envVars = CommandLineUtils.getSystemEnvVars();
             for ( Object o : envVars.keySet() )
             {
                 String key = o.toString();
-                message.append( "\n" );
+                message.append( LS );
                 message.append( key ).append( "=" ).append( envVars.get( key ) );
             }
         }
@@ -94,14 +96,14 @@ public class SystemMojo
             }
         }
 
-        message.append( "\n" );
+        message.append( LS );
 
         if ( output != null )
         {
             String formattedDateTime = DateFormatUtils.ISO_DATETIME_FORMAT.format( System.currentTimeMillis()
);
             StringBuilder sb = new StringBuilder();
-            sb.append( "Created by: " ).append( getClass().getName() ).append( "\n" );
-            sb.append( "Created on: " ).append( formattedDateTime ).append( "\n" ).append(
"\n" );
+            sb.append( "Created by: " ).append( getClass().getName() ).append( LS );
+            sb.append( "Created on: " ).append( formattedDateTime ).append( LS ).append(
LS );
             sb.append( message.toString() );
 
             try

Modified: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java
Sat Nov  5 18:15:28 2016
@@ -64,16 +64,18 @@ public class DescribeMojoTest
         parameter.setExpression( "${valid.expression}" );
         md.addParameter( parameter );
         
+        String ls = System.getProperty( "line.separator" );
+        
         try
         {
             PrivateAccessor.invoke( new DescribeMojo(), "describeMojoParameters", new Class[]
{ MojoDescriptor.class,
                 StringBuilder.class }, new Object[] { md, sb } );
             
-            assertEquals( "  Available parameters:\n" +
-            		      "\n" +
-            		      "    name\n" +
-            		      "      User property: valid.expression\n" +
-            		      "      (no description available)\n", sb.toString() );
+            assertEquals( "  Available parameters:" + ls
+            		      + ls +
+            		      "    name" + ls +
+            		      "      User property: valid.expression" + ls +
+            		      "      (no description available)" + ls, sb.toString() );
         }
         catch ( Throwable e )
         {
@@ -91,16 +93,18 @@ public class DescribeMojoTest
         parameter.setExpression( "${project.build.directory}/generated-sources/foobar" );
//this is a defaultValue
         md.addParameter( parameter );
         
+        String ls = System.getProperty( "line.separator" );
+        
         try
         {
             PrivateAccessor.invoke( new DescribeMojo(), "describeMojoParameters", new Class[]
{ MojoDescriptor.class,
                 StringBuilder.class }, new Object[] { md, sb } );
             
-            assertEquals( "  Available parameters:\n" +
-                          "\n" +
-                          "    name\n" +
-                          "      Expression: ${project.build.directory}/generated-sources/foobar\n"
+
-                          "      (no description available)\n", sb.toString() );
+            assertEquals( "  Available parameters:" + ls +
+                          ls +
+                          "    name" + ls +
+                          "      Expression: ${project.build.directory}/generated-sources/foobar"
+ ls +
+                          "      (no description available)" + ls, sb.toString() );
         }
         catch ( Throwable e )
         {

Modified: maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/EvaluateMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/EvaluateMojoTest.java?rev=1768264&r1=1768263&r2=1768264&view=diff
==============================================================================
--- maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/EvaluateMojoTest.java
(original)
+++ maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/EvaluateMojoTest.java
Sat Nov  5 18:15:28 2016
@@ -76,8 +76,10 @@ public class EvaluateMojoTest
         setUpMojo( mojo, inputHandler, expressionEvaluator );
 
         mojo.execute();
+        
+        String ls = System.getProperty( "line.separator" );
 
-        assertTrue( interceptingLogger.infoLogs.contains( "\nMy result" ) );
+        assertTrue( interceptingLogger.infoLogs.contains( ls + "My result" ) );
         assertTrue( interceptingLogger.warnLogs.isEmpty() );
         verify( expressionEvaluator ).evaluate( "${project.groupId}" );
         verify( inputHandler, times( 2 ) ).readLine();
@@ -103,8 +105,10 @@ public class EvaluateMojoTest
         setUpMojo( mojo, inputHandler, expressionEvaluator );
 
         mojo.execute();
+        
+        String ls = System.getProperty( "line.separator" );
 
-        assertTrue( interceptingLogger.infoLogs.contains( "\nMy result" ) );
+        assertTrue( interceptingLogger.infoLogs.contains( ls + "My result" ) );
         assertFalse( interceptingLogger.warnLogs.isEmpty() );
         verify( expressionEvaluator ).evaluate( "${project.artifactId}" );
         verify( inputHandler, times( 2 ) ).readLine();



Mime
View raw message