From: Julien HENRY Date: Wed, 14 Nov 2018 10:21:10 +0000 (+0100) Subject: SONAR-11465 Deprecate task extensions X-Git-Tag: 7.6~119 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e48d9b29484c8e23fb0ebdae73bfceb27e656374;p=sonarqube.git SONAR-11465 Deprecate task extensions --- 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 { 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 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