use version from the pom

This commit is contained in:
Lee 2024-04-10 10:48:15 +01:00
parent cb7c2e162f
commit c0c4e32809
2 changed files with 31 additions and 3 deletions

20
pom.xml

@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>cc.fascinated</groupId> <groupId>cc.fascinated</groupId>
<artifactId>Minecraft-Helper</artifactId> <artifactId>Minecraft-Utilities</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0.0</version>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
@ -21,11 +21,27 @@
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<!-- Build Steps -->
<build> <build>
<finalName>${project.artifactId}</finalName>
<plugins> <plugins>
<!-- Spring -->
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
<configuration>
<additionalProperties>
<description>${project.description}</description>
</additionalProperties>
</configuration>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

@ -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.Info;
import io.swagger.v3.oas.models.info.License; import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server; 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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -12,6 +14,16 @@ import java.util.List;
@Configuration @Configuration
public class OpenAPIConfiguration { 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 @Bean
public OpenAPI defineOpenAPI() { public OpenAPI defineOpenAPI() {
@ -25,7 +37,7 @@ public class OpenAPIConfiguration {
Info info = new Info(); Info info = new Info();
info.setTitle("Minecraft Utilities API"); 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.setDescription("Wrapper for the Minecraft APIs to make them easier to use.");
info.setContact(contact); info.setContact(contact);
info.setLicense(new License().name("MIT License").url("https://opensource.org/licenses/MIT")); info.setLicense(new License().name("MIT License").url("https://opensource.org/licenses/MIT"));