diff --git a/.gitignore b/.gitignore index 1239f6fca33347cdc9f9a31e03247e640037edfb..56f92cf8fc742d67b7cc4dcd4c6ac048bb4aadf1 100644 --- a/.gitignore +++ b/.gitignore @@ -78,4 +78,7 @@ target/ *.rar # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* \ No newline at end of file +hs_err_pid* + +# dsms-engine copy version file +/dsms-engine-application/src/main/resources/version diff --git a/dsms-engine-application/pom.xml b/dsms-engine-application/pom.xml index 0c4e2ba501486f8c17c1566a6fe111e5b97e3851..c48627d917d774e12f0e9be1a14c4606d7838472 100644 --- a/dsms-engine-application/pom.xml +++ b/dsms-engine-application/pom.xml @@ -19,16 +19,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - + dsms-engine com.dsms 1.0.0-SNAPSHOT - 4.0.0 - dsms-engine-application + 4.0.0 + dsms-engine-application - + @@ -43,10 +43,15 @@ - - + + - + + + pl.project13.maven + git-commit-id-plugin + + org.springframework.boot spring-boot-maven-plugin diff --git a/dsms-engine-application/src/test/java/com/dsms/modules/system/service/ManagerServiceTest.java b/dsms-engine-application/src/test/java/com/dsms/modules/system/service/ManagerServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..32c240c7dda577557c42f1544c7f600e49306d9d --- /dev/null +++ b/dsms-engine-application/src/test/java/com/dsms/modules/system/service/ManagerServiceTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 The DSMS Authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.dsms.modules.system.service; + +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.info.GitProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.util.ResourceUtils; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; + +import static com.dsms.common.constant.SystemConst.VERSION_FILE_PATH; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@Slf4j +public class ManagerServiceTest { + + @Autowired + private GitProperties gitProperties; + + @Test + @DisplayName("system module-about") + void testServerInfo() throws IOException { + Assertions.assertNotNull(gitProperties.getCommitId()); + File versionFile = ResourceUtils.getFile(VERSION_FILE_PATH); + String version = Files.readString(versionFile.toPath(), StandardCharsets.UTF_8); + Assertions.assertNotNull(version); + } + +} diff --git a/dsms-engine-common/src/main/java/com/dsms/common/constant/SystemConst.java b/dsms-engine-common/src/main/java/com/dsms/common/constant/SystemConst.java index 924abcfa11b5949607d0f4e9c7b47c653afb914d..7c4d31503d4df3b8113aecf813e2273b5dd0259c 100644 --- a/dsms-engine-common/src/main/java/com/dsms/common/constant/SystemConst.java +++ b/dsms-engine-common/src/main/java/com/dsms/common/constant/SystemConst.java @@ -33,6 +33,11 @@ public class SystemConst { */ public static final String SPRING_ADDITIONAL_CONFIG = "spring.config.additional-location"; + /** + * version file path + */ + public static final String VERSION_FILE_PATH = "classpath:version"; + /** * redis 存储token前缀 */ diff --git a/pom.xml b/pom.xml index f775514e1db51238fd27b356a5b37344c424a93f..9ae1f1e1595d553139920529d6b4cbc6451db86c 100644 --- a/pom.xml +++ b/pom.xml @@ -132,4 +132,36 @@ + + + + + + maven-resources-plugin + 3.3.0 + + + copy-resources + validate + + copy-resources + + + dsms-engine-application/target/classes + + + ${basedir} + + version + + true + + + + + + + + + \ No newline at end of file diff --git a/version b/version new file mode 100644 index 0000000000000000000000000000000000000000..60453e6906a5b8d0fbd3d33d8063b42ff3d973c6 --- /dev/null +++ b/version @@ -0,0 +1 @@ +v1.0.0 \ No newline at end of file