I’m trying to include build information along with version information in springboot. I’ve a working local setup that satisfies my requirements. Which looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<otherstuff></otherstuff>
<version>1.0.0-${buildNumber}</version>
<properties>
<buildNumber>${buildNumber}</buildNumber>
<otherstuff></otherstuff>
</properties>
</project>
I build it using mvn clean install -DbuildNumber=5678
. However, it shows a warning that says version is expecting a constant. But it’s working fine locallly. But it fails while running in the CI pipeline. I also need it to reflect in the info endpoint we have.
@GetMapping("/api/app/info")
AppInfo getAppInfo() {
return new AppInfo(this.buildProperties.getName(), this.buildProperties.getVersion(),
this.buildProperties.get("description"), this.buildProperties.get("copyright.info"),
this.buildProperties.getTime());
}
What are my options here?
Tried using maven version plugin. Didn’t work as expected.