Skip to content

Commit

Permalink
Merge pull request #339 from gnodet/i338
Browse files Browse the repository at this point in the history
Add a quiet flag to disable plugin info output (fixes #338)
  • Loading branch information
Ekryd authored Jul 1, 2023
2 parents 4f9fcdb + e6a5995 commit 66ccb1b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
8 changes: 8 additions & 0 deletions maven-plugin/src/it/mojo-description/expected.log
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion maven-plugin/src/main/java/sortpom/AbstractParentMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion maven-plugin/src/main/java/sortpom/SortMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion maven-plugin/src/main/java/sortpom/VerifyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
8 changes: 6 additions & 2 deletions maven-plugin/src/main/java/sortpom/logger/MavenLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +22,9 @@ public void warn(String content) {

@Override
public void info(String content) {
pluginLogger.info(content);
if (!quiet) {
pluginLogger.info(content);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MavenLoggerTest {

@BeforeEach
void setUp() {
mavenLogger = new MavenLogger(logMock);
mavenLogger = new MavenLogger(logMock, false);
}

@Test
Expand Down

0 comments on commit 66ccb1b

Please sign in to comment.