From 497aaab67f0da1db22a10c20558bd04570765b40 Mon Sep 17 00:00:00 2001 From: johnniang Date: Tue, 7 May 2019 11:15:48 +0800 Subject: [PATCH] Add halo version to application --- build.gradle | 9 ++++++++- .../java/run/halo/app/config/SwaggerConfiguration.java | 3 ++- src/main/java/run/halo/app/model/support/HaloConst.java | 6 +++++- .../java/run/halo/app/service/impl/AdminServiceImpl.java | 7 ++++--- src/main/resources/application.yaml | 2 +- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 53ef91f3f..b33a50dff 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ apply plugin: 'io.spring.dependency-management' group = 'run.halo.app' archivesBaseName = 'halo' -version = '1.0.0' +version = '1.0.0.bata' sourceCompatibility = '1.8' description = 'Halo, personal blog system developed in Java.' @@ -27,6 +27,13 @@ configurations { } } +bootJar { + manifest { + attributes('Implementation-Title': 'Halo Application', + 'Implementation-Version': version) + } +} + dependencies { implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' diff --git a/src/main/java/run/halo/app/config/SwaggerConfiguration.java b/src/main/java/run/halo/app/config/SwaggerConfiguration.java index 0cd172f20..dfc97123d 100644 --- a/src/main/java/run/halo/app/config/SwaggerConfiguration.java +++ b/src/main/java/run/halo/app/config/SwaggerConfiguration.java @@ -3,6 +3,7 @@ package run.halo.app.config; import com.fasterxml.classmate.TypeResolver; import io.swagger.models.auth.In; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; @@ -56,7 +57,7 @@ public class SwaggerConfiguration { new ResponseMessageBuilder().code(404).message("Not found").build(), new ResponseMessageBuilder().code(500).message("Internal server error").build()); - public SwaggerConfiguration(HaloProperties haloProperties) { + public SwaggerConfiguration( HaloProperties haloProperties) { this.haloProperties = haloProperties; } diff --git a/src/main/java/run/halo/app/model/support/HaloConst.java b/src/main/java/run/halo/app/model/support/HaloConst.java index 3890bc070..37e295a68 100644 --- a/src/main/java/run/halo/app/model/support/HaloConst.java +++ b/src/main/java/run/halo/app/model/support/HaloConst.java @@ -23,7 +23,7 @@ public class HaloConst { /** * version constant */ - public static final String HALO_VERSION = "1.0.0"; + public static final String HALO_VERSION; /** * Suffix of freemarker template file @@ -74,4 +74,8 @@ public class HaloConst { * user_session */ public static String USER_SESSION_KEY = "user_session"; + + static { + HALO_VERSION = HaloConst.class.getPackage().getImplementationVersion(); + } } diff --git a/src/main/java/run/halo/app/service/impl/AdminServiceImpl.java b/src/main/java/run/halo/app/service/impl/AdminServiceImpl.java index 34f9c1108..c4510ad31 100644 --- a/src/main/java/run/halo/app/service/impl/AdminServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/AdminServiceImpl.java @@ -57,8 +57,7 @@ public class AdminServiceImpl implements AdminService { private final StringCacheStore cacheStore; - @Value("${spring.datasource.driver-class-name}") - private String driverClassName; + private final String driverClassName; public AdminServiceImpl(PostService postService, SheetService sheetService, @@ -69,7 +68,8 @@ public class AdminServiceImpl implements AdminService { OptionService optionService, UserService userService, LinkService linkService, - StringCacheStore cacheStore) { + StringCacheStore cacheStore, + @Value("${spring.datasource.driver-class-name}") String driverClassName) { this.postService = postService; this.sheetService = sheetService; this.attachmentService = attachmentService; @@ -80,6 +80,7 @@ public class AdminServiceImpl implements AdminService { this.userService = userService; this.linkService = linkService; this.cacheStore = cacheStore; + this.driverClassName = driverClassName; } @Override diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 55b28ea20..374880bd4 100755 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -51,4 +51,4 @@ spring: logging: level: run.halo.app: INFO - file: ./logs/log.log + file: ./logs/log.log \ No newline at end of file