aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2018-11-14 11:21:10 +0100
committersonartech <sonartech@sonarsource.com>2019-01-16 09:42:59 +0100
commite48d9b29484c8e23fb0ebdae73bfceb27e656374 (patch)
tree8b48dee7a082a9ac765a4a220062e120d13a6fa8
parentaec83bafc952d4786fa9552fb8749c9efce517b5 (diff)
downloadsonarqube-e48d9b29484c8e23fb0ebdae73bfceb27e656374.tar.gz
sonarqube-e48d9b29484c8e23fb0ebdae73bfceb27e656374.zip
SONAR-11465 Deprecate task extensions
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/task/Task.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/task/TaskDefinition.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java9
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java3
5 files changed, 19 insertions, 1 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
index 4670e0e371a..5bbb4974373 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
@@ -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";
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/task/Task.java b/sonar-plugin-api/src/main/java/org/sonar/api/task/Task.java
index c1d71c412f3..449255f6791 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/task/Task.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/task/Task.java
@@ -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();
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/task/TaskDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/task/TaskDefinition.java
index dfee4d2ca7a..06f781bf264 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/task/TaskDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/task/TaskDefinition.java
@@ -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\\-\\_]+";
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java
index a1f057b3c88..22e8d58b95e 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java
@@ -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();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java
index fa51827e8ea..47ce068d0cc 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java
@@ -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