Skip to content

Commit

Permalink
Feat/pom version (#114)
Browse files Browse the repository at this point in the history
* feat: get pom version at vi/health interface

* feat: get pom version at vi/health interface

* feat: get pom version at vi/health interface

---------

Co-authored-by: yushuwang <[email protected]>
  • Loading branch information
wildeslam and yushuwang authored Nov 17, 2023
1 parent e77c73b commit 53867be
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
5 changes: 0 additions & 5 deletions arex-storage-web-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@
<artifactId>log4j-mongodb4</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.6.3</version>
</dependency>

</dependencies>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.arextest.common.model.response.Response;
import com.arextest.common.utils.ResponseUtils;
import java.io.FileReader;
import lombok.extern.slf4j.Slf4j;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -17,27 +15,13 @@
@RequestMapping("/vi/")
@CrossOrigin(origins = "*", maxAge = 3600)
public class CheckHealthController {
private static Model POM_MODEL;

static {
try {
POM_MODEL = new MavenXpp3Reader().read(new FileReader("pom.xml"));
} catch (Exception e) {
LOGGER.error("Read pom failed!", e);
}
}
@Value("${pom.version}")
private String VERSION;

@GetMapping(value = "/health", produces = "application/json")
@ResponseBody
public Response checkHealth() {
return ResponseUtils.successResponse(getVersion());
return ResponseUtils.successResponse(VERSION);
}

private static String getVersion() {
if (POM_MODEL != null) {
return POM_MODEL.getVersion();
} else {
return "error";
}
}
}
2 changes: 2 additions & 0 deletions arex-storage-web-api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ arex:
similarity:
strategy:
appIds:
pom:
version: ${project.version}
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@
</activation>
<build>
<finalName>arex-storage-web-api</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down

0 comments on commit 53867be

Please sign in to comment.