Skip to content

Commit 1ecf71a

Browse files
Maskim BuryshynetsMaskim Buryshynets
authored andcommitted
updated documentation;
1 parent 11573eb commit 1ecf71a

File tree

3 files changed

+76
-10
lines changed

3 files changed

+76
-10
lines changed

README.md

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,62 @@ However, there are several aspects that could be improved:
1111
to use existing `java.util.Properties` instead of any manual work
1212
- [dotenv-java][1] cannot resolve references between properties
1313

14-
To install the library add:
14+
In other words, instead of reimplementing bicycle and parsing `.env` file manually using regular expressions, etc., it's
15+
loaded just like the usual `.properties` file. In my implementation, I tried to concentrate on the functionality that,
16+
in my opinion, is exactly what is missing - resolving references.
1517

16-
```gradle
17-
repositories {
18-
maven { url 'https://jitpack.io' }
19-
}
18+
Consider for example a file with the following content:
2019

21-
dependencies {
22-
implementation 'com.github.arhor:java-dotenv-revised:0.1.3'
23-
}
20+
```properties
21+
A=1
22+
B=2
23+
C=3
24+
D=${A} ${B} ${C}
2425
```
2526

27+
Trying to get property `D` will lead to value `1 2 3` be resolved.
28+
29+
## Installation
30+
31+
Here you can find the instructions for installing the library using various build systems.
32+
33+
### Gradle
34+
35+
1. Add Jitpack repository to your repositories list
36+
```groovy
37+
repositories {
38+
// ...other repositories you use...
39+
maven { url 'https://jitpack.io' }
40+
}
41+
```
42+
43+
2. Add library dependency to you dependencies list
44+
```groovy
45+
dependencies {
46+
implementation 'com.github.arhor:java-dotenv-revised:0.1.4'
47+
}
48+
```
49+
50+
### Maven
51+
52+
1. Add Jitpack repository to your repositories list
53+
```xml
54+
<repositories>
55+
<!-- ...other repositories you use... -->
56+
<repository>
57+
<id>jitpack.io</id>
58+
<url>https://jitpack.io</url>
59+
</repository>
60+
</repositories>
61+
```
62+
63+
2. Add library dependency to you dependencies list
64+
```xml
65+
<dependency>
66+
<groupId>com.github.arhor</groupId>
67+
<artifactId>java-dotenv-revised</artifactId>
68+
<version>0.1.4</version>
69+
</dependency>
70+
```
71+
2672
[1]: https://github.com/cdimascio/dotenv-java

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ check {
8989
publishing {
9090
publications {
9191
create('maven', MavenPublication) {
92-
it.from components['java']
92+
from components['java']
9393

94-
it.pom {
94+
pom {
9595
licenses {
9696
license {
9797
name.set('The Apache License, Version 2.0')

src/main/java/io/github/arhor/dotenv/Dotenv.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,32 @@ static DotenvConfigurer configure() {
1818
return DotenvConfigurer.getInstance();
1919
}
2020

21+
/**
22+
* Returns property value for the given name.
23+
*
24+
* @param name property name
25+
* @return property value if present, otherwise null
26+
*/
2127
@Nullable
2228
String get(@Nullable String name);
2329

30+
/**
31+
* Returns property value for the given name. If value is missing provided default value is used.
32+
*
33+
* @param name property name
34+
* @param defaultValue default value to use
35+
* @return property value if present, otherwise default value
36+
*/
2437
@Nullable
2538
String get(@Nullable String name, @Nullable String defaultValue);
2639

40+
/**
41+
* Returns property value for the given name. If value is missing {@link MissingPropertyException} is thrown.
42+
*
43+
* @param name property name
44+
* @return property value if present, otherwise throws an exception
45+
* @throws MissingPropertyException exception thrown in case value by the given name is missing
46+
*/
2747
@Nonnull
2848
String getRequired(@Nonnull String name) throws MissingPropertyException;
2949
}

0 commit comments

Comments
 (0)