Merge pull request #683 from Stirling-Tools/version_fix

fix: version showing as 0.0.0
This commit is contained in:
sbplat 2024-01-10 09:28:43 -05:00 committed by GitHub
commit 9fc873e973
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,11 +1,15 @@
package stirling.software.SPDF.config;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Properties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import stirling.software.SPDF.model.ApplicationProperties;
@ -27,8 +31,15 @@ public class AppConfig {
@Bean(name = "appVersion")
public String appVersion() {
String version = getClass().getPackage().getImplementationVersion();
return (version != null) ? version : "0.0.0";
Resource resource = new ClassPathResource("version.properties");
Properties props = new Properties();
try {
props.load(resource.getInputStream());
return props.getProperty("version");
} catch (IOException e) {
e.printStackTrace();
}
return "0.0.0";
}
@Bean(name = "homeText")