Issue
I'm getting the following exception when updating the cucumber-groovy version in my POM file from 4.2.0 to 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$1.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
This is the section of POM file where the error is being generated from (I believe)
<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>
And here is the properties section of the POM file
<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>
Same POM file works fine when using the cucumber-groovy version 4.2.0, is there a different way to specify the glue code for newer version of cucumber-groovy?
I have tried using the following but none of them worked.
target.test-classes
target
test-classes
My folder structure is
src\test\resources\features
src\test\resources\step_definitions
Any help is highly appreciated. Thanks!
Solution
You currently pass your glue as --glue target/test-classes target/test-classes/.
However your glue should be either a package name or class path uri. To access resources in the nameless package you can use --glue classpath:
instead.
Answered By - M.P. Korstanje
Answer Checked By - Cary Denson (JavaFixing Admin)