diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-02-13 19:05:05 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-02-13 19:06:38 +0100 |
commit | 787a472b3de5e4fe60ac6407d2cd6aa5054ab863 (patch) | |
tree | 9fca565ebaf1f5ce2bc51d79d5e355c23124552f /sonar-plugin-api | |
parent | dea30cbbfe616b707fb8681a2d26c19132b942af (diff) | |
download | sonarqube-787a472b3de5e4fe60ac6407d2cd6aa5054ab863.tar.gz sonarqube-787a472b3de5e4fe60ac6407d2cd6aa5054ab863.zip |
SONAR-2760 file exclusions by absolute path
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java | 6 | ||||
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileExclusions.java (renamed from sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleExclusions.java) | 6 | ||||
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileFilter.java | 9 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/FileExclusionsTest.java (renamed from sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/ModuleExclusionsTest.java) | 10 |
4 files changed, 20 insertions, 11 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java index 28d2b3a436a..7c99e49b36b 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Project.java @@ -330,7 +330,7 @@ public class Project extends Resource { * Patterns of resource exclusion as defined in project settings page. * * @since 3.3 also applies exclusions in general settings page and global exclusions. - * @deprecated replaced by {@link org.sonar.api.scan.filesystem.ModuleExclusions} in version 3.5 + * @deprecated replaced by {@link org.sonar.api.scan.filesystem.FileExclusions} in version 3.5 */ @Deprecated public String[] getExclusionPatterns() { @@ -344,7 +344,7 @@ public class Project extends Resource { * Also applies exclusions in general settings page and global exclusions. * * @since 3.3 - * @deprecated replaced by {@link org.sonar.api.scan.filesystem.ModuleExclusions} in version 3.5 + * @deprecated replaced by {@link org.sonar.api.scan.filesystem.FileExclusions} in version 3.5 */ @Deprecated public String[] getTestExclusionPatterns() { @@ -369,7 +369,7 @@ public class Project extends Resource { /** * Set exclusion patterns. Configuration is not saved, so this method must be used ONLY IN UNIT TESTS. - * @deprecated replaced by {@link org.sonar.api.scan.filesystem.ModuleExclusions} in version 3.5 + * @deprecated replaced by {@link org.sonar.api.scan.filesystem.FileExclusions} in version 3.5 */ @Deprecated public Project setExclusionPatterns(String[] s) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleExclusions.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileExclusions.java index 7331a984419..a79929f558e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/ModuleExclusions.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileExclusions.java @@ -33,10 +33,10 @@ import java.util.List; * * @since 3.5 */ -public class ModuleExclusions implements BatchComponent { +public class FileExclusions implements BatchComponent { private final Settings settings; - public ModuleExclusions(Settings settings) { + public FileExclusions(Settings settings) { this.settings = settings; } @@ -52,7 +52,7 @@ public class ModuleExclusions implements BatchComponent { String[] patterns = sanitize(settings.getStringArray(propertyKey)); List<String> list = Lists.newArrayList(); for (String pattern : patterns) { - if (!"**/*".equals(pattern)) { + if (!"**/*".equals(pattern) && !"file:**/*".equals(pattern)) { list.add(pattern); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileFilter.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileFilter.java index ec4067d8de4..7ff169087dc 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileFilter.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileFilter.java @@ -37,7 +37,16 @@ public interface FileFilter extends BatchExtension { ModuleFileSystem fileSystem(); FileType fileType(); File sourceDir(); + + /** + * File path relative to source directory. Never return null. + */ String fileRelativePath(); + + /** + * Absolute file path. Never return null. + */ + String fileCanonicalPath(); } boolean accept(File file, Context context); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/ModuleExclusionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/FileExclusionsTest.java index 25f52de601e..5f9d3acaeea 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/ModuleExclusionsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/scan/filesystem/FileExclusionsTest.java @@ -25,14 +25,14 @@ import org.sonar.api.config.Settings; import static org.fest.assertions.Assertions.assertThat; -public class ModuleExclusionsTest { +public class FileExclusionsTest { @Test public void ignore_inclusion_of_world() { Settings settings = new Settings(); settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*"); settings.setProperty(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY, "**/*"); - assertThat(new ModuleExclusions(settings).sourceInclusions()).isEmpty(); - assertThat(new ModuleExclusions(settings).testInclusions()).isEmpty(); + assertThat(new FileExclusions(settings).sourceInclusions()).isEmpty(); + assertThat(new FileExclusions(settings).testInclusions()).isEmpty(); } @Test @@ -40,7 +40,7 @@ public class ModuleExclusionsTest { Settings settings = new Settings(); settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Foo.java"); settings.setProperty(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY, "**/*FooTest.java"); - ModuleExclusions moduleExclusions = new ModuleExclusions(settings); + FileExclusions moduleExclusions = new FileExclusions(settings); assertThat(moduleExclusions.sourceInclusions()).containsOnly("**/*Foo.java"); assertThat(moduleExclusions.testInclusions()).containsOnly("**/*FooTest.java"); @@ -51,7 +51,7 @@ public class ModuleExclusionsTest { Settings settings = new Settings(); settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*Foo.java"); settings.setProperty(CoreProperties.PROJECT_TEST_EXCLUSIONS_PROPERTY, "**/*FooTest.java"); - ModuleExclusions moduleExclusions = new ModuleExclusions(settings); + FileExclusions moduleExclusions = new FileExclusions(settings); assertThat(moduleExclusions.sourceInclusions()).isEmpty(); assertThat(moduleExclusions.sourceExclusions()).containsOnly("**/*Foo.java"); |