diff --git a/client/src/containers/SideBar/Sidebar.jsx b/client/src/containers/SideBar/Sidebar.jsx index 7781d66e1..59295581c 100644 --- a/client/src/containers/SideBar/Sidebar.jsx +++ b/client/src/containers/SideBar/Sidebar.jsx @@ -230,7 +230,7 @@ class Sidebar extends Component { enableConnect } = this.state; const roles = this.state.roles || {}; - const tag = 'Snapshot'; + const tag = sessionStorage.getItem('version'); const { listConnects, listClusters } = this.setClustersAndConnects(); return ( oidcAuths; + private String version; } @AllArgsConstructor diff --git a/src/main/java/org/akhq/utils/VersionProvider.java b/src/main/java/org/akhq/utils/VersionProvider.java index 76b08800f..a1a038e4c 100644 --- a/src/main/java/org/akhq/utils/VersionProvider.java +++ b/src/main/java/org/akhq/utils/VersionProvider.java @@ -9,26 +9,45 @@ import javax.inject.Inject; import javax.inject.Singleton; import java.util.Objects; +import java.util.Optional; +import java.util.stream.Stream; @Singleton public class VersionProvider { - @Getter - private String tag = "Snapshot"; + private String version = "Snapshot"; @Inject Environment environment; @PostConstruct public void start() { - new PropertiesPropertySourceLoader() - .load("classpath:git", environment) - .ifPresent(properties -> setTag(properties.get("git.tags"))); + this.version = Stream + .concat( + new PropertiesPropertySourceLoader() + .load("classpath:gradle", environment) + .stream() + .flatMap(properties -> Stream.of(properties.get("version"))), + new PropertiesPropertySourceLoader() + .load("classpath:git", environment) + .stream() + .flatMap(properties -> Stream + .of( + properties.get("git.tags"), + properties.get("git.branch") + ) + ) + ) + .map(this::getVersion) + .filter(Optional::isPresent) + .map(Optional::get) + .findFirst() + .orElse(this.version); } - private void setTag(Object value) { - String candidate = Objects.toString(value, null); - this.tag = StringUtils.isNotEmpty(candidate) ? candidate : this.tag; - } + private Optional getVersion(Object object) { + String candidate = Objects.toString(object, null); + return StringUtils.isNotEmpty(candidate) ? Optional.of(candidate) : Optional.empty(); + } }