From: Simon Brandhof Date: Tue, 2 Oct 2012 08:06:25 +0000 (+0200) Subject: SONAR-3844 Drop the support of the deprecated property sonar.light X-Git-Tag: 3.3~147 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=54a3802ec94abd488a7db67efb68d0e1651b0d97;p=sonarqube.git SONAR-3844 Drop the support of the deprecated property sonar.light --- diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java index 7ef42fbd60e..5641f08c005 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java @@ -103,7 +103,7 @@ public class ProjectConfigurator implements BatchComponent { Project.AnalysisType loadAnalysisType() { String value = settings.getString(CoreProperties.DYNAMIC_ANALYSIS_PROPERTY); if (value == null) { - return ("true".equals(settings.getString("sonar.light")) ? Project.AnalysisType.STATIC : Project.AnalysisType.DYNAMIC); + return Project.AnalysisType.DYNAMIC; } if ("true".equals(value)) { return Project.AnalysisType.DYNAMIC; diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java index 09cc6ce69f7..9b4cf76d9e1 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java @@ -29,6 +29,7 @@ import org.sonar.api.utils.IocContainer; import org.sonar.batch.*; import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.batch.config.ProjectSettings; +import org.sonar.batch.config.UnsupportedProperties; import org.sonar.batch.events.EventBus; import org.sonar.batch.index.DefaultIndex; import org.sonar.batch.index.DefaultResourcePersister; @@ -64,6 +65,7 @@ public class ProjectModule extends Module { addCoreSingleton(project.getConfiguration()); addCoreSingleton(ProjectInitializer.class); addCoreSingleton(ProjectSettings.class); + addCoreSingleton(UnsupportedProperties.class); addCoreSingleton(IocContainer.class); for (Object component : projectDefinition.getContainerExtensions()) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/config/UnsupportedProperties.java b/sonar-batch/src/main/java/org/sonar/batch/config/UnsupportedProperties.java new file mode 100644 index 00000000000..554bac7240e --- /dev/null +++ b/sonar-batch/src/main/java/org/sonar/batch/config/UnsupportedProperties.java @@ -0,0 +1,41 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.batch.config; + +import org.sonar.api.BatchComponent; +import org.sonar.api.config.Settings; + +public class UnsupportedProperties implements BatchComponent { + private final Settings settings; + + public UnsupportedProperties(Settings settings) { + this.settings = settings; + } + + public void start() { + verify("sonar.light", "The property 'sonar.light' is no longer supported. Please use 'sonar.dynamicAnalysis'"); + } + + private void verify(String key, String message) { + if (settings.hasKey(key)) { + throw new IllegalArgumentException(message); + } + } +} diff --git a/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java index 3b0db7ee945..fe82ad57d93 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java @@ -71,16 +71,6 @@ public class ProjectConfiguratorTest extends AbstractDbUnitTestCase { new ProjectConfigurator(getSession(), configuration).configure(project); } - @Test - public void sonarLightIsDeprecated() { - Settings configuration = new Settings(); - configuration.setProperty("sonar.light", "true"); - Project project = new Project("key"); - new ProjectConfigurator(getSession(), configuration).configure(project); - - assertThat(project.getAnalysisType(), is(Project.AnalysisType.STATIC)); - } - @Test public void defaultAnalysisTypeIsDynamic() { Project project = new Project("key"); diff --git a/sonar-batch/src/test/java/org/sonar/batch/config/UnsupportedPropertiesTest.java b/sonar-batch/src/test/java/org/sonar/batch/config/UnsupportedPropertiesTest.java new file mode 100644 index 00000000000..6c042280b48 --- /dev/null +++ b/sonar-batch/src/test/java/org/sonar/batch/config/UnsupportedPropertiesTest.java @@ -0,0 +1,46 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.batch.config; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.config.Settings; + +public class UnsupportedPropertiesTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void should_fail_if_sonar_light_is_set() { + Settings settings = new Settings(); + settings.setProperty("sonar.light", true); + + thrown.expect(IllegalArgumentException.class); + new UnsupportedProperties(settings).start(); + } + + @Test + public void should_not_fail_if_sonar_light_is_not_set() { + Settings settings = new Settings(); + new UnsupportedProperties(settings).start(); + } +}