aboutsummaryrefslogtreecommitdiffstats
path: root/tests/plugins/posttask-plugin/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins/posttask-plugin/src/main/java')
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java35
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java36
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java62
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java29
4 files changed, 162 insertions, 0 deletions
diff --git a/tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java b/tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java
new file mode 100644
index 00000000000..7013a6707a8
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java
@@ -0,0 +1,35 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.
+ */
+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/tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java b/tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java
new file mode 100644
index 00000000000..120610a2da2
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.
+ */
+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/tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java b/tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java
new file mode 100644
index 00000000000..0c288ec01d5
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java
@@ -0,0 +1,62 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.
+ */
+
+/*
+ * 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.ce.posttask.CeTask;
+import org.sonar.api.ce.posttask.PostProjectAnalysisTask;
+import org.sonar.api.ce.posttask.Project;
+import org.sonar.api.ce.posttask.QualityGate;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+public class PostProjectAnalysisTaskImpl implements PostProjectAnalysisTask {
+ private static final Logger LOG = Loggers.get(PostProjectAnalysisTaskImpl.class);
+
+ @Override
+ public void finished(ProjectAnalysis analysis) {
+ CeTask ceTask = analysis.getCeTask();
+ Project project = analysis.getProject();
+ QualityGate qualityGate = analysis.getQualityGate();
+ LOG.info("POSTASKPLUGIN: finished() CeTask[{}][{}] Project[{}] Date[{}] QualityGate[{}]",
+ ceTask.getStatus(),
+ ceTask.getId(),
+ project.getKey(),
+ analysis.getDate().getTime(),
+ qualityGate == null ? null : qualityGate.getStatus());
+ }
+}
diff --git a/tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java b/tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java
new file mode 100644
index 00000000000..07ce105ff4e
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java
@@ -0,0 +1,29 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.
+ */
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public class PostTaskPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(PostProjectAnalysisTaskImpl.class,
+ LogScannerContextPostTask.class, AddScannerContextSensor.class);
+ }
+}