diff options
author | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-02-14 16:45:09 +0100 |
---|---|---|
committer | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-02-23 15:15:39 +0100 |
commit | 2a90fd4a8e106b8d2f347cc30d9bd50405505fec (patch) | |
tree | 09f9b04a1b8ae4aa7b951ec73415ac72bc087ced | |
parent | dc75a91dcf08a2fbdacf36663828af48a7a691d6 (diff) | |
download | sonarqube-2a90fd4a8e106b8d2f347cc30d9bd50405505fec.tar.gz sonarqube-2a90fd4a8e106b8d2f347cc30d9bd50405505fec.zip |
Analyze non-leaf modules
3 files changed, 9 insertions, 40 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java index ff143ddadb6..dada0d84cf6 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java @@ -82,8 +82,8 @@ public class ProjectReactorBuilder { * * @since 1.5 */ - private static final String PROPERTY_SOURCES = "sonar.sources"; - private static final String PROPERTY_TESTS = "sonar.tests"; + private static final String PROPERTY_SOURCES = ProjectDefinition.SOURCES_PROPERTY; + private static final String PROPERTY_TESTS = ProjectDefinition.TESTS_PROPERTY; /** * Array of all mandatory properties required for a project without child. @@ -333,8 +333,6 @@ public class ProjectReactorBuilder { if (project.getSubProjects().isEmpty()) { cleanAndCheckModuleProperties(project); } else { - cleanAndCheckAggregatorProjectProperties(project); - // clean modules properties as well for (ProjectDefinition module : project.getSubProjects()) { cleanAndCheckProjectDefinitions(module); @@ -352,26 +350,6 @@ public class ProjectReactorBuilder { } @VisibleForTesting - protected static void cleanAndCheckAggregatorProjectProperties(ProjectDefinition project) { - Map<String, String> properties = project.properties(); - - // SONARPLUGINS-2295 - String[] sourceDirs = getListFromProperty(properties, PROPERTY_SOURCES); - for (String path : sourceDirs) { - File sourceFolder = resolvePath(project.getBaseDir(), path); - if (sourceFolder.isDirectory()) { - LOG.warn("/!\\ A multi-module project can't have source folders, so '{}' won't be used for the analysis. " + - "If you want to analyse files of this folder, you should create another sub-module and move them inside it.", - sourceFolder.toString()); - } - } - - // "aggregator" project must not have the following properties: - properties.remove(PROPERTY_SOURCES); - properties.remove(PROPERTY_TESTS); - } - - @VisibleForTesting protected static void mergeParentProperties(Map<String, String> childProps, Map<String, String> parentProps) { for (Map.Entry<String, String> entry : parentProps.entrySet()) { String key = entry.getKey(); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java index d5ffe1708eb..dad23ab9a19 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java @@ -44,7 +44,6 @@ import java.util.concurrent.atomic.AtomicInteger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.batch.ScannerSide; -import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.fs.IndexedFile; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.InputFile.Type; @@ -67,7 +66,6 @@ public class FileIndexer { private static final Logger LOG = LoggerFactory.getLogger(FileIndexer.class); private final InputFileFilter[] filters; - private final boolean isAggregator; private final ExclusionFilters exclusionFilters; private final InputFileBuilder inputFileBuilder; private final DefaultComponentTree componentTree; @@ -80,7 +78,7 @@ public class FileIndexer { private ProgressReport progressReport; public FileIndexer(BatchIdGenerator batchIdGenerator, InputComponentStore componentStore, DefaultInputModule module, ExclusionFilters exclusionFilters, - DefaultComponentTree componentTree, InputFileBuilder inputFileBuilder, ProjectDefinition def, InputFileFilter[] filters) { + DefaultComponentTree componentTree, InputFileBuilder inputFileBuilder, InputFileFilter[] filters) { this.batchIdGenerator = batchIdGenerator; this.componentStore = componentStore; this.module = module; @@ -89,20 +87,14 @@ public class FileIndexer { this.filters = filters; this.exclusionFilters = exclusionFilters; this.tasks = new ArrayList<>(); - this.isAggregator = !def.getSubProjects().isEmpty(); } public FileIndexer(BatchIdGenerator batchIdGenerator, InputComponentStore componentStore, DefaultInputModule module, ExclusionFilters exclusionFilters, - DefaultComponentTree componentTree, InputFileBuilder inputFileBuilder, ProjectDefinition def) { - this(batchIdGenerator, componentStore, module, exclusionFilters, componentTree, inputFileBuilder, def, new InputFileFilter[0]); + DefaultComponentTree componentTree, InputFileBuilder inputFileBuilder) { + this(batchIdGenerator, componentStore, module, exclusionFilters, componentTree, inputFileBuilder, new InputFileFilter[0]); } void index(DefaultModuleFileSystem fileSystem) { - if (isAggregator) { - // No indexing for an aggregator module - return; - } - int threads = Math.max(1, Runtime.getRuntime().availableProcessors() - 1); this.executorService = Executors.newFixedThreadPool(threads, new ThreadFactoryBuilder().setNameFormat("FileIndexer-%d").build()); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java index 17409eb8102..ab75657cfdc 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java @@ -125,9 +125,8 @@ public class ProjectReactorBuilderTest { assertThat(rootProject.getName()).isEqualTo("Foo Project"); assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project"); - // root project must not contain some properties - even if they are defined in the root properties file - assertThat(rootProject.sources().contains("sources")).isFalse(); - assertThat(rootProject.tests().contains("tests")).isFalse(); + assertThat(rootProject.sources().contains("sources")).isTrue(); + assertThat(rootProject.tests().contains("tests")).isTrue(); // and module properties must have been cleaned assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull(); assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull(); @@ -565,8 +564,8 @@ public class ProjectReactorBuilderTest { assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT"); assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project"); // root project must not contain some properties - even if they are defined in the root properties file - assertThat(rootProject.sources().contains("sources")).isFalse(); - assertThat(rootProject.tests().contains("tests")).isFalse(); + assertThat(rootProject.sources().contains("sources")).isTrue(); + assertThat(rootProject.tests().contains("tests")).isTrue(); // and module properties must have been cleaned assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull(); assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull(); |