diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-09-06 17:47:59 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-09-13 15:50:55 +0200 |
commit | a444ad1e6bef78386f960acadb0fee7e0b4d8224 (patch) | |
tree | a1711c1c6ec701781882571e9f791c1e37876eeb /server/sonar-main | |
parent | 7e778849d1c669cd87c90de21cb3d1ea6494e759 (diff) | |
download | sonarqube-a444ad1e6bef78386f960acadb0fee7e0b4d8224.tar.gz sonarqube-a444ad1e6bef78386f960acadb0fee7e0b4d8224.zip |
SONAR-9587 use classpath rather than fat jar for sonar-application
Diffstat (limited to 'server/sonar-main')
-rw-r--r-- | server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java | 4 | ||||
-rw-r--r-- | server/sonar-main/src/test/java/org/sonar/application/App.java | 29 |
2 files changed, 31 insertions, 2 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java b/server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java index 50436b6468c..e9c5ebc89ec 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java +++ b/server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java @@ -74,9 +74,9 @@ public class AppSettingsLoaderImpl implements AppSettingsLoader { private static File detectHomeDir() { try { - File appJar = new File(AppSettingsLoaderImpl.class.getProtectionDomain().getCodeSource().getLocation().toURI()); + File appJar = new File(Class.forName("org.sonar.application.App").getProtectionDomain().getCodeSource().getLocation().toURI()); return appJar.getParentFile().getParentFile(); - } catch (URISyntaxException e) { + } catch (URISyntaxException | ClassNotFoundException e) { throw new IllegalStateException("Cannot detect path of main jar file", e); } } diff --git a/server/sonar-main/src/test/java/org/sonar/application/App.java b/server/sonar-main/src/test/java/org/sonar/application/App.java new file mode 100644 index 00000000000..d084227359e --- /dev/null +++ b/server/sonar-main/src/test/java/org/sonar/application/App.java @@ -0,0 +1,29 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * 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 02110-1301, USA. + */ +package org.sonar.application; + +/** + * This class is looked for by {@link org.sonar.application.config.AppSettingsLoaderImpl} to locate the location + * of SQ's sonar-application jar file. + * + * Adding a fake one here to be able to test the feature in {@link org.sonar.application.config.AppSettingsLoaderImplTest}. + */ +public class App { +} |