public AnalysisResult execute() { AnalysisResult result = new AnalysisResult(); Map<String, String> props = new HashMap<>(); props.putAll(tester.globalProperties); props.putAll(taskProperties); Batch.builder() .setGlobalProperties(props) .setEnableLoggingConfiguration(true) .addComponents(new EnvironmentInformation("mediumTest", "1.0"), tester.pluginInstaller, tester.globalRefProvider, tester.qualityProfiles, tester.rulesLoader, tester.branchConfigurationLoader, tester.projectRefProvider, tester.activeRules, tester.serverIssues, tester.settingsLoader, result) .setLogOutput(tester.logOutput) .build().execute(); return result; }
private Batch(Builder builder) { components = new ArrayList<>(); components.addAll(builder.components); if (builder.environment != null) { components.add(builder.environment); } if (builder.globalProperties != null) { globalProperties.putAll(builder.globalProperties); } if (builder.isEnableLoggingConfiguration()) { loggingConfig = new LoggingConfiguration(builder.environment).setProperties(globalProperties); if (builder.logOutput != null) { loggingConfig.setLogOutput(builder.logOutput); } } }
public void setUp(boolean verbose) { Batch.Builder builder = Batch.builder() .setEnableLoggingConfiguration(true) .addComponents( loader, new EnvironmentInformation("mediumTest", "1.0")); if (verbose) { builder.setBootstrapProperties(Collections.singletonMap("sonar.verbose", "true")); } batch = builder.build(); }
private Batch(Builder builder) { components = Lists.newArrayList(); components.addAll(builder.components); if (builder.environment != null) { components.add(builder.environment); } if (builder.bootstrapProperties != null) { bootstrapProperties.putAll(builder.bootstrapProperties); } if (builder.isEnableLoggingConfiguration()) { loggingConfig = new LoggingConfiguration(builder.environment).setProperties(bootstrapProperties); if (builder.logOutput != null) { loggingConfig.setLogOutput(builder.logOutput); } } }
private Batch(Builder builder) { components = new ArrayList<>(); components.addAll(builder.components); if (builder.environment != null) { components.add(builder.environment); } if (builder.globalProperties != null) { globalProperties.putAll(builder.globalProperties); } if (builder.isEnableLoggingConfiguration()) { loggingConfig = new LoggingConfiguration(builder.environment).setProperties(globalProperties); if (builder.logOutput != null) { loggingConfig.setLogOutput(builder.logOutput); } } }
@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(); } }
private BatchMediumTester(BatchMediumTesterBuilder builder) { batch = Batch.builder() .setEnableLoggingConfiguration(true) .addComponents( new EnvironmentInformation("mediumTest", "1.0"), builder.pluginsReferential, builder.globalRefProvider, builder.projectRefProvider, builder.serverIssues, builder.serverLineHashes, new DefaultDebtModel()) .setBootstrapProperties(builder.bootstrapProperties) .build(); }
public static Builder builder() { return new Builder(); }
public static Builder builder() { return new Builder(); }
public static Builder builder() { return new Builder(); }
@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(); } }
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(); }
static void setLogOutputFor5dot2(Batch.Builder builder, final org.sonar.runner.batch.LogOutput logOutput) { builder.setLogOutput(new LogOutput() { @Override public void log(String formattedMessage, Level level) { logOutput.log(formattedMessage, org.sonar.runner.batch.LogOutput.Level.valueOf(level.name())); } }); }
@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(); } }
private Batch(Builder builder) { components = Lists.newArrayList(); components.addAll(builder.components); if (builder.environment != null) { components.add(builder.environment); } if (builder.bootstrapProperties != null) { bootstrapProperties.putAll(builder.bootstrapProperties); } if (builder.isEnableLoggingConfiguration()) { logging = LoggingConfiguration.create(builder.environment).setProperties(bootstrapProperties); } }
public static Builder builder() { return new Builder(); }
@Test(expected = IllegalStateException.class) public void shouldFailIfNullComponents() { Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .setComponents(null) .build(); }
@Test public void shouldDisableLoggingConfiguration() { Batch batch = Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .addComponent("fake") .setEnableLoggingConfiguration(false) .build(); assertNull(batch.getLoggingConfiguration()); }
@Test public void shoudSetLogListener() { LogOutput logOutput = mock(LogOutput.class); Batch batch = Batch.builder().setLogOutput(logOutput).build(); assertThat(batch.getLoggingConfiguration().getLogOutput()).isEqualTo(logOutput); } }
private Batch newBatch() { return Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .addComponent("fake") .build(); }