Classname glue causes crash
SJrX opened this issue · comments
When using the IntelliJ Cucumber plugin, when I try and right click on any feature file I get a crash:
Exception in thread "main" java.lang.IllegalArgumentException: Not a file or directory: /home/myname/git/com.mydomain.foo at cucumber.runtime.io.FileResourceIterator$FileIterator.<init>(FileResourceIterator.java:63)
at cucumber.runtime.io.FileResourceIterator.<init>(FileResourceIterator.java:28)
at cucumber.runtime.io.FileResourceIterator.createFileResourceIterator(FileResourceIterator.java:14)
at cucumber.runtime.io.FileResourceIterable.iterator(FileResourceIterable.java:19)
at cucumber.runtime.groovy.GroovyBackend.loadGlue(GroovyBackend.java:75)
at cucumber.runner.Runner.<init>(Runner.java:45)
at cucumber.runtime.Runtime.<init>(Runtime.java:65)
at cucumber.runtime.Runtime.<init>(Runtime.java:45)
at cucumber.runtime.Runtime.<init>(Runtime.java:41)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main.main(Main.java:18)
It seems that the command line that is being generated includes.
/usr/lib/jvm/java-8-jdk/bin/java <ARGS> -classpath <CP> cucumber.api.cli.Main --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter --monochrome --glue com.elasticpath.fixtures --glue com.mydomain.foo /path/to/somefeaturefile.feature
@mpkorstanje helped me out and pointed out to this code where he suspects their may be a problem:
https://github.com/cucumber/cucumber-jvm-groovy/blob/master/groovy/src/main/java/cucumber/runtime/groovy/GroovyBackend.java#L82
In particular that it might need to be prefixing classpath. But I do notice that if I just force the glue on my run configuration in IntelliJ to be classpath:com.mydomain.foo the problem goes away, so I wonder if it's a problem with that.
Hi @SJrX ,
All you've described is correct.
Package names should be prefixed with classpath in glue path.
This prefix is used to determine which resource loader to use https://github.com/cucumber/cucumber-jvm/blob/e471442b0bd6a6d263bbcac03c8079107a36d84d/core/src/main/java/cucumber/runtime/io/MultiLoader.java#L18
If no classpath prefix specified, this glue is treated as file/directory path and will fail with IllegalArgumentException
@glib-briia , should I open a bug with IntelliJ then. I should also point out that @mpkorstanje felt that the classpath rules were only applicable to feature files and not to glue (if memory serves).
Yes, that is correct for java. For groovy, however, we are loading raw . groovy scripts alongside compiled ones. Let me take a look how we can handle that gracefully
Is it common for raw groovy scripts not to be on be placed the classpath?