Could not find property on root project error


(Habar) #1

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 ->

arguments.add(’–tags’)

arguments.add(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’,

‘src/test/resources/features’]

systemProperties = config

} }

task loadEnvDetails() << {

loadEnvironmentConfiguration()

println System.properties[‘os.name’]

}

What I did wrong?


(Peter Niederwieser) #2

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’).


(Habar) #3

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