junit-platform-maven-plugin
junit-platform-maven-plugin copied to clipboard
Execution failed java.io.IOException: Is a directory
I'm trying the simplest configuration possible. This is just by adding the plugin, I haven't even created a module-info.java in the test directory yet.
When I run:
mvn clean install -e
I get the following error:
By debugging the error is that it's trying to access the compiled classes in the target folder, but at the time of execution they haven't been compiled yet. Am I doing something wrong?
This is my full list of plugins in case there's some incompatibility I don't know of with some of them:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>${gmavenplus.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.sormuras.junit</groupId>
<artifactId>junit-platform-maven-plugin</artifactId>
<version>${junit-platform-maven-plugin.version}</version>
<extensions>true</extensions> <!-- Necessary to execute it in 'test' phase. -->
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>${fmt-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
java.version=11 gmavenplus.plugin.version=1.8.1 junit-platform-maven-plugin.version=1.0.0-M5 maven-compiler-plugin.version=3.8.1 maven-surefire-plugin.version=2.22.2 maven-failsafe-plugin.version=2.22.2 fmt-maven-plugin.version=2.9
Seems like the plugin tries to read a non-existent module-info.test
file. Looking into it...
Can you please try using the JAVA
executor in your pom.xml
?
<plugin>
<groupId>de.sormuras.junit</groupId>
<artifactId>junit-platform-maven-plugin</artifactId>
<version>1.0.0-M5</version>
<extensions>true</extensions> <!-- Necessary to execute it in 'test' phase. -->
<configuration>
<executor>JAVA</executor>
</configuration>
</plugin>
Hey @sormuras,
I actually tried even before posting here. The outcome was the same, even though the stacktrace was slightly different.
Below is the full outcome. It seems the plugin is running during the classes compilation time, even in the case where tests are skipped.
glaubernespoli@glauber:~/workspace/java/0_projects/VetClinic/development/modules/core-domain$ mvn clean install -DskipTests
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.vet-clinic:core-domain >---------------------
[INFO] Building Core - Domain 0.1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ core-domain ---
[INFO] Deleting /home/glaubernespoli/workspace/java/0_projects/VetClinic/development/modules/core-domain/target
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ core-domain ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ core-domain ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /home/glaubernespoli/workspace/java/0_projects/VetClinic/development/modules/core-domain/target/classes
[INFO]
[INFO] --- gmavenplus-plugin:1.8.1:compile (default) @ core-domain ---
[INFO] No sources specified for compilation. Skipping.
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ core-domain ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/glaubernespoli/workspace/java/0_projects/VetClinic/development/modules/core-domain/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ core-domain ---
[INFO] Changes detected - recompiling the module!
[INFO]
[INFO] --- gmavenplus-plugin:1.8.1:compileTests (default) @ core-domain ---
[INFO] No sources specified for compilation. Skipping.
[INFO]
[INFO] --- junit-platform-maven-plugin:1.0.0-M5:launch (injected-launch) @ core-domain ---
[INFO] Launching JUnit Platform 1.5.2...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.631 s
[INFO] Finished at: 2019-12-11T16:15:53+01:00
[INFO] ------------------------------------------------------------------------
---------------------------------------------------
constituent[0]: file:/usr/share/maven/conf/logging/
constituent[1]: file:/usr/share/maven/lib/wagon-provider-api.jar
constituent[2]: file:/usr/share/maven/lib/commons-cli.jar
constituent[3]: file:/usr/share/maven/lib/maven-model-3.x.jar
constituent[4]: file:/usr/share/maven/lib/maven-embedder-3.x.jar
constituent[5]: file:/usr/share/maven/lib/plexus-component-annotations.jar
constituent[6]: file:/usr/share/maven/lib/wagon-http-shaded.jar
constituent[7]: file:/usr/share/maven/lib/maven-compat-3.x.jar
constituent[8]: file:/usr/share/maven/lib/guice.jar
constituent[9]: file:/usr/share/maven/lib/plexus-utils.jar
constituent[10]: file:/usr/share/maven/lib/commons-lang3.jar
constituent[11]: file:/usr/share/maven/lib/slf4j-api.jar
constituent[12]: file:/usr/share/maven/lib/plexus-sec-dispatcher.jar
constituent[13]: file:/usr/share/maven/lib/javax.inject.jar
constituent[14]: file:/usr/share/maven/lib/maven-slf4j-provider-3.x.jar
constituent[15]: file:/usr/share/maven/lib/maven-plugin-api-3.x.jar
constituent[16]: file:/usr/share/maven/lib/sisu-plexus.jar
constituent[17]: file:/usr/share/maven/lib/maven-resolver-connector-basic.jar
constituent[18]: file:/usr/share/maven/lib/sisu-inject.jar
constituent[19]: file:/usr/share/maven/lib/maven-artifact-3.x.jar
constituent[20]: file:/usr/share/maven/lib/commons-io.jar
constituent[21]: file:/usr/share/maven/lib/maven-resolver-api.jar
constituent[22]: file:/usr/share/maven/lib/maven-resolver-util.jar
constituent[23]: file:/usr/share/maven/lib/maven-repository-metadata-3.x.jar
constituent[24]: file:/usr/share/maven/lib/maven-builder-support-3.x.jar
constituent[25]: file:/usr/share/maven/lib/maven-resolver-transport-wagon.jar
constituent[26]: file:/usr/share/maven/lib/maven-core-3.x.jar
constituent[27]: file:/usr/share/maven/lib/maven-settings-3.x.jar
constituent[28]: file:/usr/share/maven/lib/maven-model-builder-3.x.jar
constituent[29]: file:/usr/share/maven/lib/cdi-api.jar
constituent[30]: file:/usr/share/maven/lib/jcl-over-slf4j.jar
constituent[31]: file:/usr/share/maven/lib/guava.jar
constituent[32]: file:/usr/share/maven/lib/maven-shared-utils.jar
constituent[33]: file:/usr/share/maven/lib/plexus-interpolation.jar
constituent[34]: file:/usr/share/maven/lib/plexus-cipher.jar
constituent[35]: file:/usr/share/maven/lib/maven-resolver-provider-3.x.jar
constituent[36]: file:/usr/share/maven/lib/aopalliance.jar
constituent[37]: file:/usr/share/maven/lib/jsr250-api.jar
constituent[38]: file:/usr/share/maven/lib/maven-resolver-impl.jar
constituent[39]: file:/usr/share/maven/lib/jansi.jar
constituent[40]: file:/usr/share/maven/lib/maven-resolver-spi.jar
constituent[41]: file:/usr/share/maven/lib/maven-settings-builder-3.x.jar
constituent[42]: file:/usr/share/maven/lib/wagon-file.jar
---------------------------------------------------
Exception in thread "main" java.lang.AssertionError: Unexpected exception caught!
at de.sormuras.junit.platform.maven.plugin.JUnitPlatformMojo.execute(JUnitPlatformMojo.java:418)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: java.io.UncheckedIOException: java.io.IOException: Is a directory
at java.base/java.nio.file.FileChannelLinesSpliterator.readLine(FileChannelLinesSpliterator.java:173)
at java.base/java.nio.file.FileChannelLinesSpliterator.forEachRemaining(FileChannelLinesSpliterator.java:113)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
at de.sormuras.junit.platform.isolator.Configuration$Basic.parseModuleInfoTestLines(Configuration.java:139)
at de.sormuras.junit.platform.maven.plugin.JavaPatcher.patch(JavaPatcher.java:52)
at de.sormuras.junit.platform.maven.plugin.JavaExecutor.addJavaOptions(JavaExecutor.java:160)
at de.sormuras.junit.platform.maven.plugin.JavaExecutor.evaluate(JavaExecutor.java:67)
at de.sormuras.junit.platform.maven.plugin.JUnitPlatformMojo.executeJava(JUnitPlatformMojo.java:449)
at de.sormuras.junit.platform.maven.plugin.JUnitPlatformMojo.execute(JUnitPlatformMojo.java:427)
at de.sormuras.junit.platform.maven.plugin.JUnitPlatformMojo.execute(JUnitPlatformMojo.java:411)
... 22 more
Caused by: java.io.IOException: Is a directory
at java.base/sun.nio.ch.FileDispatcherImpl.pread0(Native Method)
at java.base/sun.nio.ch.FileDispatcherImpl.pread(FileDispatcherImpl.java:54)
at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:274)
at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:245)
at java.base/sun.nio.ch.FileChannelImpl.readInternal(FileChannelImpl.java:811)
at java.base/sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:796)
at java.base/java.nio.file.FileChannelLinesSpliterator$1.read(FileChannelLinesSpliterator.java:137)
at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:274)
at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.base/java.io.BufferedReader.fill(BufferedReader.java:161)
at java.base/java.io.BufferedReader.readLine(BufferedReader.java:326)
at java.base/java.io.BufferedReader.readLine(BufferedReader.java:392)
at java.base/java.nio.file.FileChannelLinesSpliterator.readLine(FileChannelLinesSpliterator.java:171)
... 36 more
Found the underlying issue:
https://github.com/sormuras/junit-platform-maven-plugin/blob/01d12f7bda2442bb0924af7e6701f373ce55da20/src/main/java/de/sormuras/junit/platform/maven/plugin/JUnitPlatformMojo.java#L547-L554
The empty string ""
is treated as the "current working directory". Fix in progress...
@sormuras amazing. Thanks!
Since I face the same bug (and this is my first time I try testing in the Java module world), I wonder what the workaround is?
IIRC, the work around was to provide some kind of a test/java
directory. Either an empty one, or one with at least a single test, or one with with modul-info.test
file.
Need to re-investigate this issue. Perhaps, I'll rewrite the plugin anyway, "soon"™.
[...] first time I try testing in the Java module world [...]
Have a look (and copy) the directory structure of the modular-world...
integration tests at: https://github.com/sormuras/junit-platform-maven-plugin/tree/master/src/it -- they still should work.