From c0c4e328092a1813e07c2b031626df43dd842c67 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 10 Apr 2024 10:48:15 +0100 Subject: [PATCH] use version from the pom --- pom.xml | 20 +++++++++++++++++-- .../config/OpenAPIConfiguration.java | 14 ++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 6f0d5a9..3c48c16 100644 --- a/pom.xml +++ b/pom.xml @@ -5,8 +5,8 @@ 4.0.0 cc.fascinated - Minecraft-Helper - 1.0-SNAPSHOT + Minecraft-Utilities + 1.0.0 17 @@ -21,11 +21,27 @@ + + ${project.artifactId} + org.springframework.boot spring-boot-maven-plugin + + + build-info + + build-info + + + + ${project.description} + + + + diff --git a/src/main/java/cc.fascinated/config/OpenAPIConfiguration.java b/src/main/java/cc.fascinated/config/OpenAPIConfiguration.java index 1e5b5f5..15e2df8 100644 --- a/src/main/java/cc.fascinated/config/OpenAPIConfiguration.java +++ b/src/main/java/cc.fascinated/config/OpenAPIConfiguration.java @@ -5,6 +5,8 @@ import io.swagger.v3.oas.models.info.Contact; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; import io.swagger.v3.oas.models.servers.Server; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.info.BuildProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -12,6 +14,16 @@ import java.util.List; @Configuration public class OpenAPIConfiguration { + /** + * The build properties of the + * app, null if the app is not built. + */ + private final BuildProperties buildProperties; + + @Autowired + public OpenAPIConfiguration(BuildProperties buildProperties) { + this.buildProperties = buildProperties; + } @Bean public OpenAPI defineOpenAPI() { @@ -25,7 +37,7 @@ public class OpenAPIConfiguration { Info info = new Info(); info.setTitle("Minecraft Utilities API"); - info.setVersion("1.0"); + info.setVersion(buildProperties == null ? "N/A" : buildProperties.getVersion()); info.setDescription("Wrapper for the Minecraft APIs to make them easier to use."); info.setContact(contact); info.setLicense(new License().name("MIT License").url("https://opensource.org/licenses/MIT"));