How to access environment variables in gradle java build script

How can I access environment variables (user level or system level) in gradle java build script.
I am new to gradle and I am trying to build my project using gradle.
Currently, I have hardcoded the path to third-party banks, as shown in the script below

repositories { flatDir { dirs 'D:\\lib' } } 

I created the environment variable "Third_Party" in enviroment variable :

 Third_Party=D:\lib 

How can I use this variable i.e. "Third_Party", not hard code the library path in the script.
Please specify exact syntax

+6
source share
1 answer

try this way System.getenv("env var name") as

 home = System.getenv('Third_Party') task env_read << { println "$System.env.HOME" //Other way of accessing the environment variable. println System.getenv('Third_Party') } 
+12
source

Source: https://habr.com/ru/post/980913/


All Articles