aboutsummaryrefslogtreecommitdiffstats
path: root/it/it-plugins/crash-plugin/src/main/java/CrashSensor.java
blob: 7fdd2576120ebdc63dfc43821c3239c541e95880 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import org.sonar.api.Properties;
import org.sonar.api.Property;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;

@Properties({
    @Property(
        key = "crash",
        name = "Property to decide if it crash or not",
        defaultValue = "false")
})
public class CrashSensor implements Sensor {

  private Settings settings;

  public CrashSensor(Settings settings) {
    this.settings = settings;
  }

  public boolean shouldExecuteOnProject(Project project) {
    return true;
  }

  public void analyse(Project project, SensorContext sensorContext) {
    if ("true".equals(settings.getString("crash"))) {
      throw new RuntimeException("Crash!");
    }
  }
}