aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-start
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@searchbox.com>2014-07-11 11:29:34 +0200
committerStephane Gamard <stephane.gamard@searchbox.com>2014-07-11 11:32:04 +0200
commitb7615d4be1f4efdc6ba091c65d22fe0689b1e684 (patch)
tree6c1fde07dbd0cf5c4c22a8f41fbca9906fde566d /sonar-start
parenta404f337cdee4b90c13d01269f90b9fc31e196d4 (diff)
downloadsonarqube-b7615d4be1f4efdc6ba091c65d22fe0689b1e684.tar.gz
sonarqube-b7615d4be1f4efdc6ba091c65d22fe0689b1e684.zip
SONAR-5408 -Using SONAR_HOME and/or setting it
Diffstat (limited to 'sonar-start')
-rw-r--r--sonar-start/src/main/java/org/sonar/start/Env.java4
-rw-r--r--sonar-start/src/main/java/org/sonar/start/StartServer.java13
2 files changed, 14 insertions, 3 deletions
diff --git a/sonar-start/src/main/java/org/sonar/start/Env.java b/sonar-start/src/main/java/org/sonar/start/Env.java
index 51a6592ad69..dbb947341ec 100644
--- a/sonar-start/src/main/java/org/sonar/start/Env.java
+++ b/sonar-start/src/main/java/org/sonar/start/Env.java
@@ -32,8 +32,8 @@ class Env {
private final File confFile;
private final File homeDir;
- public Env(File homeDir) throws URISyntaxException {
- this.homeDir = homeDir;
+ public Env(String homeDir) throws URISyntaxException {
+ this.homeDir = new File(homeDir);
this.confFile = new File(CONF_DIRECTORY+"/sonar.properties");
}
diff --git a/sonar-start/src/main/java/org/sonar/start/StartServer.java b/sonar-start/src/main/java/org/sonar/start/StartServer.java
index b45fec0e273..fa50ff60033 100644
--- a/sonar-start/src/main/java/org/sonar/start/StartServer.java
+++ b/sonar-start/src/main/java/org/sonar/start/StartServer.java
@@ -20,6 +20,7 @@
package org.sonar.start;
import com.google.common.collect.ImmutableMap;
+import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.process.MonitorService;
@@ -40,6 +41,8 @@ public final class StartServer {
private final static Logger LOGGER = LoggerFactory.getLogger(StartServer.class);
+ private final static String SONAR_HOME = "SONAR_HOME";
+
private final Env env;
private final ExecutorService executor;
private final MonitorService monitor;
@@ -138,7 +141,15 @@ public final class StartServer {
}
public static void main(String... args) throws InterruptedException, IOException, URISyntaxException {
- File home = new File(".");
+
+ String home = System.getenv(SONAR_HOME);
+
+ //Check if we have a SONAR_HOME
+ if (StringUtils.isEmpty(home)) {
+ home = new File(".").getAbsolutePath();
+ System.getenv().put("SONAR_HOME", home);
+ }
+
new StartServer(new Env(home), args).start();
}
} \ No newline at end of file