JavaPlugin implements Plugin { @SuppressWarnings("unchecked") @Override public void define(Context context) { ImmutableList.Builder<Object> builder = ImmutableList.builder(); if (context.getRuntime().getProduct() == SonarProduct.SONARLINT) { builder.add(JavaSonarLintClasspath.class); } else { builder.addAll(SurefireExtensions.getExtensions()); builder.add(DroppedPropertiesSensor.class); builder.add(JavaSonarWayProfile.class); builder.add(JavaClasspath.class); builder.add(PropertyDefinition.builder(SonarComponents.FAIL_ON_EXCEPTION_KEY) .defaultValue("false") .hidden() .name("Fail on exceptions") .description("when set to true, if an exception is thrown by the analyzer the analysis will fail") .build()); ExternalReportExtensions.define(context); } if (supportJspTranspilation(context)) { builder.add(Jasper.class); } builder.addAll(JavaClasspathProperties.getProperties()); builder.add( JavaTestClasspath.class, Java.class, PropertyDefinition.builder(Java.FILE_SUFFIXES_KEY) .defaultValue(Java.DEFAULT_FILE_SUFFIXES) .category(JavaConstants.JAVA_CATEGORY) .name("File suffixes") .multiValues(true) .description("Comma-separated list of suffixes for files to analyze. To not filter, leave the list empty.") .subCategory("General") .onQualifiers(Qualifiers.PROJECT) .build(), JavaRulesDefinition.class, SonarComponents.class, DefaultJavaResourceLocator.class, JavaSquidSensor.class, PostAnalysisIssueFilter.class, XmlFileSensor.class ); builder.add(AnalysisWarningsWrapper.class); context.addExtensions(builder.build()); }  @SuppressWarnings("unchecked") @Override void define(Context context);  }
@Test void sonarLint_7_9_extensions() { SonarRuntime runtime = SonarRuntimeImpl.forSonarLint(VERSION_7_9); Plugin.Context context = new Plugin.Context(runtime); javaPlugin.define(context); assertThat(context.getExtensions()).hasSize(15); }
@Test void sonarqube_7_9_extensions() { Plugin.Context context = new Plugin.Context(SQ_79_RUNTIME); javaPlugin.define(context); assertThat(context.getExtensions()) .hasSize(32) .doesNotContain(Jasper.class); }
@Test void sonarqube_commercial_extensions_79() { SonarRuntime sqEnterprise = SonarRuntimeImpl.forSonarQube(VERSION_7_9, SonarQubeSide.SCANNER, SonarEdition.ENTERPRISE); Plugin.Context context = new Plugin.Context(sqEnterprise); javaPlugin.define(context); assertThat(context.getExtensions()) .hasSize(32) .doesNotContain(Jasper.class); }
@Test void sonarqube_commercial_extensions_83() { SonarRuntime sqEnterprise = SonarRuntimeImpl.forSonarQube(Version.create(8, 3), SonarQubeSide.SCANNER, SonarEdition.ENTERPRISE); Plugin.Context context = new Plugin.Context(sqEnterprise); javaPlugin.define(context); assertThat(context.getExtensions()) .hasSize(33) .contains(Jasper.class); }