From 9f25da1847a08a794a4a3099388a2c7da2460183 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Wed, 11 Sep 2013 15:12:13 +0200 Subject: [PATCH] SONAR-4656 Display sonar.includedModules property in configuration Add core configuration constant for included modules Declare property in core configuration block Set indexes on configuration properties --- .../java/org/sonar/plugins/core/CorePlugin.java | 16 ++++++++++++++++ .../resources/org/sonar/l10n/core.properties | 3 +++ .../org/sonar/batch/scan/ProjectExclusions.java | 2 +- .../main/java/org/sonar/api/CoreProperties.java | 5 +++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index aa252eb0fdb..4b32a973eb3 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -498,6 +498,7 @@ public final class CorePlugin extends SonarPlugin { .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") @@ -505,12 +506,14 @@ public final class CorePlugin extends SonarPlugin { .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") @@ -518,6 +521,7 @@ public final class CorePlugin extends SonarPlugin { .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") @@ -525,6 +529,7 @@ public final class CorePlugin extends SonarPlugin { .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") @@ -532,6 +537,7 @@ public final class CorePlugin extends SonarPlugin { .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") @@ -540,6 +546,16 @@ public final class CorePlugin extends SonarPlugin { .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/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index bc5fafc667b..cd843c9ff80 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -817,6 +817,9 @@ category.exclusions.files.help=

Wildcards

\ property.sonar.skippedModules.name=Exclude project modules from code analysis property.sonar.skippedModules.description=Comma separated list of module keys to be excluded from analysis. This property can be used for instance to exclude some Maven modules from a SonarQube analysis. Changes will be applied during next code analysis. +property.sonar.includedModules.name=Include project modules in code analysis +property.sonar.includedModules.description=Comma-separated list of the modules to analyse, all other modules are automatically ignored. Be careful: the root project must be added to the list.
\ + If a module's artifactId differs from its module name (the directory name): it is the artifactId that should be use instead of the module name. property.category.exclusions.issues=Issues property.category.exclusions.issues.description=Configure which issues should not be reported. property.error.notBoolean=Valid options are "true" and "false" diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java index c61fb7137d7..10179b33102 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectExclusions.java @@ -69,7 +69,7 @@ public class ProjectExclusions implements TaskComponent { } private boolean isExcluded(String projectKey, boolean isRoot) { - String[] includedKeys = settings.getStringArray("sonar.includedModules"); + String[] includedKeys = settings.getStringArray(CoreProperties.CORE_INCLUDED_MODULES_PROPERTY); boolean excluded = false; if (!isRoot && includedKeys.length > 0) { excluded = !ArrayUtils.contains(includedKeys, projectKey); 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 514ecb2a372..b741be03da0 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 @@ -145,6 +145,11 @@ public interface CoreProperties { String CORE_RULE_WEIGHTS_PROPERTY = "sonar.core.rule.weight"; String CORE_RULE_WEIGHTS_DEFAULT_VALUE = "INFO=0;MINOR=1;MAJOR=3;CRITICAL=5;BLOCKER=10"; + /** + * @since 4.0 + */ + String CORE_INCLUDED_MODULES_PROPERTY = "sonar.includedModules"; + /** * @deprecated since 3.6. See http://jira.codehaus.org/browse/SONAR-4145 */ -- 2.39.5