maven `exec:exec` 失败但 `exec:java` 成功
maven `exec:exec` fails but `exec:java` succeeds
我了解到 Exec Maven Plugin 有两个目标,exec:exec
和 exec:java
,但我不知道如何指定它们:
在我的例子中,mvn exec:java
运行良好,但 mvn exec:exec
不断抛出异常,如下所示:
[INFO] --- exec-maven-plugin:1.6.0:exec (run) @ allnewmaker ---
[ERROR] Command execution failed.
java.io.IOException: Cannot run program "exec" (in directory "/home/huang/Desktop/Project/Make/allnewmaker"): error=2, No such file or directory
at java.lang.ProcessBuilder.start (ProcessBuilder.java:1048)
at java.lang.Runtime.exec (Runtime.java:620)
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:804)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:751)
我的pom.xml
是这样的:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>bar</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>foo</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<!--default: java-->
<executable>exec</executable>
<arguments>
<argument>-i</argument>
<argument>${argInput}</argument>
<argument>-o</argument>
<argument>${argOutput}</argument>
</arguments>
<mainClass>org.qoros.maker.AllNewMaker</mainClass>
</configuration>
</plugin>
</plugins>
在您的 pom 中,您有可执行文件的名称:
执行
名称 "exec" 不是有效的可执行文件名称。
您在那里配置您的目标:
<execution>
<id>bar</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
如果您想使用 exec:java,您需要将目标从 exec 更改为 java。
我指的是使用页面:
https://www.mojohaus.org/exec-maven-plugin/usage.html
如果有什么需要澄清的,请告诉我!
我了解到 Exec Maven Plugin 有两个目标,exec:exec
和 exec:java
,但我不知道如何指定它们:
在我的例子中,mvn exec:java
运行良好,但 mvn exec:exec
不断抛出异常,如下所示:
[INFO] --- exec-maven-plugin:1.6.0:exec (run) @ allnewmaker ---
[ERROR] Command execution failed.
java.io.IOException: Cannot run program "exec" (in directory "/home/huang/Desktop/Project/Make/allnewmaker"): error=2, No such file or directory
at java.lang.ProcessBuilder.start (ProcessBuilder.java:1048)
at java.lang.Runtime.exec (Runtime.java:620)
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:804)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:751)
我的pom.xml
是这样的:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>bar</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>foo</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<!--default: java-->
<executable>exec</executable>
<arguments>
<argument>-i</argument>
<argument>${argInput}</argument>
<argument>-o</argument>
<argument>${argOutput}</argument>
</arguments>
<mainClass>org.qoros.maker.AllNewMaker</mainClass>
</configuration>
</plugin>
</plugins>
在您的 pom 中,您有可执行文件的名称: 执行 名称 "exec" 不是有效的可执行文件名称。
您在那里配置您的目标:
<execution>
<id>bar</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
如果您想使用 exec:java,您需要将目标从 exec 更改为 java。
我指的是使用页面: https://www.mojohaus.org/exec-maven-plugin/usage.html
如果有什么需要澄清的,请告诉我!