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.
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.