aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-02-19 15:24:51 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2013-02-19 15:25:12 +0100
commit9cfa406506d3be218922595bd2c1b02621e0bceb (patch)
tree124fabb983766077537dd15a71bdac88e7a6c2c6 /sonar-batch
parentd7114792642fd4a20443288eb3deed59dd6a3609 (diff)
downloadsonarqube-9cfa406506d3be218922595bd2c1b02621e0bceb.tar.gz
sonarqube-9cfa406506d3be218922595bd2c1b02621e0bceb.zip
Do not cache file exclusions
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java38
1 files changed, 15 insertions, 23 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java
index 07f49377bac..7122f7a706f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java
@@ -32,25 +32,17 @@ import org.sonar.api.scan.filesystem.FileType;
import java.io.File;
public class ExclusionFilters implements FileSystemFilter, ResourceFilter, BatchComponent {
- private final PathPattern[] sourceInclusions;
- private final PathPattern[] testInclusions;
- private final PathPattern[] sourceExclusions;
- private final PathPattern[] testExclusions;
+ private final FileExclusions exclusionSettings;
public ExclusionFilters(FileExclusions exclusions) {
- sourceInclusions = PathPattern.create(exclusions.sourceInclusions());
- log("Included sources: ", sourceInclusions);
-
- sourceExclusions = PathPattern.create(exclusions.sourceExclusions());
- log("Excluded sources: ", sourceExclusions);
-
- testInclusions = PathPattern.create(exclusions.testInclusions());
- log("Included tests: ", testInclusions);
-
- testExclusions = PathPattern.create(exclusions.testExclusions());
- log("Excluded tests: ", testExclusions);
+ this.exclusionSettings = exclusions;
+ log("Included sources: ", sourceInclusions());
+ log("Excluded sources: ", sourceExclusions());
+ log("Included tests: ", testInclusions());
+ log("Excluded tests: ", testExclusions());
}
+
private void log(String title, PathPattern[] patterns) {
if (patterns.length > 0) {
Logger log = LoggerFactory.getLogger(ExclusionFilters.class);
@@ -62,7 +54,7 @@ public class ExclusionFilters implements FileSystemFilter, ResourceFilter, Batch
}
public boolean accept(File file, Context context) {
- PathPattern[] inclusionPatterns = (context.type() == FileType.TEST ? testInclusions : sourceInclusions);
+ PathPattern[] inclusionPatterns = (context.type() == FileType.TEST ? testInclusions() : sourceInclusions());
if (inclusionPatterns.length > 0) {
boolean matchInclusion = false;
for (PathPattern pattern : inclusionPatterns) {
@@ -72,7 +64,7 @@ public class ExclusionFilters implements FileSystemFilter, ResourceFilter, Batch
return false;
}
}
- PathPattern[] exclusionPatterns = (context.type() == FileType.TEST ? testExclusions : sourceExclusions);
+ PathPattern[] exclusionPatterns = (context.type() == FileType.TEST ? testExclusions() : sourceExclusions());
for (PathPattern pattern : exclusionPatterns) {
if (pattern.match(context)) {
return false;
@@ -83,11 +75,11 @@ public class ExclusionFilters implements FileSystemFilter, ResourceFilter, Batch
public boolean isIgnored(Resource resource) {
if (ResourceUtils.isFile(resource)) {
- PathPattern[] inclusionPatterns = (ResourceUtils.isUnitTestClass(resource) ? testInclusions : sourceInclusions);
+ PathPattern[] inclusionPatterns = (ResourceUtils.isUnitTestClass(resource) ? testInclusions() : sourceInclusions());
if (isIgnoredByInclusions(resource, inclusionPatterns)) {
return true;
}
- PathPattern[] exclusionPatterns = (ResourceUtils.isUnitTestClass(resource) ? testExclusions : sourceExclusions);
+ PathPattern[] exclusionPatterns = (ResourceUtils.isUnitTestClass(resource) ? testExclusions() : sourceExclusions());
return isIgnoredByExclusions(resource, exclusionPatterns);
}
return false;
@@ -120,18 +112,18 @@ public class ExclusionFilters implements FileSystemFilter, ResourceFilter, Batch
}
PathPattern[] sourceInclusions() {
- return sourceInclusions;
+ return PathPattern.create(exclusionSettings.sourceInclusions());
}
PathPattern[] testInclusions() {
- return testInclusions;
+ return PathPattern.create(exclusionSettings.testInclusions());
}
PathPattern[] sourceExclusions() {
- return sourceExclusions;
+ return PathPattern.create(exclusionSettings.sourceExclusions());
}
PathPattern[] testExclusions() {
- return testExclusions;
+ return PathPattern.create(exclusionSettings.testExclusions());
}
}