How to access Gradle extra properties in src code?

Thank you,
I have set up my gradle file like below -
If possible can you please advise any improvements
def suiteFile
def APITest = project.hasProperty(“APITest”)
def UITest = project.hasProperty(“UITest”)
def DBTest = project.hasProperty(“DBTest”)
ext.env = findProperty(‘env’) ?: ‘dev’

test{
// enable TestNG support (default is JUnit)
useTestNG()
{
dependsOn ‘cleanTest’
if(APITest) {
suiteFile = ‘APItestng.xml’
}
if(UITest) {
suiteFile = ‘testng.xml’
systemProperty ‘env’, env
}
if(DBTest) {
suiteFile = ‘DBtestng.xml’
}
def reportFolder= suiteFile.substring( 0, suiteFile.indexOf(“ng”))
reports.html.destination = file(“build/reports/tests/”+reportFolder)
useDefaultListeners = true
options.suites “src/test/resources/”+suiteFile
}
testlogger{
showStandardStreams = true
}
// show standard out and standard error of the test JVM(s) on the console
testLogging.showStandardStreams = true

}