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.

SystemInfo.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * SonarQube Runner - CLI - Distribution
  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.cli;
  21. import org.sonar.runner.api.RunnerVersion;
  22. class SystemInfo {
  23. private static System2 system = new System2();
  24. private SystemInfo() {
  25. }
  26. static void setSystem(System2 system) {
  27. SystemInfo.system = system;
  28. }
  29. static void print() {
  30. Logs.info("SonarQube Runner " + RunnerVersion.version());
  31. Logs.info(java());
  32. Logs.info(os());
  33. String runnerOpts = system.getenv("SONAR_RUNNER_OPTS");
  34. if (runnerOpts != null) {
  35. Logs.info("SONAR_RUNNER_OPTS=" + runnerOpts);
  36. }
  37. }
  38. static String java() {
  39. StringBuilder sb = new StringBuilder();
  40. sb
  41. .append("Java ")
  42. .append(system.getProperty("java.version"))
  43. .append(" ")
  44. .append(system.getProperty("java.vendor"));
  45. String bits = system.getProperty("sun.arch.data.model");
  46. if ("32".equals(bits) || "64".equals(bits)) {
  47. sb.append(" (").append(bits).append("-bit)");
  48. }
  49. return sb.toString();
  50. }
  51. static String os() {
  52. StringBuilder sb = new StringBuilder();
  53. sb
  54. .append(system.getProperty("os.name"))
  55. .append(" ")
  56. .append(system.getProperty("os.version"))
  57. .append(" ")
  58. .append(system.getProperty("os.arch"));
  59. return sb.toString();
  60. }
  61. static class System2 {
  62. String getProperty(String key) {
  63. return System.getProperty(key);
  64. }
  65. String getenv(String key) {
  66. return System.getenv(key);
  67. }
  68. }
  69. }