Could not find property on root project error

Hi All,

I am getting following error when I tried to run the task in gradle

  • Where: Build file ‘D:\MyFolder\CucumberProject\build.gradle’ line: 244

  • What went wrong: A problem occurred evaluating root project ‘CucumberProject’. > Could not find property ‘loadEnvDetails’ on root project ‘CucumberProject’.

task cucumberNew(dependsOn: [assemble, loadEnvDetails]) << {

// This is line 244

javaexec {

main = ‘cucumber.api.cli.Main’

classpath = configurations.cucumberRuntime

def arguments = []

if(rootProject.hasProperty(“tags”)) {

tags.tokenize().each { tag ->





args = arguments + [

‘–tags’, ‘~@ignore’,

‘–format’, ‘junit:build/test-reports/all.xml’,

‘–format’, ‘html:build/test-reports/html/’,

‘–format’, ‘json:build/test-reports/cucumber-report.json’,

‘–format’, ‘pretty’,

‘–glue’, ‘src/test/resources/features’,


systemProperties = config

} }

task loadEnvDetails() << {




What I did wrong?

You need to declare the task before you can reference it using a variable. Alternatively, you can reference the task using a string (’“loadEnvDetails”’ rather than ‘loadEnvDetails’).

Thanks for your reply. Just wondering is there any other place to declare task other than build.gradle.

Because in my current build.gradle I couldn’t see any tasks have been declared within build.gradle