-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/de/skuzzle/ghpromexporter/version/VersionConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package de.skuzzle.ghpromexporter.version; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.SpringBootVersion; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import de.skuzzle.ghpromexporter.GhPromExporterApplication; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
class VersionConfiguration { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(VersionConfiguration.class); | ||
|
||
@Bean | ||
Versions versions() { | ||
record VersionsImpl(String springBoot, String application) implements Versions {} | ||
|
||
final String application = getApplicationVersion(GhPromExporterApplication.class); | ||
final String springBoot = SpringBootVersion.getVersion(); | ||
|
||
final Versions versions = new VersionsImpl(format(springBoot), format(application)); | ||
log.info("Determined application version: {}", versions); | ||
return versions; | ||
} | ||
|
||
private String format(String version) { | ||
return version == null | ||
? "<unknown>" | ||
: "v" + version; | ||
} | ||
|
||
private String getApplicationVersion(Class<?> sourceClass) { | ||
final Package sourcePackage = (sourceClass != null) ? sourceClass.getPackage() : null; | ||
return (sourcePackage != null) ? sourcePackage.getImplementationVersion() : null; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/de/skuzzle/ghpromexporter/version/Versions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.skuzzle.ghpromexporter.version; | ||
|
||
public interface Versions { | ||
|
||
String application(); | ||
|
||
String springBoot(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters