description = "Exclude tests from code analysis. Applies to every project. Cannot be overriden. Changes will be applied during next code analysis.",
multiValues = true,
category = CoreProperties.CATEGORY_EXCLUSIONS,
- defaultValue = "**/package-info.java"),
+ defaultValue = CoreProperties.GLOBAL_TEST_EXCLUSIONS_DEFAULT),
@Property(
key = CoreProperties.PROJECT_EXCLUSIONS_PROPERTY,
name = "Exclusions",
*/
package org.sonar.plugins.core.batch;
-import java.util.Arrays;
-import java.util.List;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.Initializer;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.ProjectFileSystem;
-public class ProjectFileSystemLogger extends Initializer {
+import java.util.Arrays;
+import java.util.List;
+public class ProjectFileSystemLogger extends Initializer {
private static final Logger LOG = LoggerFactory.getLogger(ProjectFileSystemLogger.class);
@Override
public void execute(Project project) {
- String[] exclusionPatterns = project.getExclusionPatterns();
- if (exclusionPatterns != null && exclusionPatterns.length > 0) {
- LOG.info("Excluded sources: {}", Arrays.toString(exclusionPatterns));
- }
+ logExclusionPatterns("Excluded sources: {}", project.getExclusionPatterns());
+ logExclusionPatterns("Excluded tests: {}", project.getTestExclusionPatterns());
+
ProjectFileSystem projectFileSystem = project.getFileSystem();
logDirectories("Source directories:", projectFileSystem.getSourceDirs());
logDirectories("Test directories:", projectFileSystem.getTestDirs());
}
+ private void logExclusionPatterns(String message, String[] exclusionPatterns) {
+ if (exclusionPatterns != null && exclusionPatterns.length > 0) {
+ LOG.info(message, Arrays.toString(exclusionPatterns));
+ }
+ }
+
private void logDirectories(String name, List<java.io.File> dirs) {
if (!dirs.isEmpty()) {
LOG.info(name);
}
}
}
-
}
String PROJECT_TEST_EXCLUSIONS_PROPERTY = "sonar.test.exclusions";
String GLOBAL_EXCLUSIONS_PROPERTY = "sonar.global.exclusions";
String GLOBAL_TEST_EXCLUSIONS_PROPERTY = "sonar.global.test.exclusions";
+ String GLOBAL_TEST_EXCLUSIONS_DEFAULT = "**/package-info.java";
/**
* @deprecated since 2.5. See discussion from http://jira.codehaus.org/browse/SONAR-1873
* @since 3.3
*/
public String[] getTestExclusionPatterns() {
+ String[] globalTestExclusions = configuration.getStringArray(CoreProperties.GLOBAL_TEST_EXCLUSIONS_PROPERTY);
+ if (globalTestExclusions.length == 0) {
+ globalTestExclusions = new String[] {CoreProperties.GLOBAL_TEST_EXCLUSIONS_DEFAULT};
+ }
+
return trimExclusions(ImmutableList.<String> builder()
.add(configuration.getStringArray(CoreProperties.PROJECT_TEST_EXCLUSIONS_PROPERTY))
- .add(configuration.getStringArray(CoreProperties.GLOBAL_TEST_EXCLUSIONS_PROPERTY)).build());
+ .add(globalTestExclusions).build());
}
// http://jira.codehaus.org/browse/SONAR-2261 - exclusion must be trimmed