Commit 79cb66a4 authored by Daniel Gerhardt's avatar Daniel Gerhardt

Add version info

Version information is now compiled as part of a build and written to
version.properties. It is exposed by the API.
parent 003b064b
......@@ -9,6 +9,7 @@
<properties>
<io.spring.platform-version>2.0.1.RELEASE</io.spring.platform-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<sonar.language>java</sonar.language>
<mobile.production.path>../arsnova-mobile/src/main/webapp/build/production/ARSnova</mobile.production.path>
<mobile.testing.path>../arsnova-mobile/src/main/webapp/build/testing/ARSnova</mobile.testing.path>
......@@ -294,6 +295,23 @@
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>version.properties</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>version.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......@@ -424,6 +442,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
......
......@@ -19,6 +19,7 @@ package de.thm.arsnova.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
......@@ -76,6 +77,14 @@ public class ExtraConfig extends WebMvcConfigurerAdapter {
return configurer;
}
@Bean
public PropertiesFactoryBean versionInfoProperties() {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("version.properties"));
return propertiesFactoryBean;
}
@Bean(name = "connectorClient")
public ConnectorClient connectorClient() {
if (!connectorEnable) {
......
......@@ -22,7 +22,10 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Value;
......@@ -52,6 +55,9 @@ public class WelcomeController extends AbstractController {
@Value("${mobile.path}")
private String mobileContextPath;
@Resource(name="versionInfoProperties")
private Properties versionInfoProperties;
@RequestMapping(value = "/", method = RequestMethod.GET)
public View home(final HttpServletRequest request) {
return new RedirectView(mobileContextPath + "/", false);
......@@ -59,8 +65,19 @@ public class WelcomeController extends AbstractController {
@RequestMapping(value = "/", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public HashMap<String, Object> jsonHome(final HttpServletRequest request) {
return new HashMap<String, Object>();
public Map<String, Object> jsonHome(final HttpServletRequest request) {
Map<String, Object> response = new HashMap<>();
Map<String, Object> version = new HashMap<>();
version.put("string", versionInfoProperties.getProperty("version.string"));
version.put("buildTime", versionInfoProperties.getProperty("version.build-time"));
version.put("gitCommitId", versionInfoProperties.getProperty("version.git.commit-id"));
version.put("gitDirty", Boolean.parseBoolean(versionInfoProperties.getProperty("version.git.dirty")));
response.put("productName", "arsnova-backend");
response.put("version", version);
return response;
}
@RequestMapping(value = "/checkframeoptionsheader", method = RequestMethod.POST)
......
version.string=${project.version}
version.build-time=${timestamp}
version.git.commit-id=${git.commit.id}
version.git.dirty=${git.dirty}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment