Batch createBatch(String sonarVersion, Properties properties, List<Object> extensions) { initLogging(properties); EnvironmentInformation env = new EnvironmentInformation(properties.getProperty("sonarRunner.app"), properties.getProperty("sonarRunner.appVersion")); return Batch.builder() .setEnvironment(env) .addComponents(extensions) .setBootstrapProperties((Map) properties) .build(); }
@Override public Batch createBatch(Map<String, String> properties, final org.sonarsource.scanner.api.internal.batch.LogOutput logOutput) { EnvironmentInformation env = new EnvironmentInformation(properties.get(SCANNER_APP_KEY), properties.get(SCANNER_APP_VERSION_KEY)); return Batch.builder() .setEnvironment(env) .setGlobalProperties(properties) .setLogOutput((formattedMessage, level) -> logOutput.log(formattedMessage, LogOutput.Level.valueOf(level.name()))) .build(); } }
@Override public Batch createBatch(Map<String, String> properties, final org.sonarsource.scanner.api.internal.batch.LogOutput logOutput) { EnvironmentInformation env = new EnvironmentInformation(properties.get(SCANNER_APP_KEY), properties.get(SCANNER_APP_VERSION_KEY)); return Batch.builder() .setEnvironment(env) .setGlobalProperties(properties) .setLogOutput((formattedMessage, level) -> logOutput.log(formattedMessage, LogOutput.Level.valueOf(level.name()))) .build(); } }
@Override public Batch createBatch(Properties properties, @Nullable final org.sonar.runner.batch.LogOutput logOutput, @Nullable List<Object> extensions) { EnvironmentInformation env = new EnvironmentInformation(properties.getProperty("sonarRunner.app"), properties.getProperty("sonarRunner.appVersion")); Batch.Builder builder = Batch.builder() .setEnvironment(env) .setBootstrapProperties((Map) properties); if (extensions != null) { builder.addComponents(extensions); } if (logOutput != null) { // Do that is a separate class to avoid NoClassDefFoundError for org/sonar/batch/bootstrapper/LogOutput Compatibility.setLogOutputFor5dot2(builder, logOutput); } return builder.build(); } }
@Test public void shouldDisableLoggingConfiguration() { Batch batch = Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .addComponent("fake") .setEnableLoggingConfiguration(false) .build(); assertNull(batch.getLoggingConfiguration()); }
@Test(expected = IllegalStateException.class) public void shouldFailIfNullComponents() { Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .setComponents(null) .build(); }
private Batch newBatch() { return Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .addComponent("fake") .build(); }