fix: #713, 开发环境也能获取版本信息了 (#714)

* fix #713, 开发环境也能获取版本信息了

* banner version show ok
pull/732/head
ming 2020-03-28 14:33:23 +08:00 committed by GitHub
parent f21f5933bf
commit 49486198df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 15 deletions

View File

@ -39,10 +39,15 @@ configurations {
}
}
bootJar {
manifest {
attributes("Implementation-Title": "Halo Application",
"Implementation-Version": archiveVersion)
springBoot {
buildInfo()
}
// gradle Property Expansion ${..} springboot springboot \${..}
processResources {
filesMatching("application.yaml") {
expand(project.properties)
}
}

View File

@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.info.BuildProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -15,8 +16,10 @@ import run.halo.app.cache.AbstractStringCacheStore;
import run.halo.app.cache.InMemoryCacheStore;
import run.halo.app.cache.LevelCacheStore;
import run.halo.app.config.properties.HaloProperties;
import run.halo.app.model.support.HaloConst;
import run.halo.app.utils.HttpClientUtils;
import javax.annotation.PostConstruct;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
@ -34,6 +37,9 @@ public class HaloConfiguration {
@Autowired
HaloProperties haloProperties;
@Autowired
BuildProperties buildProperties;
@Bean
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
builder.failOnEmptyBeans(false);
@ -70,4 +76,8 @@ public class HaloConfiguration {
}
@PostConstruct
public void init() {
HaloConst.HALO_VERSION = buildProperties.getVersion();
}
}

View File

@ -50,10 +50,6 @@ public class HaloConst {
*/
public final static String DEFAULT_THEME_ID = "caicai_anatole";
/**
* Version constant. (Available in production environment)
*/
public static final String HALO_VERSION;
/**
* Path separator.
*/
@ -143,8 +139,9 @@ public class HaloConst {
*/
public static String USER_SESSION_KEY = "user_session";
static {
// Set version
HALO_VERSION = HaloConst.class.getPackage().getImplementationVersion();
}
/**
* Version constant.
*/
public static String HALO_VERSION = null;
}

View File

@ -37,7 +37,7 @@ spring:
multipart:
max-file-size: 10240MB
max-request-size: 10240MB
location: ${java.io.tmpdir}
location: \${java.io.tmpdir}
management:
endpoints:
web:
@ -48,7 +48,10 @@ logging:
level:
run.halo.app: INFO
file:
path: ${user.home}/.halo/logs
path: \${user.home}/.halo/logs
halo:
download-timeout: 5m
download-timeout: 5m
application:
version: ${version}