Error: Could not find or load main class cucumber.api.cli.Main

Error: Could not find or load main class cucumber.api.cli.Main

我尝试运行这个gradle任务

task runCucumber(type: JavaExec) {
    main = "cucumber.api.cli.Main"
    args += ['-f', 'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue', 'com.waze.testing.cucumber', 'src/main/resources/features'
             , '--tags', '~@ignore', '--tags', '~@preRelease', '--tags', '@advil']
    systemProperties['http.keepAlive'] = 'false'
    systemProperties['http.maxRedirects'] = '20'
    ignoreExitValue = true
}

并得到这个错误:

Error: Could not find or load main class cucumber.api.cli.Main

这是为什么?我可以在随附的黄瓜罐中找到它。

编辑

我已经完成了 运行 成功的任务:

mainClassName = "cucumber.api.cli.Main"

    run {
        args += ['-f', 'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue', 'com.waze.testing.cucumber', 'src/main/resources/features'
                 , '--tags', '~@ignore', '--tags', '~@preRelease']
        systemProperties['http.keepAlive'] = 'false'
        systemProperties['http.maxRedirects'] = '20'
    }

以下脚本在正确配置方面有效,但失败了,因为现在有 features/test 个要检查。

apply plugin: 'java'

repositories {
    mavenCentral()
}

configurations {
    cucumber
}

dependencies {
    cucumber 'info.cukes:cucumber-java:1.2.2'
}

task runCucumber(type: JavaExec) {
    main = "cucumber.api.cli.Main"
    args += ['-f', 'html:build/reports/cucumber/', '-f', 'json:build/reports/cucumber/report.json', '--glue', 'com.waze.testing.cucumber', 'src/main/resources/features'
             , '--tags', '~@ignore', '--tags', '~@preRelease', '--tags', '@advil']
    systemProperties['http.keepAlive'] = 'false'
    systemProperties['http.maxRedirects'] = '20'
    ignoreExitValue = true
    classpath = configurations.cucumber
}

这就是 JavaExec 类路径应该如何修改。