You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DefaultBatchFactory.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * SonarQube Runner - Batch
  3. * Copyright (C) 2011 SonarSource
  4. * sonarqube@googlegroups.com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
  19. */
  20. package org.sonar.runner.batch;
  21. import org.picocontainer.annotations.Nullable;
  22. import org.sonar.batch.bootstrapper.Batch;
  23. import org.sonar.batch.bootstrapper.EnvironmentInformation;
  24. import java.util.List;
  25. import java.util.Map;
  26. import java.util.Properties;
  27. class DefaultBatchFactory implements BatchFactory {
  28. @Override
  29. public Batch createBatch(Properties properties, @Nullable final org.sonar.runner.batch.LogOutput logOutput, @Nullable List<Object> extensions) {
  30. EnvironmentInformation env = new EnvironmentInformation(properties.getProperty("sonarRunner.app"), properties.getProperty("sonarRunner.appVersion"));
  31. Batch.Builder builder = Batch.builder()
  32. .setEnvironment(env)
  33. .setBootstrapProperties((Map) properties);
  34. if (extensions != null) {
  35. builder.addComponents(extensions);
  36. }
  37. if (logOutput != null) {
  38. // Do that is a separate class to avoid NoClassDefFoundError for org/sonar/batch/bootstrapper/LogOutput
  39. Compatibility.setLogOutputFor5dot2(builder, logOutput);
  40. }
  41. return builder.build();
  42. }
  43. }