diff --git a/maven-plugin/src/it/mojo-description/expected.log b/maven-plugin/src/it/mojo-description/expected.log index 59f54e87..6b7d8ef9 100644 --- a/maven-plugin/src/it/mojo-description/expected.log +++ b/maven-plugin/src/it/mojo-description/expected.log @@ -98,6 +98,10 @@ sortpom:sort User property: sort.predefinedSortOrder Choose between a number of predefined sort order files. + quiet (Default: false) + User property: sort.quiet + Set this to 'true' to disable plugin info output + skip (Default: false) User property: sort.skip Set this to 'true' to bypass sortpom plugin @@ -220,6 +224,10 @@ sortpom:verify User property: sort.predefinedSortOrder Choose between a number of predefined sort order files. + quiet (Default: false) + User property: sort.quiet + Set this to 'true' to disable plugin info output + skip (Default: false) User property: sort.skip Set this to 'true' to bypass sortpom plugin diff --git a/maven-plugin/src/main/java/sortpom/AbstractParentMojo.java b/maven-plugin/src/main/java/sortpom/AbstractParentMojo.java index 6979af4d..120b2654 100644 --- a/maven-plugin/src/main/java/sortpom/AbstractParentMojo.java +++ b/maven-plugin/src/main/java/sortpom/AbstractParentMojo.java @@ -131,6 +131,10 @@ abstract class AbstractParentMojo extends AbstractMojo { @Parameter(property = "sort.keepTimestamp", defaultValue = "false") boolean keepTimestamp; + /** Set this to 'true' to disable plugin info output */ + @Parameter(property = "sort.quiet", defaultValue = "false") + boolean quiet; + final SortPomImpl sortPomImpl = new SortPomImpl(); /** @@ -143,7 +147,9 @@ abstract class AbstractParentMojo extends AbstractMojo { @Override public void execute() throws MojoFailureException { if (skip) { - getLog().info("Skipping Sortpom"); + if (!quiet) { + getLog().info("Skipping Sortpom"); + } } else { setup(); sortPom(); diff --git a/maven-plugin/src/main/java/sortpom/SortMojo.java b/maven-plugin/src/main/java/sortpom/SortMojo.java index d39ff4b9..60fa0d8f 100644 --- a/maven-plugin/src/main/java/sortpom/SortMojo.java +++ b/maven-plugin/src/main/java/sortpom/SortMojo.java @@ -42,7 +42,7 @@ public void setup() throws MojoFailureException { .setIgnoreLineSeparators(ignoreLineSeparators) .build(); - sortPomImpl.setup(new MavenLogger(getLog()), pluginParameters); + sortPomImpl.setup(new MavenLogger(getLog(), quiet), pluginParameters); }) .executeAndConvertException(); } diff --git a/maven-plugin/src/main/java/sortpom/VerifyMojo.java b/maven-plugin/src/main/java/sortpom/VerifyMojo.java index 8bece3a9..3fb3772e 100644 --- a/maven-plugin/src/main/java/sortpom/VerifyMojo.java +++ b/maven-plugin/src/main/java/sortpom/VerifyMojo.java @@ -63,7 +63,7 @@ public void setup() throws MojoFailureException { .setVerifyFail(verifyFail, verifyFailOn) .build(); - sortPomImpl.setup(new MavenLogger(getLog()), pluginParameters); + sortPomImpl.setup(new MavenLogger(getLog(), quiet), pluginParameters); }) .executeAndConvertException(); } diff --git a/maven-plugin/src/main/java/sortpom/logger/MavenLogger.java b/maven-plugin/src/main/java/sortpom/logger/MavenLogger.java index 2793955d..45ee9fa5 100644 --- a/maven-plugin/src/main/java/sortpom/logger/MavenLogger.java +++ b/maven-plugin/src/main/java/sortpom/logger/MavenLogger.java @@ -8,9 +8,11 @@ */ public class MavenLogger implements SortPomLogger { private final Log pluginLogger; + private final boolean quiet; - public MavenLogger(Log pluginLogger) { + public MavenLogger(Log pluginLogger, boolean quiet) { this.pluginLogger = pluginLogger; + this.quiet = quiet; } @Override @@ -20,7 +22,9 @@ public void warn(String content) { @Override public void info(String content) { - pluginLogger.info(content); + if (!quiet) { + pluginLogger.info(content); + } } @Override diff --git a/maven-plugin/src/test/java/sortpom/logger/MavenLoggerTest.java b/maven-plugin/src/test/java/sortpom/logger/MavenLoggerTest.java index d44393ef..bc8f149e 100644 --- a/maven-plugin/src/test/java/sortpom/logger/MavenLoggerTest.java +++ b/maven-plugin/src/test/java/sortpom/logger/MavenLoggerTest.java @@ -18,7 +18,7 @@ class MavenLoggerTest { @BeforeEach void setUp() { - mavenLogger = new MavenLogger(logMock); + mavenLogger = new MavenLogger(logMock, false); } @Test