diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2018-12-04 14:51:21 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-01-16 09:43:05 +0100 |
commit | 4660315c13ba09f58f5034ca99b855ece9f75e25 (patch) | |
tree | 97152755ad675a2b77ca36d9889558c280988e14 /plugins | |
parent | 19a03e51f75d342155079b808fa879ece194a196 (diff) | |
download | sonarqube-4660315c13ba09f58f5034ca99b855ece9f75e25.tar.gz sonarqube-4660315c13ba09f58f5034ca99b855ece9f75e25.zip |
SONAR-11465 Add project level Sensor EP
Diffstat (limited to 'plugins')
3 files changed, 50 insertions, 2 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java index cc8689f5a12..73efd1d2580 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java @@ -31,6 +31,7 @@ import org.sonar.xoo.coverage.UtCoverageSensor; import org.sonar.xoo.extensions.XooIssueFilter; import org.sonar.xoo.extensions.XooPostJob; import org.sonar.xoo.extensions.XooProjectBuilder; +import org.sonar.xoo.global.DeprecatedGlobalSensor; import org.sonar.xoo.global.GlobalSensor; import org.sonar.xoo.lang.CpdTokenizerSensor; import org.sonar.xoo.lang.LineMeasureSensor; @@ -170,6 +171,9 @@ public class XooPlugin implements Plugin { context.addExtension(XooBuiltInQualityProfilesDefinition.class); } if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(6, 4))) { + context.addExtension(DeprecatedGlobalSensor.class); + } + if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 6))) { context.addExtension(GlobalSensor.class); } if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 2))) { diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/DeprecatedGlobalSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/DeprecatedGlobalSensor.java new file mode 100644 index 00000000000..5d241aaba99 --- /dev/null +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/DeprecatedGlobalSensor.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.xoo.global; + +import org.sonar.api.batch.sensor.Sensor; +import org.sonar.api.batch.sensor.SensorContext; +import org.sonar.api.batch.sensor.SensorDescriptor; +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.Loggers; + +public class DeprecatedGlobalSensor implements Sensor { + + private static final Logger LOG = Loggers.get(DeprecatedGlobalSensor.class); + public static final String ENABLE_PROP = "sonar.scanner.mediumtest.deprecatedGlobalSensor"; + + @Override + public void describe(SensorDescriptor descriptor) { + descriptor + .name("Deprecated Global Sensor") + .global() + .onlyWhenConfiguration(c -> c.hasKey(ENABLE_PROP)); + } + + @Override + public void execute(SensorContext context) { + context.fileSystem().inputFiles(context.fileSystem().predicates().all()).forEach(inputFile -> LOG.info("Deprecated Global Sensor: {}", inputFile.relativePath())); + } +} diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java index d6bbf83f8c4..e4aef94c692 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java @@ -19,7 +19,7 @@ */ package org.sonar.xoo.global; -import org.sonar.api.batch.sensor.Sensor; +import org.sonar.api.scanner.sensor.Sensor; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.SensorDescriptor; import org.sonar.api.utils.log.Logger; @@ -34,7 +34,6 @@ public class GlobalSensor implements Sensor { public void describe(SensorDescriptor descriptor) { descriptor .name("Global Sensor") - .global() .onlyWhenConfiguration(c -> c.hasKey(ENABLE_PROP)); } |