diff --git a/pom.xml b/pom.xml
index 45e3f8f..41be6cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
io.github.cdimascio
dotenv-java
- 2.0.0
+ 2.1.0
@@ -51,14 +51,24 @@
- 11
- 11
io.github.cdimascio.dotenv.Dotenv
- 4.12
UTF-8
+
+ 1.8
+ 11
+ 8
+
docs/javadoc
+
+ 4.12
+
3.0.1
3.2.0
+ 2.22.0
+ 0.8.6
+ 4.3.0
+ 1.0.1
+
cdimascio
maven
dotenv-java
@@ -85,6 +95,19 @@
${project.basedir}/src/main/java
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+
+ ${compile.source}
+ ${compile.test.source}
+ ${compile.test.source}
+
+
+
org.apache.maven.plugins
@@ -106,11 +129,11 @@
-
+
org.apache.maven.plugins
maven-surefire-plugin
- 2.22.0
+ ${maven.surefire.plugin}
org.apache.maven.surefire
@@ -146,6 +169,7 @@
maven-javadoc-plugin
${maven.javadoc.plugin}
+
@@ -162,7 +186,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.6
+ ${maven.jacoco.plugin}
prepare-agent
@@ -177,7 +201,7 @@
org.eluder.coveralls
coveralls-maven-plugin
- 4.3.0
+ ${maven.coveralls.plugin}
r92OLg0S3kCJakLAMW6HlLsDgNSMaolGS
@@ -194,7 +218,7 @@
com.coderplus.maven.plugins
copy-rename-maven-plugin
- 1.0.1
+ ${maven.copy.rename.plugin}
copy-file
@@ -206,26 +230,26 @@
${project.basedir}/pom.xml
- ${project.build.directory}/dotenv-java-2.0.0.pom
+ ${project.build.directory}/dotenv-java-2.1.0.pom
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/io/github/cdimascio/dotenv/DotenvBuilder.java b/src/main/java/io/github/cdimascio/dotenv/DotenvBuilder.java
index 6e7cec7..d25cf40 100644
--- a/src/main/java/io/github/cdimascio/dotenv/DotenvBuilder.java
+++ b/src/main/java/io/github/cdimascio/dotenv/DotenvBuilder.java
@@ -78,7 +78,7 @@ public Dotenv load() throws DotenvException {
new DotenvReader(directoryPath, filename),
throwIfMissing,
throwIfMalformed);
- var env = reader.parse();
+ List env = reader.parse();
if (systemProperties) {
env.forEach(it -> System.setProperty(it.getKey(), it.getValue()));
}
@@ -117,13 +117,13 @@ public Set entries(Dotenv.Filter filter) {
@Override
public String get(String key) {
- var value = System.getenv(key);
+ String value = System.getenv(key);
return value != null ? value : envVars.get(key);
}
@Override
public String get(String key, String defaultValue) {
- var value = this.get(key);
+ String value = this.get(key);
return value != null ? value : defaultValue;
}
}
diff --git a/src/main/java/io/github/cdimascio/dotenv/internal/ClasspathHelper.java b/src/main/java/io/github/cdimascio/dotenv/internal/ClasspathHelper.java
index 5091137..a1d796d 100644
--- a/src/main/java/io/github/cdimascio/dotenv/internal/ClasspathHelper.java
+++ b/src/main/java/io/github/cdimascio/dotenv/internal/ClasspathHelper.java
@@ -2,14 +2,16 @@
import io.github.cdimascio.dotenv.DotenvException;
+import java.io.InputStream;
import java.util.ArrayList;
+import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;
public class ClasspathHelper {
static Stream loadFileFromClasspath(String location) {
Class loader = ClasspathHelper.class;
- var inputStream = loader.getResourceAsStream(location);
+ InputStream inputStream = loader.getResourceAsStream(location);
if (inputStream == null) {
inputStream = loader.getResourceAsStream(location);
}
@@ -20,8 +22,8 @@ static Stream loadFileFromClasspath(String location) {
if (inputStream == null) {
throw new DotenvException("Could not find "+location+" on the classpath");
}
- var scanner = new Scanner(inputStream, "utf-8");
- var lines = new ArrayList();
+ Scanner scanner = new Scanner(inputStream, "utf-8");
+ List lines = new ArrayList<>();
while (scanner.hasNext()) {
lines.add(scanner.nextLine());
}
diff --git a/src/main/java/io/github/cdimascio/dotenv/internal/DotenvParser.java b/src/main/java/io/github/cdimascio/dotenv/internal/DotenvParser.java
index 4391cf2..ce858d6 100644
--- a/src/main/java/io/github/cdimascio/dotenv/internal/DotenvParser.java
+++ b/src/main/java/io/github/cdimascio/dotenv/internal/DotenvParser.java
@@ -7,6 +7,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DotenvParser {
@@ -26,18 +27,18 @@ public DotenvParser(DotenvReader reader, boolean throwIfMissing, boolean throwIf
}
public List parse() throws DotenvException {
- var entries = new ArrayList();
- for (var line : lines()) {
- var l = line.trim();
+ List entries = new ArrayList<>();
+ for (String line : lines()) {
+ String l = line.trim();
if (isWhiteSpace.apply(l) || isComment.apply(l) || l.isBlank()) continue;
- var entry = parseLine.apply(l);
+ DotenvEntry entry = parseLine.apply(l);
if (entry == null) {
if (throwIfMalformed) throw new DotenvException("Malformed entry "+ l);
continue;
}
- var key = entry.getKey();
- var value = normalizeValue(entry.getValue());
+ String key = entry.getKey();
+ String value = normalizeValue(entry.getValue());
entries.add(new DotenvEntry(key, value));
}
return entries;
@@ -55,22 +56,22 @@ private List lines() throws DotenvException {
}
private String normalizeValue(String value) {
- var tr = value.trim();
+ String tr = value.trim();
return isQuoted.apply(tr)
? tr.substring(1, value.length() -1)
: tr;
}
private static boolean matches(String regex, String text) {
- var pattern = Pattern.compile(regex);
- var matcher = pattern.matcher(text);
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(text);
return matcher.matches();
}
private static DotenvEntry matchEntry(String regex, String text) {
- var pattern = Pattern.compile(regex);
- var matcher = pattern.matcher(text);
- var result = matcher.matches();
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(text);
+ boolean result = matcher.matches();
if (!result || matcher.groupCount() < 3) return null;
return new DotenvEntry(matcher.group(1), matcher.group(3));
}
diff --git a/src/main/java/io/github/cdimascio/dotenv/internal/DotenvReader.java b/src/main/java/io/github/cdimascio/dotenv/internal/DotenvReader.java
index e7108a3..875cad5 100644
--- a/src/main/java/io/github/cdimascio/dotenv/internal/DotenvReader.java
+++ b/src/main/java/io/github/cdimascio/dotenv/internal/DotenvReader.java
@@ -6,6 +6,7 @@
import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
@@ -20,14 +21,14 @@ public DotenvReader(String directory, String filename) {
}
public List read() throws DotenvException, IOException {
- var dir = directory
+ String dir = directory
.replaceAll("\\\\", "/")
.replaceFirst("\\.env$", "")
.replaceFirst("/$", "");
- var location = dir + "/" + filename;
- var lowerLocation = location.toLowerCase();
- var path = lowerLocation.startsWith("file:") || lowerLocation.startsWith("android.resource:")
+ String location = dir + "/" + filename;
+ String lowerLocation = location.toLowerCase();
+ Path path = lowerLocation.startsWith("file:") || lowerLocation.startsWith("android.resource:")
? Paths.get(URI.create(location))
: Paths.get(location);
@@ -42,8 +43,8 @@ public List read() throws DotenvException, IOException {
.loadFileFromClasspath(location.replaceFirst("./", "/"))
.collect(Collectors.toList());
} catch (DotenvException e) {
- var cwd = FileSystems.getDefault().getPath(".").toAbsolutePath().normalize();
- var cwdMessage = !path.isAbsolute() ? "(working directory: " + cwd + ")" : "";
+ Path cwd = FileSystems.getDefault().getPath(".").toAbsolutePath().normalize();
+ String cwdMessage = !path.isAbsolute() ? "(working directory: " + cwd + ")" : "";
e.addSuppressed(new DotenvException("Could not find " + path + " on the file system " + cwdMessage));
throw e;
}