]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11465 Deprecate task extensions
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 14 Nov 2018 10:21:10 +0000 (11:21 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 16 Jan 2019 08:42:59 +0000 (09:42 +0100)
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
sonar-plugin-api/src/main/java/org/sonar/api/task/Task.java
sonar-plugin-api/src/main/java/org/sonar/api/task/TaskDefinition.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java

index 4670e0e371a4aa782d596936a16a8f90d283046f..5bbb4974373a6a4e27313778e61e2fdedb6677f0 100644 (file)
@@ -351,12 +351,16 @@ public interface CoreProperties {
 
   /**
    * @since 3.5
+   * @deprecated since 7.6
    */
+  @Deprecated
   String TASK = "sonar.task";
 
   /**
    * @since 3.6
+   * @deprecated since 7.6
    */
+  @Deprecated
   String SCAN_TASK = "scan";
 
   /**
index c1d71c412f3004649c5a801ab7bbab3d4a2ade9a..449255f6791830afc75b5b86549f89e1af9a2403 100644 (file)
@@ -25,9 +25,11 @@ import org.sonar.api.batch.InstantiationStrategy;
 /**
  * Implement this interface to provide the behavior of a task.
  * @since 3.6
+ * @deprecated since 7.6
  */
 @ScannerSide
 @InstantiationStrategy(InstantiationStrategy.PER_TASK)
+@Deprecated
 public interface Task {
 
   void execute();
index dfee4d2ca7a1267c381dcf6c26e4fcc5a19beb86..06f781bf26430f3dfd89a6677d26bc7d826fddc6 100644 (file)
@@ -30,10 +30,12 @@ import org.sonar.api.batch.ScannerSide;
  * Register and describe a {@link TaskExtension}.
  *
  * @since 3.6
+ * @deprecated since 7.6
  */
 @ExtensionPoint
 @ScannerSide
 @InstantiationStrategy(InstantiationStrategy.PER_TASK)
+@Deprecated
 public class TaskDefinition implements Comparable<TaskDefinition> {
   static final String KEY_PATTERN = "[a-zA-Z0-9\\-\\_]+";
 
index a1f057b3c88fb04b3a9fe636489505aeb5ae7790..22e8d58b95e48f8bc3ebc6df8ca99d35eeaea0ef 100644 (file)
@@ -25,6 +25,8 @@ import org.sonar.api.CoreProperties;
 import org.sonar.api.task.Task;
 import org.sonar.api.task.TaskDefinition;
 import org.sonar.api.utils.MessageException;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
 import org.sonar.core.extension.CoreExtensionsInstaller;
 import org.sonar.core.platform.ComponentContainer;
 import org.sonar.scanner.bootstrap.ExtensionInstaller;
@@ -32,11 +34,13 @@ import org.sonar.scanner.bootstrap.GlobalProperties;
 
 import static org.sonar.api.batch.InstantiationStrategy.PER_TASK;
 import static org.sonar.core.extension.CoreExtensionsInstaller.noExtensionFilter;
-import static org.sonar.scanner.bootstrap.ExtensionUtils.isInstantiationStrategy;
 import static org.sonar.scanner.bootstrap.ExtensionUtils.isDeprecatedScannerSide;
+import static org.sonar.scanner.bootstrap.ExtensionUtils.isInstantiationStrategy;
 
 public class TaskContainer extends ComponentContainer {
 
+  private static final Logger LOG = Loggers.get(TaskContainer.class);
+
   private final Map<String, String> taskProperties;
   private final Object[] components;
 
@@ -70,6 +74,9 @@ public class TaskContainer extends ComponentContainer {
   public void doAfterStart() {
     // default value is declared in CorePlugin
     String taskKey = StringUtils.defaultIfEmpty(taskProperties.get(CoreProperties.TASK), CoreProperties.SCAN_TASK);
+    if (!taskKey.equals(CoreProperties.SCAN_TASK)) {
+      LOG.warn("Scanner tasks are deprecated");
+    }
     // Release memory
     taskProperties.clear();
 
index fa51827e8ea0fec5007a037b090999734b817afe..47ce068d0cc38fe0d836196c132484a3f51abd76 100644 (file)
@@ -29,6 +29,7 @@ import org.sonar.api.task.Task;
 import org.sonar.api.task.TaskDefinition;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -59,6 +60,8 @@ public class TasksMediumTest {
         return value.contains("Available tasks:") && value.contains("fake: Fake description") && value.contains("broken: Broken description");
       }
     });
+
+    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Scanner tasks are deprecated");
   }
 
   @Test