首页 > 解决方案 > 在 org.gradle.api.internal.file.DefaultSourceDirectorySet 类型的黄瓜 Java 源上找不到方法 outputDir()

问题描述

我无法为“com.github.samueltbrown.cucumber”插件运行黄瓜任务。

我收到以下错误:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/freid/app/build.gradle' line: 118

* What went wrong:
A problem occurred evaluating root project 'app'.
> Could not find method outputDir() for arguments [/Users/freid/app/src/cucumber/java] on cucumber Java source of type org.gradle.api.internal.file.DefaultSourceDirectorySet.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

这是我的 build.gradle 文件:

buildscript {
    ext {
        springBootVersion='2.2.4.RELEASE'
        lombokVersion='1.18.4'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

plugins {
    id 'org.springframework.boot' version '2.2.4.RELEASE'
    id 'java'
    id 'com.github.psxpaul.execfork' version '0.1.8'
    id "com.jfrog.artifactory" version "4.7.2"
    id "com.github.samueltbrown.cucumber" version "0.9"
}

dependencies {
    testCompile 'info.cukes:cucumber-java:1.2.4'
}

sourceSets {
    cucumber {
        java {
            compileClasspath += main.output + test.output
            runtimeClasspath += main.output + test.output
            srcDir file('src/cucumber/java')
        }
        resources.srcDir file('src/cucumber/resources')
    }
}

cucumber {
    formats = ['html:build/reports/html', 'json:build/reports/cucumber.json']

    jvmOptions {
        environment 'tag', System.getProperty("tag")
        environment 'cucumber.local.server', 'localhost'
    }
}

标签: javagradlecucumber

解决方案


鉴于插件com.github.samueltbrown.cucumber版本 0.9 于 2015 年发布,并且您尝试使用最新的 Spring Boot 版本运行,我假设您也在使用最新的 Gradle 版本。

所以我相信你遇到了插件和 Gradle 版本之间的不兼容问题。很可能是 API 发生了变化,插件内部的功能不再有效。 [/Users/freid/app/src/cucumber/java]看起来像toString文件集合的 ,而SourceDirectorySet.outputDir只接受一个File. 所以我的猜测是,返回所用值的 API 在某个时候从单个文件更改为文件集合。


推荐阅读