]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6775 Drop old sonar.dryRun property
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 6 Aug 2015 10:18:49 +0000 (12:18 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 12 Aug 2015 14:12:49 +0000 (16:12 +0200)
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginPredicate.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalMode.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalSettings.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectAnalysisMode.java
sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginPredicateTest.java
sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java
sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalSettingsTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java

index dd55c27758791741eb7045991bc3f7e2ae3b0a83..5db59c34280d91212e4967fcbecb036175185d48 100644 (file)
@@ -24,7 +24,6 @@ import com.google.common.base.Predicate;
 import com.google.common.base.Splitter;
 import com.google.common.collect.Lists;
 
-import java.text.MessageFormat;
 import java.util.List;
 import java.util.Set;
 
@@ -47,7 +46,6 @@ public class BatchPluginPredicate implements Predicate<String> {
   private static final Logger LOG = Loggers.get(BatchPluginPredicate.class);
 
   private static final String BUILDBREAKER_PLUGIN_KEY = "buildbreaker";
-  private static final String PROPERTY_IS_DEPRECATED_MSG = "Property {0} is deprecated. Please use {1} instead.";
   private static final Joiner COMMA_JOINER = Joiner.on(", ");
 
   private final Set<String> whites = newHashSet();
@@ -59,22 +57,10 @@ public class BatchPluginPredicate implements Predicate<String> {
     if (mode.isPreview()) {
       // These default values are not supported by Settings because the class CorePlugin
       // is not loaded yet.
-      if (settings.hasKey(CoreProperties.DRY_RUN_INCLUDE_PLUGINS)) {
-        LOG.warn(MessageFormat.format(PROPERTY_IS_DEPRECATED_MSG, CoreProperties.DRY_RUN_INCLUDE_PLUGINS, CoreProperties.PREVIEW_INCLUDE_PLUGINS));
-        whites.addAll(propertyValues(settings,
-          CoreProperties.DRY_RUN_INCLUDE_PLUGINS, CoreProperties.PREVIEW_INCLUDE_PLUGINS_DEFAULT_VALUE));
-      } else {
-        whites.addAll(propertyValues(settings,
-          CoreProperties.PREVIEW_INCLUDE_PLUGINS, CoreProperties.PREVIEW_INCLUDE_PLUGINS_DEFAULT_VALUE));
-      }
-      if (settings.hasKey(CoreProperties.DRY_RUN_EXCLUDE_PLUGINS)) {
-        LOG.warn(MessageFormat.format(PROPERTY_IS_DEPRECATED_MSG, CoreProperties.DRY_RUN_EXCLUDE_PLUGINS, CoreProperties.PREVIEW_EXCLUDE_PLUGINS));
-        blacks.addAll(propertyValues(settings,
-          CoreProperties.DRY_RUN_EXCLUDE_PLUGINS, CoreProperties.PREVIEW_EXCLUDE_PLUGINS_DEFAULT_VALUE));
-      } else {
-        blacks.addAll(propertyValues(settings,
-          CoreProperties.PREVIEW_EXCLUDE_PLUGINS, CoreProperties.PREVIEW_EXCLUDE_PLUGINS_DEFAULT_VALUE));
-      }
+      whites.addAll(propertyValues(settings,
+        CoreProperties.PREVIEW_INCLUDE_PLUGINS, CoreProperties.PREVIEW_INCLUDE_PLUGINS_DEFAULT_VALUE));
+      blacks.addAll(propertyValues(settings,
+        CoreProperties.PREVIEW_EXCLUDE_PLUGINS, CoreProperties.PREVIEW_EXCLUDE_PLUGINS_DEFAULT_VALUE));
     }
     if (!whites.isEmpty()) {
       LOG.info("Include plugins: " + COMMA_JOINER.join(whites));
@@ -87,7 +73,7 @@ public class BatchPluginPredicate implements Predicate<String> {
   @Override
   public boolean apply(@Nonnull String pluginKey) {
     if (BUILDBREAKER_PLUGIN_KEY.equals(pluginKey) && mode.isPreview()) {
-      LOG.info("Build Breaker plugin is no more supported in preview/incremental mode");
+      LOG.info("Build Breaker plugin is no more supported in preview mode");
       return false;
     }
 
index 03a82d2752e07ab3c5df6880a5b98ce3c077df80..7f5a58a8b2d3e2ae51c139dee53ac4479ca82569 100644 (file)
@@ -25,38 +25,45 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
 
-import java.text.MessageFormat;
-
 public class GlobalMode {
   private static final Logger LOG = LoggerFactory.getLogger(GlobalMode.class);
   private boolean preview;
+  private boolean issues;
 
   public boolean isPreview() {
     return preview;
   }
 
+  public boolean isIssues() {
+    return issues;
+  }
+
+  public boolean isPublish() {
+    return !preview && !issues;
+  }
+
   public GlobalMode(BootstrapProperties props) {
-    if (props.property(CoreProperties.DRY_RUN) != null) {
-      LOG.warn(MessageFormat.format("Property {0} is deprecated. Please use {1} instead.", CoreProperties.DRY_RUN, CoreProperties.ANALYSIS_MODE));
-      preview = "true".equals(props.property(CoreProperties.DRY_RUN));
-    } else {
-      String mode = props.property(CoreProperties.ANALYSIS_MODE);
-      validate(mode);
-      preview = CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode) || CoreProperties.ANALYSIS_MODE_QUICK.equals(mode);
-    }
+    String mode = props.property(CoreProperties.ANALYSIS_MODE);
+    validate(mode);
+    preview = CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode);
+    issues = CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode);
 
     if (preview) {
       LOG.info("Preview global mode");
+    } else if (issues) {
+      LOG.info("Issues global mode");
+    } else {
+      LOG.info("Publish global mode");
     }
   }
 
-  private void validate(String mode) {
+  private static void validate(String mode) {
     if (StringUtils.isEmpty(mode)) {
       return;
     }
 
-    if (!CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode) && !CoreProperties.ANALYSIS_MODE_QUICK.equals(mode) &&
-      !CoreProperties.ANALYSIS_MODE_ANALYSIS.equals(mode)) {
+    if (!CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode) && !CoreProperties.ANALYSIS_MODE_PUBLISH.equals(mode) &&
+      !CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode)) {
       throw new IllegalStateException("Invalid analysis mode: " + mode);
     }
   }
index db7f0c730fbee575cf60c74eaab1844887b91ef3..a2d390010719ca0beff3422f2b2f97828e2436cc 100644 (file)
@@ -66,11 +66,6 @@ public class GlobalSettings extends Settings {
     addProperties(globalReferentials.globalSettings());
     addProperties(bootstrapProps.properties());
 
-    // To stay compatible with plugins that use the old property to check mode
-    if (mode.isPreview()) {
-      setProperty(CoreProperties.DRY_RUN, "true");
-    }
-
     LOG.info("Server id: " + getString(CoreProperties.SERVER_ID));
   }
 
index f92a2577cf8c4ae9bd9fe999dc083409237351e3..569566093eb8f5ff8aabea7bd8943b7d28b5a85d 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.batch.scan;
 
+import org.sonar.batch.mediumtest.FakePluginInstaller;
+
 import org.apache.commons.lang.StringUtils;
 import org.sonar.batch.bootstrap.BootstrapProperties;
 import org.sonar.batch.bootstrap.AnalysisProperties;
@@ -26,9 +28,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.AnalysisMode;
-import org.sonar.batch.mediumtest.BatchMediumTester;
 
-import java.text.MessageFormat;
 import java.util.Map;
 
 /**
@@ -55,7 +55,7 @@ public class ProjectAnalysisMode implements AnalysisMode {
   public boolean isIssues() {
     return issues;
   }
-  
+
   @Override
   public boolean isPublish() {
     return !preview && !issues;
@@ -78,16 +78,11 @@ public class ProjectAnalysisMode implements AnalysisMode {
   }
 
   private void load(Map<String, String> globalProps, Map<String, String> analysisProps) {
-    if (getPropertyWithFallback(analysisProps, globalProps, CoreProperties.DRY_RUN) != null) {
-      LOG.warn(MessageFormat.format("Property {0} is deprecated. Please use {1} instead.", CoreProperties.DRY_RUN, CoreProperties.ANALYSIS_MODE));
-      preview = "true".equals(getPropertyWithFallback(analysisProps, globalProps, CoreProperties.DRY_RUN));
-    } else {
-      String mode = getPropertyWithFallback(analysisProps, globalProps, CoreProperties.ANALYSIS_MODE);
-      validate(mode);
-      preview = CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode);
-      issues = CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode);
-    }
-    mediumTestMode = "true".equals(getPropertyWithFallback(analysisProps, globalProps, BatchMediumTester.MEDIUM_TEST_ENABLED));
+    String mode = getPropertyWithFallback(analysisProps, globalProps, CoreProperties.ANALYSIS_MODE);
+    validate(mode);
+    preview = CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode);
+    issues = CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode);
+    mediumTestMode = "true".equals(getPropertyWithFallback(analysisProps, globalProps, FakePluginInstaller.MEDIUM_TEST_ENABLED));
 
     if (preview) {
       LOG.info("Preview mode");
@@ -115,14 +110,15 @@ public class ProjectAnalysisMode implements AnalysisMode {
     return CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode);
   }
 
-  private void validate(String mode) {
+  private static void validate(String mode) {
     if (StringUtils.isEmpty(mode)) {
       return;
     }
 
-    if (!CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode) && !CoreProperties.ANALYSIS_MODE_QUICK.equals(mode) &&
-      !CoreProperties.ANALYSIS_MODE_ANALYSIS.equals(mode)) {
+    if (!CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode) && !CoreProperties.ANALYSIS_MODE_PUBLISH.equals(mode) &&
+      !CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode)) {
       throw new IllegalStateException("Invalid analysis mode: " + mode);
     }
   }
 }
+
index 937281d2fba66a7454413de4b978e7367096d4c7..66429da2715b7106a4a9765251f833e6c1fbe8ae 100644 (file)
@@ -79,23 +79,6 @@ public class BatchPluginPredicateTest {
     assertThat(predicate.apply("cobertura")).isTrue();
   }
 
-  /**
-   * The properties sonar.dryRun.includePlugins and sonar.dryRun.excludePlugins
-   * are deprecated. They are replaced by sonar.preview.includePlugins and
-   * sonar.preview.excludePlugins.
-   */
-  @Test
-  public void support_deprecated_dry_run_settings() {
-    when(mode.isPreview()).thenReturn(true);
-    settings
-      .setProperty(CoreProperties.DRY_RUN_INCLUDE_PLUGINS, "cockpit")
-      .setProperty(CoreProperties.DRY_RUN_EXCLUDE_PLUGINS, "views,pmd");
-    BatchPluginPredicate predicate = new BatchPluginPredicate(settings, mode);
-
-    assertThat(predicate.getWhites()).containsOnly("cockpit");
-    assertThat(predicate.getBlacks()).containsOnly("views", "pmd");
-  }
-
   @Test
   public void trim_inclusions_and_exclusions() {
     settings
index bbdbcf78aa3ffe080c5013ac0bca0454481d6e62..50aaa6f53b50ab2ac012fb422036c914c5d19672 100644 (file)
@@ -40,12 +40,6 @@ public class GlobalModeTest {
     assertThat(mode.isPreview()).isFalse();
   }
 
-  @Test
-  public void testDeprecatedDryRun() {
-    GlobalMode mode = createMode(CoreProperties.DRY_RUN, "true");
-    assertThat(mode.isPreview()).isTrue();
-  }
-
   private GlobalMode createMode(String key, String value) {
     Map<String, String> map = new HashMap<>();
     map.put(key, value);
index b48ebc78db4d60e2a89b41921119201880b9a05f..b9a2e32fde65176e4a431cc8ffc3609ebfc01ab5 100644 (file)
  */
 package org.sonar.batch.bootstrap;
 
-import org.sonar.api.CoreProperties;
-
 import java.util.Collections;
 
-import static org.mockito.Mockito.when;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -63,13 +60,6 @@ public class GlobalSettingsTest {
 
     assertThat(batchSettings.getBoolean("sonar.cpd.cross")).isTrue();
   }
-  
-  @Test
-  public void support_deprecated_dry_run() {
-    when(mode.isPreview()).thenReturn(true);
-    GlobalSettings batchSettings = new GlobalSettings(bootstrapProps, new PropertyDefinitions(), globalRef, mode);
-    assertThat(batchSettings.getString(CoreProperties.DRY_RUN)).isEqualTo("true");
-  }
 
   @Test
   public void should_log_warn_msg_for_each_jdbc_property_if_present() {
index 29b866f8903a1d89fc76a92ebf8038b1b17e30ab..822e0b88350c98f33e3dceebf6b0b3f776349a5c 100644 (file)
@@ -63,15 +63,15 @@ public class ProjectAnalysisModeTest {
 
     assertThat(mode.isPreview()).isTrue();
   }
-  
+
   @Test
   public void default_publish_mode() {
     ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_PREVIEW);
     assertThat(mode.isPublish()).isFalse();
-    
+
     mode = createMode(CoreProperties.ANALYSIS_MODE_ISSUES);
     assertThat(mode.isPublish()).isFalse();
-    
+
     mode = createMode(null);
 
     assertThat(mode.isPublish()).isTrue();
@@ -84,19 +84,6 @@ public class ProjectAnalysisModeTest {
     assertThat(mode.isIssues()).isTrue();
   }
 
-  @Test
-  public void support_deprecated_dryrun_property() {
-    Map<String, String> bootstrapMap = new HashMap<>();
-    Map<String, String> analysisMap = new HashMap<>();
-
-    analysisMap.put(CoreProperties.DRY_RUN, "true");
-    bootstrapMap.put(CoreProperties.DRY_RUN, "true");
-
-    ProjectAnalysisMode mode = new ProjectAnalysisMode(new BootstrapProperties(bootstrapMap), new AnalysisProperties(analysisMap));
-
-    assertThat(mode.isPreview()).isTrue();
-  }
-
   private static ProjectAnalysisMode createMode(@Nullable String mode) {
     return createMode(mode, mode);
   }
index 1d923e27a268a00a744c0b6fff52795f2aeca4c3..16bf5b320625b859a48c3252b6a1fcb7cb434325 100644 (file)
@@ -106,7 +106,7 @@ public class ProjectSettingsTest {
   }
 
   @Test
-  public void should_fail_when_accessing_secured_properties_in_dryrun() {
+  public void should_fail_when_accessing_secured_properties_in_issues_mode() {
     projectRef.addSettings("struts", ImmutableMap.of("sonar.foo.secured", "bar", "sonar.foo.license.secured", "bar2"));
 
     when(mode.isIssues()).thenReturn(true);
index 81a71dc3f3ce7ca8768b50e97f34822bb99f2d66..33c6801afb4ea340e338867ca654e39e6a5f2537 100644 (file)
@@ -86,16 +86,14 @@ public class CorePropertyDefinitions {
         .hidden()
         .build(),
       PropertyDefinition.builder(CoreProperties.PREVIEW_INCLUDE_PLUGINS)
-        .deprecatedKey(CoreProperties.DRY_RUN_INCLUDE_PLUGINS)
-        .name("Plugins accepted for Preview and Incremental modes")
-        .description("Comma-separated list of plugin keys. Those plugins will be used during preview or incremental analyses.")
+        .name("Plugins accepted for Preview mode")
+        .description("Comma-separated list of plugin keys. Those plugins will be used during preview analyses.")
         .category(CoreProperties.CATEGORY_GENERAL)
         .defaultValue(CoreProperties.PREVIEW_INCLUDE_PLUGINS_DEFAULT_VALUE)
         .build(),
       PropertyDefinition.builder(CoreProperties.PREVIEW_EXCLUDE_PLUGINS)
-        .deprecatedKey(CoreProperties.DRY_RUN_EXCLUDE_PLUGINS)
-        .name("Plugins excluded for Preview and Incremental modes")
-        .description("Comma-separated list of plugin keys. Those plugins will not be used during preview or incremental analyses.")
+        .name("Plugins excluded for Preview mode")
+        .description("Comma-separated list of plugin keys. Those plugins will not be used during preview analyses.")
         .category(CoreProperties.CATEGORY_GENERAL)
         .defaultValue(CoreProperties.PREVIEW_EXCLUDE_PLUGINS_DEFAULT_VALUE)
         .build(),
index 40b4430cb41e2d429867c24711ab236179e04814..eabe96955c3d4af8bfca3785f85667eb30dc10e9 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.api;
 
-import org.sonar.api.batch.AnalysisMode;
 import org.sonar.api.batch.fs.FileSystem;
 
 /**
@@ -380,13 +379,6 @@ public interface CoreProperties {
    */
   String PASSWORD = "sonar.password";
 
-  /**
-   * @since 3.4
-   * @deprecated since 5.1 use {@link AnalysisMode} to check existing mode
-   */
-  @Deprecated
-  String DRY_RUN = "sonar.dryRun";
-
   /**
    * @since 3.5
    * @deprecated since 5.2 no more task concept on batch side
@@ -486,32 +478,6 @@ public interface CoreProperties {
   String GLOBAL_WORKING_DIRECTORY = "sonar.globalWorking.directory";
   String GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE = ".";
 
-  /**
-   * @since 3.4
-   * @deprecated in 4.0 replaced by {@link CoreProperties#PREVIEW_INCLUDE_PLUGINS}
-   */
-  @Deprecated
-  String DRY_RUN_INCLUDE_PLUGINS = "sonar.dryRun.includePlugins";
-  /**
-   * @since 3.4
-   * @deprecated in 4.0 replaced by {@link CoreProperties#PREVIEW_INCLUDE_PLUGINS_DEFAULT_VALUE}
-   */
-  @Deprecated
-  String DRY_RUN_INCLUDE_PLUGINS_DEFAULT_VALUE = PREVIEW_INCLUDE_PLUGINS_DEFAULT_VALUE;
-
-  /**
-   * @since 3.4
-   * @deprecated in 4.0 replaced by {@link CoreProperties#PREVIEW_EXCLUDE_PLUGINS}
-   */
-  @Deprecated
-  String DRY_RUN_EXCLUDE_PLUGINS = "sonar.dryRun.excludePlugins";
-  /**
-   * @since 3.4
-   * @deprecated in 4.0 replaced by {@link CoreProperties#PREVIEW_EXCLUDE_PLUGINS_DEFAULT_VALUE}
-   */
-  @Deprecated
-  String DRY_RUN_EXCLUDE_PLUGINS_DEFAULT_VALUE = PREVIEW_EXCLUDE_PLUGINS_DEFAULT_VALUE;
-
   /**
    * @since 4.2
    */