Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Nov 25, 2017
1 parent 520746b commit 477facd
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/test/kotlin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# java-dotenv


Dotenv is a zero-dependency module that loads environment variables from a `.env`. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.

**Note:** Java does not provide a way to set environment variables on a currently running process. Thus, once `java-dotenv` is configured, you can use the `dotenv.get("...")` API to get environment variables, instead of `System.getenv(...)`.

## Usage

### Create a `.env` file

```
# formatted as key=value
MY_ENV_VAR1=My first env var with dotenv
MY_EVV_VAR2=My second env var
```

### Kotlin
#### Configure dotenv-java
Configure `dotenv-java` once in your application.

```kotlin
val dotenv = Dotenv
.configure()
.withDirectory("./src/test/resources")
.ignoreIfMalformed()
.build()
```

#### Get an environment variable
Note, environment variables specified in `.env` take precedence over those configured in the actual environment.

```
dotenv["MY_ENV_VAR1"]
```

### Java
#### Configure dotenv-java
Configure `dotenv-java` once in your application.

```java
Dotenv dotenv = Dotenv
.configure()
.withDirectory("./src/test/resources")
.ignoreIfMalformed()
.build()
```

#### Get an environment variable
Note, environment variables specified in `.env` take precedence over those configured in the actual environment.

```
dotenv.get("MY_ENV_VAR1")
```

## License
Apache 2.0

0 comments on commit 477facd

Please sign in to comment.