Skip to content

Commit

Permalink
Initial version.
Browse files Browse the repository at this point in the history
  • Loading branch information
onukristo committed Mar 27, 2024
1 parent f7c018a commit fc15996
Show file tree
Hide file tree
Showing 30 changed files with 400 additions and 314 deletions.
6 changes: 2 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.1] - 2024-03-21
## [0.0.2] - 2024-03-27

### Added

* A bean to ask the current environment from.
Initial version.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@

Provides information to other libraries in which environment they are running in.

Allows to set default properties via environment variables and system properties.
Allows to set default properties for specific environments.

Those have to prefixed respectively with
* `WISE_DEFAULTS_`
* `wise.defaults.`
Typical use case is for various Wise libraries to set environment specific default properties in their `EnvironmentPostProcessor` implementations.

E.g.
* `WISE_DEFAULTS_WISE_ENVIRONMENT_TEST_VALUE1`
* `wise.defaults.wise.environment.test.value4`
```java
WiseEnvironment.setDefaultProperty(WiseEnvironment.PRODUCTION, "tw-reliable-jdbc.sslMode", SslMode.VERIFY_FULL);
WiseEnvironment.setDefaultProperty(WiseEnvironment.STAGING, "tw-reliable-jdbc.sslMode", SslMode.PREFERRED);
WiseEnvironment.setDefaultProperty(WiseEnvironment.CUSTOM_ENVIRONMENT, "tw-reliable-jdbc.sslMode", SslMode.VERIFY_CA);
```

See `WiseEnvironment` class for other optional use cases. E.g. asking which environments are currently active.

## License
Copyright 2024 TransferWise Ltd.
Expand Down
7 changes: 0 additions & 7 deletions build.common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ apply plugin: "java-library"
apply plugin: "checkstyle"
apply plugin: "idea"
apply plugin: "com.github.spotbugs"
apply plugin: "groovy"

apply from: "$rootProject.rootDir/build.libraries.gradle"

Expand Down Expand Up @@ -91,12 +90,6 @@ compileTestJava {
test {
useJUnitPlatform()

environment("WISE_DEFAULTS_WISE_ENVIRONMENT_TEST_VALUE1", "foo")
environment("WISE_DEFAULTS_WISE_ENVIRONMENT_TEST_VALUE2", "foo")
environment("WISE_ENVIRONMENT_TEST_VALUE3", "foo")

systemProperty("wise.defaults.wise.environment.test.value4", "foo")

testLogging {
events TestLogEvent.STARTED, TestLogEvent.FAILED, TestLogEvent.SKIPPED, TestLogEvent.PASSED,
TestLogEvent.STANDARD_ERROR
Expand Down
3 changes: 2 additions & 1 deletion build.libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ ext {
springBootDependencies: "org.springframework.boot:spring-boot-dependencies:${springBootVersion}",

// versions managed by spring-boot-dependencies platform
commonsLang3 : 'org.apache.commons:commons-lang3',
lombok : 'org.projectlombok:lombok',
springBootStarter : "org.springframework.boot:spring-boot-starter",
springBootStarterTest : "org.springframework.boot:spring-boot-starter-test"
springBootStarterTest : "org.springframework.boot:spring-boot-starter-test",
]
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.0.1
version=0.0.2
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 7 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -202,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
5 changes: 3 additions & 2 deletions wise-environment-starter/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
ext.projectArtifactName = "wise-environment"
ext.projectArtifactName = "wise-environment-starter"

apply from: "$rootProject.rootDir/build.common.gradle"
apply from: "$rootProject.rootDir/build.library.gradle"

dependencies {
compileOnly libraries.springBootStarter
implementation libraries.commonsLang3
implementation libraries.springBootStarter

testImplementation libraries.springBootStarterTest
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit fc15996

Please sign in to comment.