supporting "negate" for matching
This commit is contained in:
parent
49ef3dd8a2
commit
9f58601815
@ -40,6 +40,9 @@ public abstract class AbstractMatchMojo extends AbstractRegexMojo {
|
|||||||
@Parameter( property = "patterns", required = true )
|
@Parameter( property = "patterns", required = true )
|
||||||
protected List<String> patterns;
|
protected List<String> patterns;
|
||||||
|
|
||||||
|
@Parameter( property = "negate", required = true, defaultValue = "false" )
|
||||||
|
protected boolean negate = false;
|
||||||
|
|
||||||
private List<Pattern> compiledPatterns;
|
private List<Pattern> compiledPatterns;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,7 +84,7 @@ public abstract class AbstractMatchMojo extends AbstractRegexMojo {
|
|||||||
|
|
||||||
if (this.allowMultiLineMatch)
|
if (this.allowMultiLineMatch)
|
||||||
return this.matches(strbuilder.toString());
|
return this.matches(strbuilder.toString());
|
||||||
return false;
|
return this.negate;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean matches(String text) {
|
protected boolean matches(String text) {
|
||||||
@ -95,14 +98,14 @@ public abstract class AbstractMatchMojo extends AbstractRegexMojo {
|
|||||||
Matcher matcher = pattern.matcher(text);
|
Matcher matcher = pattern.matcher(text);
|
||||||
if (this.allowPartialMatch) {
|
if (this.allowPartialMatch) {
|
||||||
if (matcher.find())
|
if (matcher.find())
|
||||||
return true;
|
return !this.negate;
|
||||||
} else {
|
} else {
|
||||||
if (matcher.matches())
|
if (matcher.matches())
|
||||||
return true;
|
return !this.negate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return this.negate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,7 +69,7 @@ public class MatchFileContentMojo extends AbstractMatchMojo {
|
|||||||
throw new MojoExecutionException("Execution failed due to an I/O related issue", ie);
|
throw new MojoExecutionException("Execution failed due to an I/O related issue", ie);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return this.negate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user