diff --git a/README.md b/README.md
index d648224..339dff9 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,9 @@ Default phase of execution is `verify`. The following is an example of a configu
${project.basedir}/lib/scalastyle_config.xml
${project.basedir}/scalastyle-output.xml
UTF-8
+
+ .*directory.*
+
@@ -55,3 +58,14 @@ You can also specify multiple source directories if necessary. Replace the element in :
+
+```xml
+
+ .*testdir1.*
+ .*testdir2.*
+
+```
+
+Only files that match **none** of the provided `exclusions` are processed.
diff --git a/src/it/exclusion/invoker.properties b/src/it/exclusion/invoker.properties
new file mode 100644
index 0000000..2623bab
--- /dev/null
+++ b/src/it/exclusion/invoker.properties
@@ -0,0 +1,2 @@
+invoker.goals=clean compile
+invoker.buildResult=success
diff --git a/src/it/exclusion/pom.xml b/src/it/exclusion/pom.xml
new file mode 100644
index 0000000..1e45a8c
--- /dev/null
+++ b/src/it/exclusion/pom.xml
@@ -0,0 +1,49 @@
+
+
+
+ 4.0.0
+
+ it.scalastyle-maven-plugin
+ basic
+ 1.0-SNAPSHOT
+ Test for basic criteria
+ Test for basic criteria
+ pom
+
+
+
+
+
+
+ @project.groupId@
+ @project.artifactId@
+ @project.version@
+
+ true
+ true
+ true
+ false
+ ${src.it}/testsrc
+
+ ${src.it}/testsrc2
+
+ ${src.it}/scalastyle_config.xml
+
+ .*Foobar2.*
+
+
+
+
+ scalastyle
+ compile
+
+ check
+
+
+
+
+
+
+
diff --git a/src/it/exclusion/validate.groovy b/src/it/exclusion/validate.groovy
new file mode 100644
index 0000000..cc178c5
--- /dev/null
+++ b/src/it/exclusion/validate.groovy
@@ -0,0 +1,14 @@
+try {
+
+def file = new File(basedir, 'target')
+assert !file.exists()
+
+assert new File(basedir, "build.log").readLines().grep(~/.*excluded.*src\/it\/testsrc2\/Foobar2.scala.*/).size() == 1
+assert new File(basedir, "build.log").readLines().grep(~/.*Excluded 1 file.*/).size() == 1
+
+return true
+
+} catch(Throwable e) {
+ e.printStackTrace()
+ return false
+}
diff --git a/src/main/java/org/scalastyle/maven/plugin/ScalastyleViolationCheckMojo.java b/src/main/java/org/scalastyle/maven/plugin/ScalastyleViolationCheckMojo.java
index 17d52ba..e73568c 100644
--- a/src/main/java/org/scalastyle/maven/plugin/ScalastyleViolationCheckMojo.java
+++ b/src/main/java/org/scalastyle/maven/plugin/ScalastyleViolationCheckMojo.java
@@ -171,6 +171,16 @@ public class ScalastyleViolationCheckMojo extends AbstractMojo {
@Parameter(property = "scalastyle.input.encoding")
private String inputEncoding;
+ /**
+ * Regex patterns to exclude files. Applies to all sources.
+ */
+ @Parameter(property = "scalastyle.exclusions")
+ private List exclusions;
+
+ /**
+ * Number of excluded files
+ */
+ private int excludedFiles = 0;
/**
* The Maven Project Object.
@@ -201,6 +211,7 @@ public void execute() throws MojoFailureException, MojoExecutionException {
getLog().debug("outputFile=" + outputFile);
getLog().debug("outputEncoding=" + outputEncoding);
getLog().debug("inputEncoding=" + inputEncoding);
+ getLog().debug("exclusions=" + exclusions);
performCheck();
}
@@ -225,6 +236,7 @@ private void performCheck() throws MojoFailureException, MojoExecutionException
if (!quiet) {
System.out.println("Processed " + outputResult.files() + " file(s)");
+ System.out.println("Excluded " + excludedFiles + " file(s)");
System.out.println("Found " + outputResult.errors() + " errors");
System.out.println("Found " + outputResult.warnings() + " warnings");
System.out.println("Found " + outputResult.infos() + " infos");
@@ -313,7 +325,29 @@ private List getFilesToProcess() {
all.addAll(getFiles("sourceDirectory", sourceDirectoriesAsList(), inputEncoding));
all.addAll(getFiles("testSourceDirectory", testSourceDirectoriesAsList(), inputEncoding));
- return all;
+ List filteredList = new ArrayList();
+
+ if (exclusions != null && exclusions.size() != 0) {
+ for (FileSpec file : all) {
+ boolean check = true;
+
+ for (String exclusion : exclusions) {
+ if (!check || file.name().matches(exclusion)) {
+ check = false;
+ }
+ }
+ if (check)
+ filteredList.add(file);
+ else if (verbose)
+ getLog().info("excluded file = " + file.name());
+ }
+ } else {
+ filteredList = all;
+ }
+
+ excludedFiles = all.size() - filteredList.size();
+
+ return filteredList;
}
private List getFiles(String name, List dirs, String encoding) {