*/
package org.sonar.runner.api;
-import org.apache.commons.io.IOUtils;
-
import java.util.Scanner;
/**
* Version of this sonar-runner API.
+ *
* @since 2.2
*/
public enum RunnerVersion {
try {
this.version = scanner.next();
} finally {
- IOUtils.closeQuietly(scanner);
+ scanner.close();
}
}
}
package org.sonar.runner;
import org.sonar.runner.api.EmbeddedRunner;
-import org.sonar.runner.api.RunnerVersion;
import org.sonar.runner.impl.Logs;
import java.util.Properties;
}
void execute() {
- printSystem();
+ SystemInfo.print();
if (!cli.isDisplayVersionOnly()) {
int status = doExecute(new Conf(cli));
System.exit(status);
}
}
- private void printSystem() {
- System.out.println("Sonar Runner " + RunnerVersion.version());
- System.out.println("Java " + System.getProperty("java.version") + " (" + System.getProperty("java.vendor") + ")");
- System.out.println(System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch"));
- }
-
private int doExecute(Conf conf) {
if (cli.isDisplayStackTrace()) {
Logs.info("Error stacktraces are turned on.");
try {
Properties properties = conf.load();
EmbeddedRunner.create().addProperties(properties).execute();
+ // Logs.info("Work directory: " + runner.getWorkDir().getCanonicalPath());
-// Logs.debug("Other system properties:");
-// Logs.debug(" - sun.arch.data.model: \"" + System.getProperty("sun.arch.data.model") + "\"");
-// Logs.info("Server: " + runner.getSonarServerURL());
-// try {
-// Logs.info("Work directory: " + runner.getWorkDir().getCanonicalPath());
-// } catch (IOException e) {
-// throw new RunnerException("Unable to resolve directory", e);
-// }
} catch (Exception e) {
displayExecutionResult(stats, "FAILURE");
showError("Error during Sonar runner execution", e, cli.isDisplayStackTrace());
--- /dev/null
+/*
+ * Sonar Runner - Distribution
+ * Copyright (C) 2011 SonarSource
+ * dev@sonar.codehaus.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.runner;
+
+import org.sonar.runner.api.RunnerVersion;
+
+class SystemInfo {
+
+ static void print() {
+ System.out.println("Sonar Runner " + RunnerVersion.version());
+ System.out.println(java());
+ System.out.println(os());
+ }
+
+ static String java() {
+ StringBuilder sb = new StringBuilder();
+ sb
+ .append("Java ")
+ .append(System.getProperty("java.version"))
+ .append(" ")
+ .append(System.getProperty("java.vendor"));
+ String bits = System.getProperty("sun.arch.data.model");
+ if ("32".equals(bits) || "64".equals(bits)) {
+ sb.append(" (").append(bits).append("-bit)");
+ }
+ return sb.toString();
+ }
+
+ static String os() {
+ StringBuilder sb = new StringBuilder();
+ sb
+ .append(System.getProperty("os.name"))
+ .append(" ")
+ .append(System.getProperty("os.version"))
+ .append(" ")
+ .append(System.getProperty("os.arch"));
+ return sb.toString();
+ }
+}
--- /dev/null
+/*
+ * Sonar Runner - Distribution
+ * Copyright (C) 2011 SonarSource
+ * dev@sonar.codehaus.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.runner;
+
+import org.junit.Test;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class SystemInfoTest {
+ @Test
+ public void test_java() {
+ assertThat(SystemInfo.java()).matches("Java .* \\((32|64)-bit\\)");
+ }
+
+ @Test
+ public void test_os() {
+ assertThat(SystemInfo.os()).isNotEmpty();
+ }
+}
// Guava Suppliers#memoize() would be great here :D
if (version == null) {
version = downloadVersion();
+ Logs.info("Sonar Server " + version);
}
return version;
}