在 POM 文件中更新 cucumber-groovy 版本时获取 java.lang.IllegalArgumentException

Getting a java.lang.IllegalArgumentException when updating cucumber-groovy version in POM file

将 POM 文件中的 cucumber-groovy 版本从 4.2.0 更新到 4.7.0

时出现以下异常
java.lang.IllegalArgumentException: The glue path contained invalid identifiers target/test-classes
    at io.cucumber.core.model.GluePath.parseAssumeClasspathScheme (GluePath.java:84)
    at io.cucumber.core.model.GluePath.parse (GluePath.java:53)
    at io.cucumber.core.options.RuntimeOptionsParser.parse (RuntimeOptionsParser.java:85)
    at io.cucumber.core.options.CommandlineOptionsParser.parse (CommandlineOptionsParser.java:25)
    at io.cucumber.core.options.CommandlineOptionsParser.parse (CommandlineOptionsParser.java:29)
    at io.cucumber.core.cli.Main.run (Main.java:29)
    at io.cucumber.core.cli.Main.main (Main.java:14)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.mojo.exec.ExecJavaMojo.run (ExecJavaMojo.java:282)
    at java.lang.Thread.run (Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.329 s
[INFO] Finished at: 2019-10-28T19:17:41+11:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default) on project sample-test: An exception occured while executing the Java class. The glue path contained invalid identifiers target/test-classes -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

这是 POM 文件中产生错误的部分(我相信)

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <classpathScope>test</classpathScope>
                            <mainClass>io.cucumber.core.cli.Main</mainClass>    <!-- NEEDED FOR cucumber-groovy version 4.7.1 -->
                            <!--<mainClass>cucumber.api.cli.Main</mainClass>--> <!-- NEEDED FOR cucumber-groovy version 4.2.0 -->
                            <arguments>
                                <argument>--plugin</argument>
                                <argument>json:reports/junit.json</argument>
                                <argument>--strict</argument>
                                <argument>--glue</argument>
                                <argument>target/test-classes</argument>
                                <argument>target/test-classes/.</argument>
                                <argument>--tags</argument>
                                <argument>${tagArg}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

这里是 POM 文件的属性部分

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <cluecumber-report-plugin.version>2.3.1</cluecumber-report-plugin.version>
        <exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
        <maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
        <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
        <ocular.version>1.0.0.Alpha</ocular.version>
        <groovycsv.version>1.3</groovycsv.version>
        <ashot.version>1.5.4</ashot.version>
        <webdrivermanager.version>3.7.1</webdrivermanager.version>
        <com4j.version>2.1</com4j.version>
        <geb-core.version>3.2</geb-core.version>
        <http-builder.version>0.7.1</http-builder.version>
        <commons-io.version>2.6</commons-io.version>
        <selenium-api.version>3.141.59</selenium-api.version>
        <selenium-java.version>3.141.59</selenium-java.version>
        <slf4j-simple.version>1.7.28</slf4j-simple.version>
        <cucumber-jvm.version>4.8.0</cucumber-jvm.version>
        <cucumber-groovy.version>4.7.0</cucumber-groovy.version>
        <groovy-all.version>2.5.8</groovy-all.version>
    </properties>

相同的 POM 文件在使用 cucumber-groovy 4.2.0 版时工作正常,是否有不同的方法来为新版本的 cucumber-groovy 指定胶水代码?

我试过使用以下方法,但 none 有效。

target.test-classes
target
test-classes

我的文件夹结构是

src\test\resources\features
src\test\resources\step_definitions

非常感谢任何帮助。 谢谢!

您当前将您的胶水作为 --glue target/test-classes target/test-classes/. 传递,但是您的胶水应该是包名称或 class 路径 uri。要访问无名包中的资源,您可以改用 --glue classpath:

更新 POM 文件并替换 --glue target/test-classes target/test-classes/.--glue classpath: classpath:/.