Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of String.format use #55

Merged
merged 1 commit into from
Dec 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,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}
*/
Expand All @@ -198,29 +203,29 @@ public void execute()
&& 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 );
Expand Down