@@ -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); | |||
@@ -351,26 +349,6 @@ public class ProjectReactorBuilder { | |||
checkExistenceOfPaths(project.getKey(), project.getBaseDir(), sourcePaths, PROPERTY_SOURCES); | |||
} | |||
@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()) { |
@@ -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()); | |||
@@ -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(); |