Skip to content

Commit 201010c

Browse files
authored
V6 (#50)
* upgrade dotenv-java * upgrade to v 1.1.0 dotenv-java * coveralls integration * update readme * update readme * add simple maven example * v6.1 * 6.1.1
1 parent d01d17a commit 201010c

File tree

8 files changed

+145
-8
lines changed

8 files changed

+145
-8
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🗝️ dotenv-kotlin
22

3-
![](https://travis-ci.org/cdimascio/dotenv-kotlin.svg?branch=master) [![Maven Central](https://img.shields.io/maven-central/v/io.github.cdimascio/dotenv-kotlin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.github.cdimascio%22%20AND%20a:%22dotenv-kotlin%22) [![Download](https://api.bintray.com/packages/cdimascio/maven/dotenv-kotlin/images/download.svg) ](https://bintray.com/cdimascio/maven/dotenv-kotlin/_latestVersion) [![Coverage Status](https://coveralls.io/repos/github/cdimascio/dotenv-kotlin/badge.svg?branch=master)](https://coveralls.io/github/cdimascio/dotenv-kotlin?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/66b8195f0da544f1ad9ed1352c0ea66f)](https://app.codacy.com/app/cdimascio/dotenv-kotlin?utm_source=github.com&utm_medium=referral&utm_content=cdimascio/dotenv-kotlin&utm_campaign=Badge_Grade_Dashboard) [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors) [![](https://img.shields.io/gitter/room/cdimascio-oss/community?color=%23eb205a)](https://gitter.im/cdimascio-oss/community) ![](https://img.shields.io/badge/license-Apache%202.0-orange.svg)
3+
![](https://travis-ci.org/cdimascio/java-dotenv.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/github/cdimascio/java-dotenv/badge.svg?branch=v6)](https://coveralls.io/github/cdimascio/java-dotenv?branch=v6) [![Maven Central](https://img.shields.io/maven-central/v/io.github.cdimascio/java-dotenv.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.github.cdimascio%22%20AND%20a:%22java-dotenv%22) [ ![Download](https://api.bintray.com/packages/cdimascio/maven/java-dotenv/images/download.svg) ](https://bintray.com/cdimascio/maven/java-dotenv/_latestVersion) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/66b8195f0da544f1ad9ed1352c0ea66f)](https://app.codacy.com/app/cdimascio/java-dotenv?utm_source=github.com&utm_medium=referral&utm_content=cdimascio/java-dotenv&utm_campaign=Badge_Grade_Dashboard) [![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors) [![](https://img.shields.io/gitter/room/cdimascio-oss/community?color=%23eb205a)](https://gitter.im/cdimascio-oss/community) ![](https://img.shields.io/badge/license-Apache%202.0-orange.svg)
44

55
A port of the Ruby dotenv project for Java and Kotlin. Load environment variables from a `.env` file.
66

@@ -32,7 +32,7 @@ Looking for the pure Java variant (no Kotlin), get [dotenv-java](https://github.
3232
<dependency>
3333
<groupId>io.github.cdimascio</groupId>
3434
<artifactId>dotenv-kotlin</artifactId>
35-
<version>6.1.0</version>
35+
<version>6.1.1</version>
3636
</dependency>
3737
```
3838

@@ -41,7 +41,7 @@ Looking for the pure Java variant (no Kotlin), get [dotenv-java](https://github.
4141
### Gradle
4242

4343
```groovy
44-
compile 'io.github.cdimascio:dotenv-kotlin:6.1.0'
44+
compile 'io.github.cdimascio:dotenv-kotlin:6.1.1'
4545
```
4646

4747
## Usage
@@ -268,7 +268,7 @@ for (e in dotenv.entries()) {
268268
```
269269

270270
## Examples
271-
- with [Maven (simple)](https://github.com/cdimascio/java-dotenv-example)
271+
- with [Maven (simple)](https://github.com/cdimascio/dotenv-kotlin-example)
272272
- with [Spring MVC](https://github.com/cdimascio/kotlin-spring-mvc-template)
273273
- with [Spring Webflux](https://github.com/cdimascio/kotlin-swagger-spring-functional-template)
274274
- with [Android](https://github.com/cdimascio/android-example/blob/master/app/src/main/java/com/example/dimascio/myapp/MainActivity.kt)

examples/maven-simple/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# maven-simple
2+
3+
Simple `dotenv-kotlin` example using maven.
4+
5+
## Clone
6+
7+
```shell
8+
git clone
9+
```
10+
11+
## Compile
12+
13+
```shell
14+
mvn compile
15+
```
16+
17+
## Run
18+
19+
```shell
20+
mvn exec:java -Dexec.mainClass="io.github.cdimascio.examples.dotenv.Main"
21+
```
22+
23+
The program outputs the value of the env var `MY_ENV`. In this case, `MY_VALUE`
24+
25+
## License
26+
27+
MIT

examples/maven-simple/pom.xml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>cdimascio.github.io</groupId>
8+
<artifactId>dotenv-kotlin-example</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<maven.compiler.source>11</maven.compiler.source>
13+
<maven.compiler.target>11</maven.compiler.target>
14+
<kotlin.version>1.4.10</kotlin.version>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>io.github.cdimascio</groupId>
20+
<artifactId>dotenv-kotlin</artifactId>
21+
<version>6.0.0</version>
22+
</dependency>
23+
24+
<dependency>
25+
<groupId>org.jetbrains.kotlin</groupId>
26+
<artifactId>kotlin-stdlib</artifactId>
27+
<version>${kotlin.version}</version>
28+
</dependency>
29+
30+
</dependencies>
31+
<build>
32+
<!-- setup kotlin sources dir -->
33+
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
34+
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
35+
36+
<plugins>
37+
38+
<!-- compile kotlin -->
39+
<plugin>
40+
<groupId>org.jetbrains.kotlin</groupId>
41+
<artifactId>kotlin-maven-plugin</artifactId>
42+
<version>${kotlin.version}</version>
43+
44+
<executions>
45+
<execution>
46+
<id>compile</id>
47+
<goals>
48+
<goal>compile</goal>
49+
</goals>
50+
</execution>
51+
52+
<execution>
53+
<id>test-compile</id>
54+
<goals>
55+
<goal>test-compile</goal>
56+
</goals>
57+
</execution>
58+
</executions>
59+
</plugin>
60+
61+
<!-- package app -->
62+
<plugin>
63+
<groupId>org.apache.maven.plugins</groupId>
64+
<artifactId>maven-assembly-plugin</artifactId>
65+
<executions>
66+
<execution>
67+
<phase>package</phase>
68+
<goals>
69+
<goal>single</goal>
70+
</goals>
71+
<configuration>
72+
<archive>
73+
<manifest>
74+
<mainClass>
75+
io.github.cdimascio.examples.dotenv.Main
76+
</mainClass>
77+
</manifest>
78+
</archive>
79+
<descriptorRefs>
80+
<descriptorRef>jar-with-dependencies</descriptorRef>
81+
</descriptorRefs>
82+
</configuration>
83+
</execution>
84+
</executions>
85+
</plugin>
86+
</plugins>
87+
</build>
88+
</project>
89+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.github.cdimascio.examples.dotenv
2+
3+
import io.github.cdimascio.dotenv.Dotenv
4+
5+
object Main {
6+
@JvmStatic
7+
fun main(args: Array<String>) {
8+
val dotenv = Dotenv.configure().load()
9+
10+
// Iterate over each environment entry
11+
// Note: entries in the host environment override entries in .env
12+
dotenv.entries().forEach { println(it) }
13+
14+
// Retrieve the value of the MY_ENV environment variable
15+
println("MY_ENV: " + dotenv["MY_ENV"])
16+
17+
// Retrieve the value of the MY_ENV2 environment variable or return a default value
18+
println("MY_ENV2: " + dotenv["MY_ENV2", "Default Value"])
19+
}
20+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MY_ENV="MY_VALUE"

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<groupId>io.github.cdimascio</groupId>
1212
<artifactId>dotenv-kotlin</artifactId>
13-
<version>6.0.0</version>
13+
<version>6.1.1</version>
1414

1515
<licenses>
1616
<license>
@@ -50,7 +50,7 @@
5050

5151

5252
<properties>
53-
<dotenv.version>1.1.0</dotenv.version>
53+
<dotenv.version>2.0.0</dotenv.version>
5454
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
5555
<maven.compiler.target>11</maven.compiler.target>
5656
<maven.compiler.source>11</maven.compiler.source>

src/test/java/tests/JavaTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void iteratorOverDotenvWithFilter() {
5959
.ignoreIfMalformed()
6060
.load();
6161

62-
Set<DotenvEntry> entriesInFile = dotenv.entries(DotenvEntry.Filter.DECLARED_IN_ENV_FILE);
62+
Set<DotenvEntry> entriesInFile = dotenv.entries(Dotenv.Filter.DECLARED_IN_ENV_FILE);
6363
Set<DotenvEntry> entriesAll = dotenv.entries();
6464
assertTrue(entriesInFile.size() < entriesAll.size());
6565

src/test/kotlin/tests/DslTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class DotEnvDslTest {
100100
.ignoreIfMalformed()
101101
.load()
102102

103-
val entriesInFile = dotenv.entries(DotenvEntry.Filter.DECLARED_IN_ENV_FILE)
103+
val entriesInFile = dotenv.entries(Dotenv.Filter.DECLARED_IN_ENV_FILE)
104104
val entriesAll = dotenv.entries()
105105
assertTrue(entriesInFile.size < entriesAll.size)
106106

0 commit comments

Comments
 (0)