Skip to content

Commit 36f0cbc

Browse files
Utils update
1 parent ef53c2d commit 36f0cbc

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,28 @@
104104
<version>${contentstack-utils-version}</version>
105105
<scope>compile</scope>
106106
</dependency>
107+
107108
<dependency>
108109
<groupId>org.json</groupId>
109110
<artifactId>json</artifactId>
110111
<version>${json-version}</version>
111112
<scope>compile</scope>
112113
</dependency>
114+
113115
<dependency>
114116
<groupId>io.github.cdimascio</groupId>
115117
<artifactId>dotenv-java</artifactId>
116118
<version>${dotenv-source.version}</version>
117-
<scope>runtime</scope>
119+
<!-- <scope>runtime</scope>-->
118120
</dependency>
121+
119122
<dependency>
120123
<groupId>io.reactivex.rxjava3</groupId>
121124
<artifactId>rxjava</artifactId>
122125
<version>${rxjava-source.version}</version>
123126
<scope>compile</scope>
124127
</dependency>
128+
125129
<dependency>
126130
<groupId>com.squareup.retrofit2</groupId>
127131
<artifactId>retrofit</artifactId>

src/test/java/com/contentstack/sdk/Credentials.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import io.github.cdimascio.dotenv.Dotenv;
44
import io.github.cdimascio.dotenv.DotenvException;
55

6-
import java.io.File;
7-
import java.io.IOException;
86
import java.rmi.AccessException;
97

108
public class Credentials {
@@ -34,18 +32,24 @@ public class Credentials {
3432
* @return Dotenv
3533
*/
3634
public static Dotenv getEnv() {
35+
String currentDirectory = System.getProperty("user.dir");
36+
//File envFile = new File(currentDirectory, "env");
37+
env = Dotenv.configure()
38+
.directory("src/test/resources")
39+
.filename("env") // instead of '.env', use 'env'
40+
.load();
3741
try {
3842
env = Dotenv.load();
3943
} catch (DotenvException ex) {
40-
String currentDirectory = System.getProperty("user.dir");
41-
File envFile = new File(currentDirectory, ".env");
42-
try {
43-
// Create .env file in the current directory
44-
envFile.createNewFile();
45-
} catch (IOException e) {
46-
System.err.println("An error occurred while creating .env file.");
47-
e.printStackTrace();
48-
}
44+
System.out.println("Could not load from local .env");
45+
// File envFile = new File(currentDirectory, ".env");
46+
// try {
47+
// // Create .env file in the current directory
48+
// envFile.createNewFile();
49+
// } catch (IOException e) {
50+
// System.err.println("An error occurred while creating .env file.");
51+
// e.printStackTrace();
52+
// }
4953
}
5054
return env;
5155
}
File renamed without changes.

0 commit comments

Comments
 (0)