在 Windows 上:
我尝试执行下一个 mvn 命令:
mvn install -DjenkinsAcceptance=true -Dcucumber.forkCount=4 -Dcucumber.test.failure.ignore=true
但是上升错误:
[ERROR] Command execution failed.
java.io.IOException: Cannot run program "C:\Users\myuser\.sdkman\candidates\java\current\bin\java.exe" (in directory "C:\dev\myproject\module2\target\runtime"): CreateProcess error=206, The filename or extension is too long
at java.lang.ProcessBuilder.start (ProcessBuilder.java:1048)
at java.lang.Runtime.exec (Runtime.java:594)
at org.apache.commons.exec.launcher.Java13CommandLauncher.exec (Java13CommandLauncher.java:61)
at org.apache.commons.exec.DefaultExecutor.launch (DefaultExecutor.java:279)
at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:336)
at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:764)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:711)
at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:289)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:904)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:281)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:204)
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.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long
at java.lang.ProcessImpl.create (Native Method)
at java.lang.ProcessImpl.<init> (ProcessImpl.java:453)
at java.lang.ProcessImpl.start (ProcessImpl.java:139)
at java.lang.ProcessBuilder.start (ProcessBuilder.java:1029)
at java.lang.Runtime.exec (Runtime.java:594)
我找到了解决方案。在 Maven 插件中使用
<longClasspath>
exec-maven-plugin
在pom.xml中
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.5.0</version>
<configuration>
...
<longClasspath>true</classpathScope>
...
</configuration>
</plugin>