diff options
Diffstat (limited to 'sonar-start')
-rw-r--r-- | sonar-start/src/main/java/org/sonar/start/Env.java | 4 | ||||
-rw-r--r-- | sonar-start/src/main/java/org/sonar/start/StartServer.java | 13 |
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 |