summaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java55
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java4
-rw-r--r--sonar-server/src/main/resources/build.properties2
3 files changed, 38 insertions, 23 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java b/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
index dfec05e9002..fc01c7a7279 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
@@ -20,8 +20,11 @@
package org.sonar.server.platform;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.platform.Server;
@@ -33,32 +36,41 @@ import java.util.Date;
import java.util.Properties;
public final class ServerImpl extends Server {
+ private static final Logger LOG = LoggerFactory.getLogger(ServerImpl.class);
+ private final Settings settings;
+ private final Date startedAt;
+ private final String buildProperties;
+ private final String pomProperties;
private String id;
private String version;
- private final Date startedAt;
- private Settings settings;
- private final String manifest;
+ private String implementationBuild;
public ServerImpl(Settings settings) {
- this(settings, "/META-INF/maven/org.codehaus.sonar/sonar-plugin-api/pom.properties");
+ this(settings, "/build.properties", "/META-INF/maven/org.codehaus.sonar/sonar-plugin-api/pom.properties");
}
@VisibleForTesting
- ServerImpl(Settings settings, String manifest) {
+ ServerImpl(Settings settings, String buildProperties, String pomProperties) {
this.settings = settings;
this.startedAt = new Date();
- this.manifest = manifest;
+ this.buildProperties = buildProperties;
+ this.pomProperties = pomProperties;
}
public void start() {
try {
id = new SimpleDateFormat("yyyyMMddHHmmss").format(startedAt);
- version = loadVersionFromManifest(manifest);
+
+ version = read(pomProperties).getProperty("version", "");
+ implementationBuild = read(buildProperties).getProperty("Implementation-Build");
+
if (StringUtils.isBlank(version)) {
throw new ServerStartException("Unknown Sonar version");
}
+ LOG.info("Sonar {}", Joiner.on(" / ").skipNulls().join("Server", version, implementationBuild));
+
} catch (IOException e) {
throw new ServerStartException("Can not load metadata", e);
}
@@ -79,31 +91,30 @@ public final class ServerImpl extends Server {
return version;
}
+ public String getImplementationBuild() {
+ return implementationBuild;
+ }
+
@Override
public Date getStartedAt() {
return startedAt;
}
- private String loadVersionFromManifest(String pomFilename) throws IOException {
- InputStream pomFileStream = getClass().getResourceAsStream(pomFilename);
- try {
- return readVersion(pomFileStream);
+ private static Properties read(String filename) throws IOException {
+ Properties properties = new Properties();
+ InputStream stream = null;
+ try {
+ stream = ServerImpl.class.getResourceAsStream(filename);
+ if (stream != null) {
+ properties.load(stream);
+ }
} finally {
- IOUtils.closeQuietly(pomFileStream);
+ IOUtils.closeQuietly(stream);
}
- }
- protected static String readVersion(InputStream pomFileStream) throws IOException {
- String result = null;
- if (pomFileStream != null) {
- Properties pomProp = new Properties();
- pomProp.load(pomFileStream);
- result = pomProp.getProperty("version");
- }
- return StringUtils.defaultIfEmpty(result, "");
+ return properties;
}
-
@Override
public String getURL() {
return null;
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java b/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java
index 775408ca64c..6a00e387275 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java
@@ -19,6 +19,8 @@
*/
package org.sonar.server.plugins;
+import com.google.common.base.Joiner;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -190,7 +192,7 @@ public class PluginDeployer implements ServerComponent {
}
private void deploy(DefaultPluginMetadata plugin) {
- LOG.debug("Deploy plugin " + plugin);
+ LOG.info("Deploy plugin {}", Joiner.on(" / ").skipNulls().join(plugin.getName(), plugin.getVersion(), plugin.getImplementationBuild()));
Preconditions.checkState(plugin.isCompatibleWith(server.getVersion()),
"Plugin %s needs a more recent version of Sonar than %s. At least %s is expected",
diff --git a/sonar-server/src/main/resources/build.properties b/sonar-server/src/main/resources/build.properties
new file mode 100644
index 00000000000..8c9958a7711
--- /dev/null
+++ b/sonar-server/src/main/resources/build.properties
@@ -0,0 +1,2 @@
+Implementation-Build=${buildNumber}
+Build-Time=${timestamp} \ No newline at end of file