]> source.dussan.org Git - sonarqube.git/commitdiff
Refactor definition of exclusion properties
authorSimon Brandhof <simon.brandhof@gmail.com>
Mon, 16 Sep 2013 12:36:23 +0000 (14:36 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Mon, 16 Sep 2013 12:36:23 +0000 (14:36 +0200)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/ExclusionProperties.java [new file with mode: 0644]
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/ExclusionPropertiesTest.java [new file with mode: 0644]

index f72400dd0f7d4b0df6924f3feeda2a156d4d3112..f74bc7e2b4e8730cc838e82db2e9464987e60224 100644 (file)
@@ -485,79 +485,11 @@ public final class CorePlugin extends SonarPlugin {
         NewAlerts.class,
         NewAlerts.newMetadata());
 
-    extensions.addAll(getPropertyDefinitions());
+    extensions.addAll(ExclusionProperties.definitions());
     extensions.addAll(IgnoreIssuesPlugin.getExtensions());
     extensions.addAll(CoverageMeasurementFilter.getPropertyDefinitions());
 
     return extensions.build();
   }
 
-  private static List<PropertyDefinition> getPropertyDefinitions() {
-    return ImmutableList.of(
-      PropertyDefinition.builder(CoreProperties.PROJECT_INCLUSIONS_PROPERTY)
-        .name("Source File Inclusions")
-        .multiValues(true)
-        .category(CoreProperties.CATEGORY_EXCLUSIONS)
-        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
-        .onQualifiers(Qualifiers.PROJECT)
-        .index(3)
-        .build(),
-      PropertyDefinition.builder(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY)
-        .name("Test File Inclusions")
-        .multiValues(true)
-        .category(CoreProperties.CATEGORY_EXCLUSIONS)
-        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
-        .onQualifiers(Qualifiers.PROJECT)
-        .index(5)
-        .build(),
-      PropertyDefinition.builder(CoreProperties.GLOBAL_EXCLUSIONS_PROPERTY)
-        .name("Global Source File Exclusions")
-        .multiValues(true)
-        .category(CoreProperties.CATEGORY_EXCLUSIONS)
-        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
-        .index(0)
-        .build(),
-      PropertyDefinition.builder(CoreProperties.GLOBAL_TEST_EXCLUSIONS_PROPERTY)
-        .name("Global Test File Exclusions")
-        .multiValues(true)
-        .category(CoreProperties.CATEGORY_EXCLUSIONS)
-        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
-        .defaultValue(CoreProperties.GLOBAL_TEST_EXCLUSIONS_DEFAULT)
-        .index(1)
-        .build(),
-      PropertyDefinition.builder(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY)
-        .name("Source File Exclusions")
-        .multiValues(true)
-        .category(CoreProperties.CATEGORY_EXCLUSIONS)
-        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
-        .onQualifiers(Qualifiers.PROJECT)
-        .index(2)
-        .build(),
-      PropertyDefinition.builder(CoreProperties.PROJECT_TEST_EXCLUSIONS_PROPERTY)
-        .name("Test File Exclusions")
-        .multiValues(true)
-        .category(CoreProperties.CATEGORY_EXCLUSIONS)
-        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
-        .onQualifiers(Qualifiers.PROJECT)
-        .index(4)
-        .build(),
-      PropertyDefinition.builder(CoreProperties.CORE_SKIPPED_MODULES_PROPERTY)
-        .name("Exclude Modules")
-        .description("Maven artifact ids of modules to exclude.")
-        .multiValues(true)
-        .category(CoreProperties.CATEGORY_EXCLUSIONS)
-        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
-        .onlyOnQualifiers(Qualifiers.PROJECT)
-        .index(0)
-        .build(),
-      PropertyDefinition.builder(CoreProperties.CORE_INCLUDED_MODULES_PROPERTY)
-        .name("Include Modules")
-        .description("Maven artifact ids of modules to include.")
-        .multiValues(true)
-        .category(CoreProperties.CATEGORY_EXCLUSIONS)
-        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
-        .onlyOnQualifiers(Qualifiers.PROJECT)
-        .index(1)
-        .build());
-  }
 }
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/ExclusionProperties.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/ExclusionProperties.java
new file mode 100644 (file)
index 0000000..5a03604
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.plugins.core;
+
+import com.google.common.collect.ImmutableList;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.config.PropertyDefinition;
+import org.sonar.api.resources.Qualifiers;
+
+import java.util.List;
+
+class ExclusionProperties {
+
+  private ExclusionProperties() {
+    // only static stuff
+  }
+
+  static List<PropertyDefinition> definitions() {
+    return ImmutableList.of(
+      PropertyDefinition.builder(CoreProperties.PROJECT_INCLUSIONS_PROPERTY)
+        .name("Source File Inclusions")
+        .multiValues(true)
+        .category(CoreProperties.CATEGORY_EXCLUSIONS)
+        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
+        .onQualifiers(Qualifiers.PROJECT)
+        .index(3)
+        .build(),
+      PropertyDefinition.builder(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY)
+        .name("Test File Inclusions")
+        .multiValues(true)
+        .category(CoreProperties.CATEGORY_EXCLUSIONS)
+        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
+        .onQualifiers(Qualifiers.PROJECT)
+        .index(5)
+        .build(),
+      PropertyDefinition.builder(CoreProperties.GLOBAL_EXCLUSIONS_PROPERTY)
+        .name("Global Source File Exclusions")
+        .multiValues(true)
+        .category(CoreProperties.CATEGORY_EXCLUSIONS)
+        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
+        .index(0)
+        .build(),
+      PropertyDefinition.builder(CoreProperties.GLOBAL_TEST_EXCLUSIONS_PROPERTY)
+        .name("Global Test File Exclusions")
+        .multiValues(true)
+        .category(CoreProperties.CATEGORY_EXCLUSIONS)
+        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
+        .defaultValue(CoreProperties.GLOBAL_TEST_EXCLUSIONS_DEFAULT)
+        .index(1)
+        .build(),
+      PropertyDefinition.builder(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY)
+        .name("Source File Exclusions")
+        .multiValues(true)
+        .category(CoreProperties.CATEGORY_EXCLUSIONS)
+        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
+        .onQualifiers(Qualifiers.PROJECT)
+        .index(2)
+        .build(),
+      PropertyDefinition.builder(CoreProperties.PROJECT_TEST_EXCLUSIONS_PROPERTY)
+        .name("Test File Exclusions")
+        .multiValues(true)
+        .category(CoreProperties.CATEGORY_EXCLUSIONS)
+        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
+        .onQualifiers(Qualifiers.PROJECT)
+        .index(4)
+        .build(),
+      PropertyDefinition.builder(CoreProperties.CORE_SKIPPED_MODULES_PROPERTY)
+        .name("Exclude Modules")
+        .description("Maven artifact ids of modules to exclude.")
+        .multiValues(true)
+        .category(CoreProperties.CATEGORY_EXCLUSIONS)
+        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
+        .onlyOnQualifiers(Qualifiers.PROJECT)
+        .index(0)
+        .build(),
+      PropertyDefinition.builder(CoreProperties.CORE_INCLUDED_MODULES_PROPERTY)
+        .name("Include Modules")
+        .description("Maven artifact ids of modules to include.")
+        .multiValues(true)
+        .category(CoreProperties.CATEGORY_EXCLUSIONS)
+        .subCategory(CoreProperties.SUBCATEGORY_FILES_EXCLUSIONS)
+        .onlyOnQualifiers(Qualifiers.PROJECT)
+        .index(1)
+        .build());
+  }
+}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/ExclusionPropertiesTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/ExclusionPropertiesTest.java
new file mode 100644 (file)
index 0000000..204d01e
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.plugins.core;
+
+import org.junit.Test;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.config.PropertyDefinition;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class ExclusionPropertiesTest {
+  @Test
+  public void definitions() throws Exception {
+    assertThat(ExclusionProperties.definitions().size()).isGreaterThan(0);
+    for (PropertyDefinition definition : ExclusionProperties.definitions()) {
+      assertThat(definition.category()).isEqualTo(CoreProperties.CATEGORY_EXCLUSIONS);
+    }
+  }
+}