From: Julien HENRY Date: Tue, 13 Nov 2018 15:27:39 +0000 (+0100) Subject: Clean some scanner component names X-Git-Tag: 7.6~116 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0392f0dd841ffafde74d170918858fff43b22070;p=sonarqube.git Clean some scanner component names --- diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/AbstractPatternInitializer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/AbstractPatternInitializer.java index d206f91156e..8d26bed1a9a 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/AbstractPatternInitializer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/AbstractPatternInitializer.java @@ -34,8 +34,8 @@ public abstract class AbstractPatternInitializer { private Configuration settings; private List multicriteriaPatterns; - protected AbstractPatternInitializer(Configuration settings) { - this.settings = settings; + protected AbstractPatternInitializer(Configuration config) { + this.settings = config; initPatterns(); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssueExclusionPatternInitializer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssueExclusionPatternInitializer.java index b4018c829c3..01e0ab76b06 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssueExclusionPatternInitializer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssueExclusionPatternInitializer.java @@ -40,7 +40,7 @@ public class IssueExclusionPatternInitializer extends AbstractPatternInitializer @Override protected String getMulticriteriaConfigurationKey() { - return "sonar.issue.ignore" + ".multicriteria"; + return IssueExclusionProperties.EXCLUSION_KEY_PREFIX + ".multicriteria"; } @Override diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssueInclusionPatternInitializer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssueInclusionPatternInitializer.java index 164c90a317b..0fa72da96db 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssueInclusionPatternInitializer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/pattern/IssueInclusionPatternInitializer.java @@ -20,6 +20,7 @@ package org.sonar.scanner.issue.ignore.pattern; import org.sonar.api.config.Configuration; +import org.sonar.core.config.IssueExclusionProperties; public class IssueInclusionPatternInitializer extends AbstractPatternInitializer { @@ -29,6 +30,6 @@ public class IssueInclusionPatternInitializer extends AbstractPatternInitializer @Override protected String getMulticriteriaConfigurationKey() { - return "sonar.issue.enforce" + ".multicriteria"; + return IssueExclusionProperties.INCLUSION_KEY_PREFIX + ".multicriteria"; } } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfiguration.java new file mode 100644 index 00000000000..2dbcc577806 --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfiguration.java @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.scan; + +import java.util.Map; +import org.sonar.api.config.Encryption; +import org.sonar.api.config.PropertyDefinitions; +import org.sonar.scanner.bootstrap.GlobalAnalysisMode; +import org.sonar.scanner.config.DefaultConfiguration; + +public class ModuleConfiguration extends DefaultConfiguration { + + public ModuleConfiguration(PropertyDefinitions propertyDefinitions, Encryption encryption, GlobalAnalysisMode mode, Map props) { + super(propertyDefinitions, encryption, mode, props); + } + +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfigurationProvider.java new file mode 100644 index 00000000000..f078a0d11be --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleConfigurationProvider.java @@ -0,0 +1,86 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.scan; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.picocontainer.injectors.ProviderAdapter; +import org.sonar.api.batch.bootstrap.ProjectDefinition; +import org.sonar.api.batch.fs.internal.DefaultInputModule; +import org.sonar.scanner.bootstrap.GlobalAnalysisMode; +import org.sonar.scanner.bootstrap.GlobalConfiguration; +import org.sonar.scanner.report.AnalysisContextReportPublisher; +import org.sonar.scanner.repository.ProjectRepositories; + +public class ModuleConfigurationProvider extends ProviderAdapter { + + private ModuleConfiguration moduleConfiguration; + + public ModuleConfiguration provide(GlobalConfiguration globalConfig, DefaultInputModule module, ProjectRepositories projectRepos, + GlobalAnalysisMode analysisMode, AnalysisContextReportPublisher contextReportPublisher) { + if (moduleConfiguration == null) { + + Map settings = new LinkedHashMap<>(); + settings.putAll(globalConfig.getProperties()); + settings.putAll(addServerSidePropertiesIfModuleExists(projectRepos, module.definition())); + addScannerSideProperties(settings, module.definition()); + contextReportPublisher.dumpModuleSettings(module); + + moduleConfiguration = new ModuleConfiguration(globalConfig.getDefinitions(), globalConfig.getEncryption(), analysisMode, settings); + } + return moduleConfiguration; + } + + private static Map addServerSidePropertiesIfModuleExists(ProjectRepositories projectRepos, ProjectDefinition def) { + if (projectRepos.moduleExists(def.getKeyWithBranch())) { + return projectRepos.settings(def.getKeyWithBranch()); + } else { + // Module doesn't exist on server. Try to add parent server settings as inheritance. + ProjectDefinition parentDef = def.getParent(); + if (parentDef != null) { + return addServerSidePropertiesIfModuleExists(projectRepos, parentDef); + } + return Collections.emptyMap(); + } + } + + private static void addScannerSideProperties(Map settings, ProjectDefinition project) { + List orderedProjects = getTopDownParentProjects(project); + for (ProjectDefinition p : orderedProjects) { + settings.putAll(p.properties()); + } + } + + /** + * From root to given project + */ + static List getTopDownParentProjects(ProjectDefinition project) { + List result = new ArrayList<>(); + ProjectDefinition p = project; + while (p != null) { + result.add(0, p); + p = p.getParent(); + } + return result; + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java index 68bd4a0ffdf..aa12cc96b7f 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java @@ -89,7 +89,7 @@ public class ModuleScanContainer extends ComponentContainer { module.definition(), module, MutableModuleSettings.class, - new ModuleSettingsProvider()); + new ModuleConfigurationProvider()); if (analysisMode.isIssues()) { add( diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleSettings.java deleted file mode 100644 index 3382fdf3e10..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleSettings.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.scan; - -import java.util.Map; -import org.sonar.api.config.Encryption; -import org.sonar.api.config.PropertyDefinitions; -import org.sonar.scanner.bootstrap.GlobalAnalysisMode; -import org.sonar.scanner.config.DefaultConfiguration; - -public class ModuleSettings extends DefaultConfiguration { - - public ModuleSettings(PropertyDefinitions propertyDefinitions, Encryption encryption, GlobalAnalysisMode mode, Map props) { - super(propertyDefinitions, encryption, mode, props); - } - -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleSettingsProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleSettingsProvider.java deleted file mode 100644 index a5ce21f2d30..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleSettingsProvider.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.scan; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import org.picocontainer.injectors.ProviderAdapter; -import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.api.batch.fs.internal.DefaultInputModule; -import org.sonar.scanner.bootstrap.GlobalAnalysisMode; -import org.sonar.scanner.bootstrap.GlobalConfiguration; -import org.sonar.scanner.report.AnalysisContextReportPublisher; -import org.sonar.scanner.repository.ProjectRepositories; - -public class ModuleSettingsProvider extends ProviderAdapter { - - private ModuleSettings projectSettings; - - public ModuleSettings provide(GlobalConfiguration globalSettings, DefaultInputModule module, ProjectRepositories projectRepos, - GlobalAnalysisMode analysisMode, AnalysisContextReportPublisher contextReportPublisher) { - if (projectSettings == null) { - - Map settings = new LinkedHashMap<>(); - settings.putAll(globalSettings.getProperties()); - settings.putAll(addServerSidePropertiesIfModuleExists(projectRepos, module.definition())); - addScannerSideProperties(settings, module.definition()); - contextReportPublisher.dumpModuleSettings(module); - - projectSettings = new ModuleSettings(globalSettings.getDefinitions(), globalSettings.getEncryption(), analysisMode, settings); - } - return projectSettings; - } - - private static Map addServerSidePropertiesIfModuleExists(ProjectRepositories projectRepos, ProjectDefinition def) { - if (projectRepos.moduleExists(def.getKeyWithBranch())) { - return projectRepos.settings(def.getKeyWithBranch()); - } else { - // Module doesn't exist on server. Try to add parent server settings as inheritance. - ProjectDefinition parentDef = def.getParent(); - if (parentDef != null) { - return addServerSidePropertiesIfModuleExists(projectRepos, parentDef); - } - return Collections.emptyMap(); - } - } - - private static void addScannerSideProperties(Map settings, ProjectDefinition project) { - List orderedProjects = getTopDownParentProjects(project); - for (ProjectDefinition p : orderedProjects) { - settings.putAll(p.properties()); - } - } - - /** - * From root to given project - */ - static List getTopDownParentProjects(ProjectDefinition project) { - List result = new ArrayList<>(); - ProjectDefinition p = project; - while (p != null) { - result.add(0, p); - p = p.getParent(); - } - return result; - } -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java index b8daf815dba..d4a87b31e40 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableModuleSettings.java @@ -33,7 +33,7 @@ import org.sonar.scanner.repository.ProjectRepositories; import static java.util.Objects.requireNonNull; /** - * @deprecated since 6.5 {@link ModuleSettings} used to be mutable, so keep a mutable copy for backward compatibility. + * @deprecated since 6.5 {@link ModuleConfiguration} used to be mutable, so keep a mutable copy for backward compatibility. */ @Deprecated public class MutableModuleSettings extends Settings { @@ -69,7 +69,7 @@ public class MutableModuleSettings extends Settings { } private void addBuildProperties(ProjectDefinition project) { - List orderedProjects = ModuleSettingsProvider.getTopDownParentProjects(project); + List orderedProjects = ModuleConfigurationProvider.getTopDownParentProjects(project); for (ProjectDefinition p : orderedProjects) { addProperties(p.properties()); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java index 3b17bd91f29..c09c844a095 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/MutableProjectSettings.java @@ -32,7 +32,7 @@ import org.sonar.scanner.repository.ProjectRepositories; import static java.util.Objects.requireNonNull; /** - * @deprecated since 6.5 {@link ProjectSettings} used to be mutable, so keep a mutable copy for backward compatibility. + * @deprecated since 6.5 {@link ProjectConfiguration} used to be mutable, so keep a mutable copy for backward compatibility. */ @Deprecated public class MutableProjectSettings extends Settings { diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfiguration.java new file mode 100644 index 00000000000..53a727b50e4 --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfiguration.java @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.scan; + +import java.util.Map; +import org.sonar.api.config.Encryption; +import org.sonar.api.config.PropertyDefinitions; +import org.sonar.scanner.bootstrap.GlobalAnalysisMode; +import org.sonar.scanner.config.DefaultConfiguration; + +public class ProjectConfiguration extends DefaultConfiguration { + + public ProjectConfiguration(PropertyDefinitions propertyDefinitions, Encryption encryption, GlobalAnalysisMode mode, Map props) { + super(propertyDefinitions, encryption, mode, props); + } + +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfigurationProvider.java new file mode 100644 index 00000000000..51041627d70 --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectConfigurationProvider.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.scan; + +import java.util.LinkedHashMap; +import java.util.Map; +import org.picocontainer.injectors.ProviderAdapter; +import org.sonar.api.batch.bootstrap.ProjectReactor; +import org.sonar.scanner.bootstrap.GlobalAnalysisMode; +import org.sonar.scanner.bootstrap.GlobalConfiguration; +import org.sonar.scanner.repository.ProjectRepositories; + +public class ProjectConfigurationProvider extends ProviderAdapter { + + private ProjectConfiguration projectConfig; + + public ProjectConfiguration provide(ProjectReactor reactor, GlobalConfiguration globalSettings, ProjectRepositories projectRepositories, GlobalAnalysisMode mode) { + if (projectConfig == null) { + + Map settings = new LinkedHashMap<>(); + settings.putAll(globalSettings.getProperties()); + settings.putAll(projectRepositories.settings(reactor.getRoot().getKeyWithBranch())); + settings.putAll(reactor.getRoot().properties()); + + projectConfig = new ProjectConfiguration(globalSettings.getDefinitions(), globalSettings.getEncryption(), mode, settings); + } + return projectConfig; + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java index 0171e117e5f..5b9f43f3638 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java @@ -119,8 +119,8 @@ public class ProjectScanContainer extends ComponentContainer { @Override protected void doBeforeStart() { - addBatchComponents(); - addBatchExtensions(); + addScannerComponents(); + addScannerExtensions(); ProjectLock lock = getComponentByType(ProjectLock.class); lock.tryLock(); getComponentByType(WorkDirectoriesInitializer.class).execute(); @@ -133,7 +133,7 @@ public class ProjectScanContainer extends ComponentContainer { } - private void addBatchComponents() { + private void addScannerComponents() { add( props, ProjectReactorBuilder.class, @@ -202,7 +202,7 @@ public class ProjectScanContainer extends ComponentContainer { MutableProjectSettings.class, ScannerProperties.class, - new ProjectSettingsProvider(), + new ProjectConfigurationProvider(), // Report ScannerMetrics.class, @@ -252,15 +252,15 @@ public class ProjectScanContainer extends ComponentContainer { return getComponentByType(GlobalAnalysisMode.class).isIssues(); } - private void addBatchExtensions() { + private void addScannerExtensions() { getComponentByType(CoreExtensionsInstaller.class) - .install(this, noExtensionFilter(), extension -> isInstantiationStrategy(extension, PER_BATCH)); + .install(this, noExtensionFilter(), extension -> getScannerProjectExtensionsFilter().accept(extension)); getComponentByType(ExtensionInstaller.class) - .install(this, getBatchPluginExtensionsFilter()); + .install(this, getScannerProjectExtensionsFilter()); } @VisibleForTesting - static ExtensionMatcher getBatchPluginExtensionsFilter() { + static ExtensionMatcher getScannerProjectExtensionsFilter() { return extension -> isScannerSide(extension) || (isDeprecatedScannerSide(extension) && isInstantiationStrategy(extension, PER_BATCH)); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectSettings.java deleted file mode 100644 index 6c60803e8cc..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectSettings.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.scan; - -import java.util.Map; -import org.sonar.api.config.Encryption; -import org.sonar.api.config.PropertyDefinitions; -import org.sonar.scanner.bootstrap.GlobalAnalysisMode; -import org.sonar.scanner.config.DefaultConfiguration; - -public class ProjectSettings extends DefaultConfiguration { - - public ProjectSettings(PropertyDefinitions propertyDefinitions, Encryption encryption, GlobalAnalysisMode mode, Map props) { - super(propertyDefinitions, encryption, mode, props); - } - -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectSettingsProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectSettingsProvider.java deleted file mode 100644 index 918af7b0311..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectSettingsProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.scanner.scan; - -import java.util.LinkedHashMap; -import java.util.Map; -import org.picocontainer.injectors.ProviderAdapter; -import org.sonar.api.batch.bootstrap.ProjectReactor; -import org.sonar.scanner.bootstrap.GlobalAnalysisMode; -import org.sonar.scanner.bootstrap.GlobalConfiguration; -import org.sonar.scanner.repository.ProjectRepositories; - -public class ProjectSettingsProvider extends ProviderAdapter { - - private ProjectSettings projectSettings; - - public ProjectSettings provide(ProjectReactor reactor, GlobalConfiguration globalSettings, ProjectRepositories projectRepositories, GlobalAnalysisMode mode) { - if (projectSettings == null) { - - Map settings = new LinkedHashMap<>(); - settings.putAll(globalSettings.getProperties()); - settings.putAll(projectRepositories.settings(reactor.getRoot().getKeyWithBranch())); - settings.putAll(reactor.getRoot().properties()); - - projectSettings = new ProjectSettings(globalSettings.getDefinitions(), globalSettings.getEncryption(), mode, settings); - } - return projectSettings; - } -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationProvider.java index 0e0f827a5be..a1c78fc65dd 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/BranchConfigurationProvider.java @@ -56,7 +56,7 @@ public class BranchConfigurationProvider extends ProviderAdapter { } private static Supplier> createSettingsSupplier(GlobalConfiguration globalConfiguration, ProjectDefinition root, SettingsLoader settingsLoader) { - // we can't get ProjectSettings because it creates a circular dependency. + // we can't get ProjectConfiguration because it creates a circular dependency. // We create our own settings which will only be loaded if needed. return () -> { Map settings = new HashMap<>(); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java index ce394b9ffe3..4baae856d69 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java @@ -30,7 +30,7 @@ import org.sonar.api.utils.log.LogTester; import org.sonar.api.utils.log.LoggerLevel; import org.sonar.scanner.bootstrap.GlobalAnalysisMode; import org.sonar.scanner.config.DefaultConfiguration; -import org.sonar.scanner.scan.ProjectSettings; +import org.sonar.scanner.scan.ProjectConfiguration; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -49,7 +49,7 @@ public class GenericCoverageSensorTest { settings.put(GenericCoverageSensor.OLD_OVERALL_COVERAGE_REPORT_PATHS_PROPERTY_KEY, "old5.xml,old6.xml"); PropertyDefinitions defs = new PropertyDefinitions(GenericCoverageSensor.properties()); - DefaultConfiguration config = new ProjectSettings(defs, new Encryption(null), mock(GlobalAnalysisMode.class), settings); + DefaultConfiguration config = new ProjectConfiguration(defs, new Encryption(null), mock(GlobalAnalysisMode.class), settings); Set reportPaths = new GenericCoverageSensor(config).loadReportPaths(); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java index 35bc5e3c435..739532a9d2c 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java @@ -31,14 +31,12 @@ import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.sensor.internal.SensorContextTester; import org.sonar.api.config.Encryption; import org.sonar.api.config.PropertyDefinitions; -import org.sonar.api.config.Settings; -import org.sonar.api.config.internal.MapSettings; import org.sonar.api.utils.log.LogTester; import org.sonar.api.utils.log.LoggerLevel; import org.sonar.scanner.bootstrap.GlobalAnalysisMode; import org.sonar.scanner.config.DefaultConfiguration; import org.sonar.scanner.deprecated.test.TestPlanBuilder; -import org.sonar.scanner.scan.ProjectSettings; +import org.sonar.scanner.scan.ProjectConfiguration; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -61,7 +59,7 @@ public class GenericTestExecutionSensorTest { Map settings = new HashMap<>(); settings.put(GenericTestExecutionSensor.OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY, "report.xml"); PropertyDefinitions defs = new PropertyDefinitions(GenericTestExecutionSensor.properties()); - DefaultConfiguration config = new ProjectSettings(defs, new Encryption(null), mock(GlobalAnalysisMode.class), settings); + DefaultConfiguration config = new ProjectConfiguration(defs, new Encryption(null), mock(GlobalAnalysisMode.class), settings); new GenericTestExecutionSensor(mock(TestPlanBuilder.class), config).execute(context); assertThat(logTester.logs(LoggerLevel.WARN)).contains( diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/MutableModuleSettingsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/MutableModuleSettingsTest.java index 3cecb07c120..86be7dfda58 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/MutableModuleSettingsTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/MutableModuleSettingsTest.java @@ -76,7 +76,7 @@ public class MutableModuleSettingsTest { grandParent.addSubProject(parent); parent.addSubProject(child); - List hierarchy = ModuleSettingsProvider.getTopDownParentProjects(child); + List hierarchy = ModuleConfigurationProvider.getTopDownParentProjects(child); assertThat(hierarchy.get(0)).isEqualTo(grandParent); assertThat(hierarchy.get(1)).isEqualTo(parent); assertThat(hierarchy.get(2)).isEqualTo(child); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectScanContainerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectScanContainerTest.java index dfb191031ce..f9738b93d56 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectScanContainerTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectScanContainerTest.java @@ -32,7 +32,7 @@ public class ProjectScanContainerTest { @Test public void should_add_only_batch_extensions() { - ExtensionMatcher filter = ProjectScanContainer.getBatchPluginExtensionsFilter(); + ExtensionMatcher filter = ProjectScanContainer.getScannerProjectExtensionsFilter(); assertThat(filter.accept(new MyBatchExtension())).isTrue(); assertThat(filter.accept(MyBatchExtension.class)).isTrue();