Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 19870

How to access Gradle extra properties in src code?

$
0
0

task in build.gradle file -

task automationTest(type: Test) {
    ext.env = rootProject.hasProperty('TS1') ? rootProject['TS2'] : 'TS1'
    println env //printing passed pararmeter successfully
}

now I want to access env in Login class in src/main/java

I know i can access variables from build.gradle to any java class by using system property like systemProperty ‘env’,System.properties[‘env’] ?: ‘dev’ command in build.gradle, from console gradle -Denv=test and then accessing System.getProperty(“env”) from anywhere in src but i want to understand if i create env as ext property or project property then how can i use env from any java class?
Can anyone please help?

Also what should be the ideal way to use variables(System property or project property) in src from Build.gradle?


Viewing all articles
Browse latest Browse all 19870

Trending Articles