diff --git a/src/main/java/com/inteligr8/maven/regex/AbstractMatchMojo.java b/src/main/java/com/inteligr8/maven/regex/AbstractMatchMojo.java index e365a99..883d8ae 100644 --- a/src/main/java/com/inteligr8/maven/regex/AbstractMatchMojo.java +++ b/src/main/java/com/inteligr8/maven/regex/AbstractMatchMojo.java @@ -39,6 +39,9 @@ public abstract class AbstractMatchMojo extends AbstractRegexMojo { @Parameter( property = "patterns", required = true ) protected List patterns; + + @Parameter( property = "negate", required = true, defaultValue = "false" ) + protected boolean negate = false; private List compiledPatterns; @@ -81,7 +84,7 @@ public abstract class AbstractMatchMojo extends AbstractRegexMojo { if (this.allowMultiLineMatch) return this.matches(strbuilder.toString()); - return false; + return this.negate; } protected boolean matches(String text) { @@ -95,14 +98,14 @@ public abstract class AbstractMatchMojo extends AbstractRegexMojo { Matcher matcher = pattern.matcher(text); if (this.allowPartialMatch) { if (matcher.find()) - return true; + return !this.negate; } else { if (matcher.matches()) - return true; + return !this.negate; } } - return false; + return this.negate; } @Override diff --git a/src/main/java/com/inteligr8/maven/regex/MatchFileContentMojo.java b/src/main/java/com/inteligr8/maven/regex/MatchFileContentMojo.java index 8e7c0c4..e4864ba 100644 --- a/src/main/java/com/inteligr8/maven/regex/MatchFileContentMojo.java +++ b/src/main/java/com/inteligr8/maven/regex/MatchFileContentMojo.java @@ -69,7 +69,7 @@ public class MatchFileContentMojo extends AbstractMatchMojo { throw new MojoExecutionException("Execution failed due to an I/O related issue", ie); } - return false; + return this.negate; } @Override