From 085ede544767498a78a8bbd0fd6abf45a2c1f9de Mon Sep 17 00:00:00 2001 From: Carmine DiMascio Date: Mon, 1 Jan 2018 14:59:12 -0500 Subject: [PATCH] Update compositor.json via compositor.io --- compositor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compositor.json b/compositor.json index 6d7b08f..61d7fd1 100644 --- a/compositor.json +++ b/compositor.json @@ -66,7 +66,7 @@ "metadata": { "source": "github.readme" }, - "html": "\n

\n

\n

A zero-dependency Java port of the Ruby dotenv project (which loads environment variables from a .env file). java-dotenv also offers a Kotlin DSL.

\n

From the original Library:

\n
\n

Storing configuration in the environment is one of the tenets of a twelve-factor app. Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables.

\n

But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. Dotenv load variables from a .env file into ENV when the environment is bootstrapped.

\n
\n

Environment variables listed in the host environment override those in .env.

\n

Use dotenv.get("...") instead of Java's System.getenv(...).

\n

Install

\n

Maven

\n
<dependency>\n    <groupId>io.github.cdimascio</groupId>\n    <artifactId>java-dotenv</artifactId>\n    <version>3.0.0</version>\n</dependency>

Gradle

\n
compile 'io.github.cdimascio:java-dotenv:3.0.0'

Usage

\n

Create a .env file in the root of your project

\n
# formatted as key=value\nMY_ENV_VAR1=some_value\nMY_EVV_VAR2=some_value

With Java

\n
import io.github.cdimascio.dotenv.Dotenv;\n\nDotenv dotenv = Dotenv.load();\ndotenv.get("MY_ENV_VAR1")

or with Kotlin

\n
import io.github.cdimascio.dotenv.dotenv\n\nval dotenv = dotenv()\ndotenv["MY_ENV_VAR1"]

Advanced Usage

\n

Configure

\n

Configure java-dotenv once in your application.

\n

With Java

\n
Dotenv dotenv = Dotenv.configure()\n        .directory("./some/path")\n        .ignoreIfMalformed()\n        .ignoreIfMissing()\n        .load();
\n

or with Kotlin

\n
val dotenv = dotenv {\n    directory = "./some/path"\n    ignoreIfMalformed = true\n    ignoreIfMissing = true\n}
\n

Get environment variables

\n

Note, environment variables specified in the host environment take precedence over those in .env.

\n

With Java

\n
dotenv.get("MY_ENV_VAR1");\ndotenv.get("HOME");

or with Kotlin

\n
dotenv["MY_ENV_VAR1"]\ndotenv["HOME"]

Configuration options

\n

optional directory(path: String)

\n

path specifies the directory containing .env. Dotenv first searches for .env using the given path on the filesystem. If not found, it searches the given path on the classpath. If directory is not specified it defaults to searching the current working directory on the filesystem. If not found, it searches the current directory on the classpath.

\n

optional ignoreIfMalformed()

\n

Do not throw when .env entries are malformed. Malformed entries are skipped.

\n

optional ignoreIfMissing()

\n

Do not throw when .env does not exist. Dotenv will continue to retrieve environment variables that are set in the environment e.g. dotenv["HOME"]

\n

Kotlin Dsl Configuration Options

\n

optional directory: String

\n

Specifies the directory containing .env. Dotenv first searches for .env using the given path on the filesystem. If not found, it searches the given path on the classpath. If directory is not specified it defaults to searching the current working directory on the filesystem. If not found, it searches the current directory on the classpath.

\n

optional ignoreIfMalformed: Boolean

\n

Do not throw when .env entries are malformed. Malformed entries are skipped.

\n

optional ignoreIfMissing: Boolean

\n

Do not throw when .env does not exist. Dotenv will continue to retrieve environment variables that are set in the environment e.g. dotenv["HOME"]

\n

Examples

\n\n

FAQ

\n

Q: Why should I use dotenv.get("MY_ENV_VAR") instead of System.getenv("MY_ENV_VAR")

\n

A: Since Java does not provide a way to set environment variables on a currently running process, vars listed in .env cannot be set and thus cannot be retrieved using System.getenv(...).

\n

License

\n

Apache 2.0

\n" + "html": "\n

\n

\n

A zero-dependency Java port of the Ruby dotenv project (which loads environment variables from a .env file). java-dotenv also offers a Kotlin DSL.

\n

From the original Library:

\n
\n

Storing configuration in the environment is one of the tenets of a twelve-factor app. Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables.

\n

But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. Dotenv load variables from a .env file into ENV when the environment is bootstrapped.

\n
\n

Environment variables listed in the host environment override those in .env.

\n

Use dotenv.get("...") instead of Java's System.getenv(...).

\n

Install

\n

Maven

\n
<dependency>\n    <groupId>io.github.cdimascio</groupId>\n    <artifactId>java-dotenv</artifactId>\n    <version>3.0.0</version>\n</dependency>

Gradle

\n
compile 'io.github.cdimascio:java-dotenv:3.0.0'

Usage

\n

Create a .env file in the root of your project

\n
# formatted as key=value\nMY_ENV_VAR1=some_value\nMY_EVV_VAR2=some_value

With Java

\n
import io.github.cdimascio.dotenv.Dotenv;\n\nDotenv dotenv = Dotenv.load();\ndotenv.get("MY_ENV_VAR1")

or with Kotlin

\n
import io.github.cdimascio.dotenv.dotenv\n\nval dotenv = dotenv()\ndotenv["MY_ENV_VAR1"]

Advanced Usage

\n

Configure

\n

Configure java-dotenv once in your application.

\n

With Java

\n
Dotenv dotenv = Dotenv.configure()\n        .directory("./some/path")\n        .ignoreIfMalformed()\n        .ignoreIfMissing()\n        .load();
\n

or with Kotlin

\n
val dotenv = dotenv {\n    directory = "./some/path"\n    ignoreIfMalformed = true\n    ignoreIfMissing = true\n}
\n

Get environment variables

\n

Note, environment variables specified in the host environment take precedence over those in .env.

\n

With Java

\n
dotenv.get("MY_ENV_VAR1");\ndotenv.get("HOME");

or with Kotlin

\n
dotenv["MY_ENV_VAR1"]\ndotenv["HOME"]

Configuration options

\n

optional directory

\n\n

optional ignoreIfMalformed

\n\n

optional ignoreIfMissing

\n\n

Examples

\n\n

FAQ

\n

Q: Why should I use dotenv.get("MY_ENV_VAR") instead of System.getenv("MY_ENV_VAR")

\n

A: Since Java does not provide a way to set environment variables on a currently running process, vars listed in .env cannot be set and thus cannot be retrieved using System.getenv(...).

\n

License

\n

Apache 2.0

\n" }, { "component": "footer",