diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-05-07 14:20:16 +0200 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-05-07 14:20:16 +0200 |
commit | 25bd84ec32115b346cab66eeed9dc47cd574d12b (patch) | |
tree | 7c8cff4489fe48b54a1a40f152b0d86a56efd0ed /lib | |
parent | be08f91dac2b018fb9a08c89e3961ebc0263a1a4 (diff) |
Read app version from version.properties
- read app version from version.properties
- make openapi dependencies compileOnly
- run spotless formatter
Issue-ID: PORTALNG-94
Change-Id: I3d3b9f057bc998d90763101ac8f3b32a0df280c1
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/build.gradle | 19 | ||||
-rw-r--r-- | lib/src/main/java/org/onap/portalng/bff/config/BeansConfig.java | 12 |
2 files changed, 24 insertions, 7 deletions
diff --git a/lib/build.gradle b/lib/build.gradle index 93064db..90ab5b2 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -9,7 +9,7 @@ plugins { } group 'org.onap.portal-ng' -version rootProject.file('version').text.trim() +version getAppVersion() dependencies { implementation project(':openapi:server') @@ -100,4 +100,19 @@ spotbugs { ignoreFailures = false reportLevel = "high" excludeFilter = file("$rootProject.projectDir/spotbugs-exclude.xml") -}
\ No newline at end of file +} + +def String getAppVersion() { + Properties versionProperties = getVersionProperties() + String major = versionProperties.getProperty('major') + String minor = versionProperties.getProperty('minor') + String patch = versionProperties.getProperty('patch') + return major + '.' + minor + '.' + patch +} +def Properties getVersionProperties() { + def versionProperties = new Properties() + rootProject.file('version.properties').withInputStream { + versionProperties.load(it) + } + return versionProperties +} diff --git a/lib/src/main/java/org/onap/portalng/bff/config/BeansConfig.java b/lib/src/main/java/org/onap/portalng/bff/config/BeansConfig.java index 3eb5f87..a23ac0c 100644 --- a/lib/src/main/java/org/onap/portalng/bff/config/BeansConfig.java +++ b/lib/src/main/java/org/onap/portalng/bff/config/BeansConfig.java @@ -33,6 +33,7 @@ import java.util.List; import lombok.extern.slf4j.Slf4j; import org.onap.portalng.bff.exceptions.DownstreamApiProblemException; import org.onap.portalng.bff.utils.Logger; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.codec.ClientCodecConfigurer; @@ -58,9 +59,11 @@ public class BeansConfig { "logRequestExchangeFilterFunction"; public static final String LOG_RESPONSE_EXCHANGE_FILTER_FUNCTION = "logResponseExchangeFilterFunction"; - private static final String CLIENT_REGISTRATION_ID = "keycloak"; public static final String X_REQUEST_ID = "X-Request-Id"; + private static final String CLIENT_REGISTRATION_ID = "keycloak"; + private static final ObjectMapper objectMapper = new ObjectMapper(); + @Bean(name = OAUTH2_EXCHANGE_FILTER_FUNCTION) ExchangeFilterFunction oauth2ExchangeFilterFunction( ReactiveOAuth2AuthorizedClientManager authorizedClientManager) { @@ -88,9 +91,8 @@ public class BeansConfig { downstreamExceptionBody -> { try { return Mono.error( - new ObjectMapper() - .readValue( - downstreamExceptionBody, DownstreamApiProblemException.class)); + objectMapper.readValue( + downstreamExceptionBody, DownstreamApiProblemException.class)); } catch (JsonProcessingException e) { return Mono.error(DownstreamApiProblemException.builder().build()); } @@ -130,7 +132,7 @@ public class BeansConfig { } @Bean - ExchangeStrategies exchangeStrategies(ObjectMapper objectMapper) { + ExchangeStrategies exchangeStrategies(@Qualifier("objectMapper") ObjectMapper objectMapper) { return ExchangeStrategies.builder() .codecs( configurer -> { |