diff options
author | David Gageot <david@gageot.net> | 2012-09-21 10:23:37 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-09-21 12:26:14 +0200 |
commit | 90f65c869c857e5f548bc67ed779aeb465e2cb2f (patch) | |
tree | de8dd8770f4343d00af381f281ef4f60bc255d40 /sonar-plugin-api/src | |
parent | 2b7540abc629bdb71430a454da36552d3cc0cf13 (diff) | |
download | sonarqube-90f65c869c857e5f548bc67ed779aeb465e2cb2f.tar.gz sonarqube-90f65c869c857e5f548bc67ed779aeb465e2cb2f.zip |
SONAR-3750 Add ability to share Exclusion rules between several projects
Diffstat (limited to 'sonar-plugin-api/src')
3 files changed, 21 insertions, 14 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java index 17e0c48776e..b3b55b5ab03 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java @@ -67,6 +67,11 @@ public interface CoreProperties { */ String CATEGORY_DIFFERENTIAL_VIEWS = "differentialViews"; + /** + * @since 3.3 + */ + String CATEGORY_EXCLUSIONS = "exclusions"; + /* Global settings */ String SONAR_HOME = "SONAR_HOME"; String PROJECT_BRANCH_PROPERTY = "sonar.branch"; @@ -98,8 +103,11 @@ public interface CoreProperties { * Value format is yyyy-MM-dd */ String PROJECT_DATE_PROPERTY = "sonar.projectDate"; + String PROJECT_LANGUAGE_PROPERTY = "sonar.language"; String DYNAMIC_ANALYSIS_PROPERTY = "sonar.dynamicAnalysis"; + + /* Exclusions */ String PROJECT_EXCLUSIONS_PROPERTY = "sonar.exclusions"; /** diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java index f3cc76ba934..fd8f9304d53 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java @@ -19,14 +19,6 @@ */ package org.sonar.api.resources; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.endsWith; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; @@ -37,6 +29,7 @@ import org.hamcrest.Matchers; import org.hamcrest.TypeSafeMatcher; import org.junit.Before; import org.junit.Test; +import org.sonar.api.CoreProperties; import org.sonar.api.batch.FileFilter; import org.sonar.api.test.MavenTestUtils; @@ -45,6 +38,12 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + public class DefaultProjectFileSystemTest { private Project project = null; @@ -81,7 +80,7 @@ public class DefaultProjectFileSystemTest { assertThat(fs.hasJavaSourceFiles(), is(true)); PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty("sonar.exclusions", "**/*.java"); + conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*.java"); project.setConfiguration(conf); assertThat(fs.hasJavaSourceFiles(), is(false)); } @@ -97,7 +96,7 @@ public class DefaultProjectFileSystemTest { @Test public void applyExclusionPatternsToSourceFiles() { PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty("sonar.exclusions", "**/B*.java"); + conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/B*.java"); project.setConfiguration(conf); final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project); @@ -112,7 +111,7 @@ public class DefaultProjectFileSystemTest { @Test public void exclusionPatternOnAjFiles() { PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty("sonar.exclusions", "**/*.aj"); + conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*.aj"); project.setConfiguration(conf); final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project); @@ -125,7 +124,7 @@ public class DefaultProjectFileSystemTest { @Test public void doNotApplyExclusionPatternsToTestFiles() { PropertiesConfiguration conf = new PropertiesConfiguration(); - conf.setProperty("sonar.exclusions", "**/B*.java"); + conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/B*.java"); project.setConfiguration(conf); final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project); @@ -220,7 +219,7 @@ public class DefaultProjectFileSystemTest { @Test public void testSelectiveFileFilter() { DefaultProjectFileSystem.FileSelectionFilter filter = new DefaultProjectFileSystem.FileSelectionFilter( - Arrays.asList(new File("foo/Bar.java"), new File("hello/Bar.java"), new File("hello/World.java"))); + Arrays.asList(new File("foo/Bar.java"), new File("hello/Bar.java"), new File("hello/World.java"))); assertThat(filter.accept(new File("foo/Bar.java")), Matchers.is(true)); assertThat(filter.accept(new File("hello/Bar.java")), Matchers.is(true)); assertThat(filter.accept(new File("hello/World.java")), Matchers.is(true)); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectTest.java index d88ea57e211..6bc15f8f79c 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectTest.java @@ -59,7 +59,7 @@ public class ProjectTest { @Test public void shouldTrimExclusionPatterns() { Configuration conf = new PropertiesConfiguration(); - conf.setProperty("sonar.exclusions", " **/*Foo.java , **/Bar.java "); + conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, " **/*Foo.java , **/Bar.java "); Project project = new Project("foo").setConfiguration(conf); String[] exclusions = project.getExclusionPatterns(); |