Skip to content

Commit

Permalink
feat: get pom version at vi/health interface (#220)
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 56e706d commit 7e8cdb6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
17 changes: 12 additions & 5 deletions arex-schedule-web-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@
<artifactId>aspectjweaver</artifactId>
<groupId>org.aspectj</groupId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
<modelVersion>4.0.0</modelVersion>
<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -185,6 +180,12 @@
<version>1.6.13</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<id>war</id>
<properties>
Expand All @@ -197,6 +198,12 @@
</profile>
<profile>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
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,28 +15,12 @@
@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());
}

private static String getVersion() {
if (POM_MODEL != null) {
return POM_MODEL.getVersion();
} else {
return "error";
}
return ResponseUtils.successResponse(VERSION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ arex.schedule.monitor.secondToRefresh=5
arex.client.https.cert.disable=true
arex.prometheus.port=20092
arex.app.auth.switch=false
ignore.time.precision.millis=2000
ignore.time.precision.millis=2000
pom.version=${project.version}

0 comments on commit 7e8cdb6

Please sign in to comment.