diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-08-06 11:28:40 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-08-06 12:52:33 +0200 |
commit | 8e6415a4c7444f7c6e03b10e8fa8eb535cc7e505 (patch) | |
tree | aacc9e22f21f755e98a9ac2ad945136ee36f0419 /it/it-plugins | |
parent | e55369090f3be4f1e4baa791b05c3f5cf1cef6e1 (diff) | |
download | sonarqube-8e6415a4c7444f7c6e03b10e8fa8eb535cc7e505.tar.gz sonarqube-8e6415a4c7444f7c6e03b10e8fa8eb535cc7e505.zip |
SONAR-7654 API to propagate props from scanner to CE
Diffstat (limited to 'it/it-plugins')
3 files changed, 75 insertions, 1 deletions
diff --git a/it/it-plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java b/it/it-plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java new file mode 100644 index 00000000000..34261a6e33b --- /dev/null +++ b/it/it-plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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. + */ + +import org.sonar.api.batch.sensor.Sensor; +import org.sonar.api.batch.sensor.SensorContext; +import org.sonar.api.batch.sensor.SensorDescriptor; + +public class AddScannerContextSensor implements Sensor { + @Override + public void execute(SensorContext context) { + context.addContextProperty("foo1", "bar1"); + context.addContextProperty("foo2", "bar2"); + } + + @Override + public void describe(SensorDescriptor descriptor) { + + } +} diff --git a/it/it-plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java b/it/it-plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java new file mode 100644 index 00000000000..55216b031b1 --- /dev/null +++ b/it/it-plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact 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. + */ + +import java.util.Map; +import org.sonar.api.ce.posttask.PostProjectAnalysisTask; +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.Loggers; + +public class LogScannerContextPostTask implements PostProjectAnalysisTask { + private static final Logger LOG = Loggers.get(LogScannerContextPostTask.class); + + @Override + public void finished(ProjectAnalysis analysis) { + for (Map.Entry<String, String> prop : analysis.getScannerContext().getProperties().entrySet()) { + LOG.info("POSTASKPLUGIN: ScannerProperty {}={}", + prop.getKey(), + prop.getValue()); + } + } +} diff --git a/it/it-plugins/posttask-plugin/src/main/java/PostTaskPlugin.java b/it/it-plugins/posttask-plugin/src/main/java/PostTaskPlugin.java index df813bb6599..69f2e0bbfa7 100644 --- a/it/it-plugins/posttask-plugin/src/main/java/PostTaskPlugin.java +++ b/it/it-plugins/posttask-plugin/src/main/java/PostTaskPlugin.java @@ -23,6 +23,7 @@ import org.sonar.api.SonarPlugin; public class PostTaskPlugin extends SonarPlugin { public List getExtensions() { - return Arrays.asList(PostProjectAnalysisTaskImpl.class); + return Arrays.asList(PostProjectAnalysisTaskImpl.class, + LogScannerContextPostTask.class, AddScannerContextSensor.class); } } |