0

I am to switch between DB localhost or a dev server DB depending on the system I am running the code.

in the build.gradle

System.getenv()

System.getProperty("test.property") but this one comes as null.

2 possible solutions, 1) set the System varibale 2) Try some other way to get the domain

Appreciate your answers

Expecting a way to get the domain so that i can decide which DB and other scripts to be used.

sachyy
  • 532
  • 4
  • 8

1 Answers1

0

To read an env var in gradle,

  • var myvar = "$System.env.myvar"
  • System.getenv("myvar")

Also, try to avoid special characters such as . in env prop names.

If you really want to get the domain name, consider executing a windows command and store the output in a string.

How to use exec() output in gradle

Other options could be...

Creating .local file with no content, adding it to .gitignore, and then checking its existence. It could be created in the local dev machines, but be missing from other places.

Adding something to the ~/.gradle/gradle.properties file. Because this is picked up on the local machine, you can test for it. But, in other places where it is not set, you wouldn't see it.

User51
  • 887
  • 8
  • 17