Add wildcard-based class exclusion from JUnit mojo

This commit is contained in:
Alexey Andreev 2015-06-23 18:23:57 +04:00
parent e3017828d8
commit 49e6050871
2 changed files with 17 additions and 0 deletions

View File

@ -101,6 +101,9 @@
<debugInformationGenerated>true</debugInformationGenerated> <debugInformationGenerated>true</debugInformationGenerated>
<sourceMapsGenerated>true</sourceMapsGenerated> <sourceMapsGenerated>true</sourceMapsGenerated>
<sourceFilesCopied>true</sourceFilesCopied> <sourceFilesCopied>true</sourceFilesCopied>
<excludeWildcards>
<wildcard>**.GC*Test</wildcard>
</excludeWildcards>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>

View File

@ -83,6 +83,9 @@ public class BuildJavascriptTestMojo extends AbstractMojo {
@Parameter @Parameter
private String[] wildcards = { "**.*Test", "**.*UnitTest" }; private String[] wildcards = { "**.*Test", "**.*UnitTest" };
@Parameter
private String[] excludeWildcards = new String[0];
@Parameter @Parameter
private boolean minifying = true; private boolean minifying = true;
@ -150,6 +153,10 @@ public class BuildJavascriptTestMojo extends AbstractMojo {
this.wildcards = wildcards; this.wildcards = wildcards;
} }
public void setExcludeWildcards(String[] excludeWildcards) {
this.excludeWildcards = excludeWildcards;
}
public String[] getTransformers() { public String[] getTransformers() {
return transformers; return transformers;
} }
@ -359,6 +366,13 @@ public class BuildJavascriptTestMojo extends AbstractMojo {
if (!matches) { if (!matches) {
return; return;
} }
for (String wildcard : excludeWildcards) {
if (FilenameUtils.wildcardMatch(simpleName, wildcard.replace('.', '/'))) {
return;
}
}
try { try {
Class<?> candidate = Class.forName(className, true, classLoader); Class<?> candidate = Class.forName(className, true, classLoader);
if (tool.getAdapter().acceptClass(candidate)) { if (tool.getAdapter().acceptClass(candidate)) {