diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2021-04-06 16:22:45 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-04-14 20:03:29 +0000 |
commit | eca5700aeaaa1b3a6c40c77318d33e98a6dd23dd (patch) | |
tree | 5e8dc292e4f2adfac3eaea166e3042b9815ec354 /server/sonar-main | |
parent | e0a058d7e9dc8cb4dce7b25e01d9702aa3554576 (diff) | |
download | sonarqube-eca5700aeaaa1b3a6c40c77318d33e98a6dd23dd.tar.gz sonarqube-eca5700aeaaa1b3a6c40c77318d33e98a6dd23dd.zip |
SONAR-14676 Shade core jars into a single jar
Diffstat (limited to 'server/sonar-main')
-rw-r--r-- | server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java | 11 | ||||
-rw-r--r-- | server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java | 12 |
2 files changed, 12 insertions, 11 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java b/server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java index 3475bb689fc..9bd07d512e6 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java +++ b/server/sonar-main/src/main/java/org/sonar/application/command/CommandFactoryImpl.java @@ -23,6 +23,8 @@ import java.io.File; import java.util.Map; import java.util.Optional; import org.slf4j.LoggerFactory; +import org.sonar.api.internal.MetadataLoader; +import org.sonar.api.utils.Version; import org.sonar.application.es.EsInstallation; import org.sonar.application.es.EsLogging; import org.sonar.application.es.EsSettings; @@ -32,8 +34,6 @@ import org.sonar.process.ProcessProperties; import org.sonar.process.Props; import org.sonar.process.System2; -import static org.sonar.process.ProcessProperties.Property.WEB_GRACEFUL_STOP_TIMEOUT; -import static org.sonar.process.ProcessProperties.parseTimeoutMs; import static org.sonar.process.ProcessProperties.Property.CE_GRACEFUL_STOP_TIMEOUT; import static org.sonar.process.ProcessProperties.Property.CE_JAVA_ADDITIONAL_OPTS; import static org.sonar.process.ProcessProperties.Property.CE_JAVA_OPTS; @@ -50,8 +50,10 @@ import static org.sonar.process.ProcessProperties.Property.SEARCH_JAVA_ADDITIONA import static org.sonar.process.ProcessProperties.Property.SEARCH_JAVA_OPTS; import static org.sonar.process.ProcessProperties.Property.SOCKS_PROXY_HOST; import static org.sonar.process.ProcessProperties.Property.SOCKS_PROXY_PORT; +import static org.sonar.process.ProcessProperties.Property.WEB_GRACEFUL_STOP_TIMEOUT; import static org.sonar.process.ProcessProperties.Property.WEB_JAVA_ADDITIONAL_OPTS; import static org.sonar.process.ProcessProperties.Property.WEB_JAVA_OPTS; +import static org.sonar.process.ProcessProperties.parseTimeoutMs; public class CommandFactoryImpl implements CommandFactory { private static final String ENV_VAR_JAVA_TOOL_OPTIONS = "JAVA_TOOL_OPTIONS"; @@ -69,6 +71,7 @@ public class CommandFactoryImpl implements CommandFactory { SOCKS_PROXY_HOST.getKey(), SOCKS_PROXY_PORT.getKey()}; + private static final Version SQ_VERSION = MetadataLoader.loadVersion(org.sonar.api.utils.System2.INSTANCE); private final Props props; private final File tempDir; private final System2 system2; @@ -166,7 +169,7 @@ public class CommandFactoryImpl implements CommandFactory { .setEnvVariable(PATH_LOGS.getKey(), props.nonNullValue(PATH_LOGS.getKey())) .setArgument("sonar.cluster.web.startupLeader", Boolean.toString(leader)) .setClassName("org.sonar.server.app.WebServer") - .addClasspath("./lib/common/*"); + .addClasspath("./lib/sonar-application-" + SQ_VERSION + ".jar"); String driverPath = props.value(JDBC_DRIVER_PATH.getKey()); if (driverPath != null) { command.addClasspath(driverPath); @@ -190,7 +193,7 @@ public class CommandFactoryImpl implements CommandFactory { .setJvmOptions(jvmOptions) .setGracefulStopTimeoutMs(getGracefulStopTimeoutMs(props, CE_GRACEFUL_STOP_TIMEOUT)) .setClassName("org.sonar.ce.app.CeServer") - .addClasspath("./lib/common/*"); + .addClasspath("./lib/sonar-application-" + SQ_VERSION + ".jar"); String driverPath = props.value(JDBC_DRIVER_PATH.getKey()); if (driverPath != null) { command.addClasspath(driverPath); diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java index 45cdcf1da86..f8d7029008a 100644 --- a/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java +++ b/server/sonar-main/src/test/java/org/sonar/application/command/CommandFactoryImplTest.java @@ -224,8 +224,7 @@ public class CommandFactoryImplTest { assertThat(command.getClassName()).isEqualTo("org.sonar.server.app.WebServer"); assertThat(command.getWorkDir().getAbsolutePath()).isEqualTo(homeDir.getAbsolutePath()); - assertThat(command.getClasspath()) - .containsExactly("./lib/common/*"); + assertThat(command.getClasspath()).hasSize(1).allMatch(p -> p.toString().startsWith("./lib/sonar-application-")); assertThat(command.getJvmOptions().getAll()) // enforced values .contains("-Djava.awt.headless=true", "-Dfile.encoding=UTF-8") @@ -249,8 +248,7 @@ public class CommandFactoryImplTest { assertThat(command.getClassName()).isEqualTo("org.sonar.ce.app.CeServer"); assertThat(command.getWorkDir().getAbsolutePath()).isEqualTo(homeDir.getAbsolutePath()); - assertThat(command.getClasspath()) - .containsExactly("./lib/common/*"); + assertThat(command.getClasspath()).hasSize(1).allMatch(p -> p.toString().startsWith("./lib/sonar-application-")); assertThat(command.getJvmOptions().getAll()) // enforced values .contains("-Djava.awt.headless=true", "-Dfile.encoding=UTF-8") @@ -298,9 +296,9 @@ public class CommandFactoryImplTest { props.setProperty("sonar.jdbc.driverPath", driverFile.getAbsolutePath()); JavaCommand command = newFactory(props).createWebCommand(true); - - assertThat(command.getClasspath()) - .containsExactlyInAnyOrder("./lib/common/*", driverFile.getAbsolutePath()); + assertThat(command.getClasspath()).hasSize(2); + assertThat(command.getClasspath().get(0).toString()).startsWith("./lib/sonar-application-"); + assertThat(command.getClasspath().get(1)).isEqualTo(driverFile.getAbsolutePath()); } private void prepareEsFileSystem() throws IOException { |