我了解到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>
答案 0 :(得分:1)
您可以在那里配置目标:
<execution>
<id>bar</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
如果要使用exec:java,则需要将目标从exec更改为java。
我指的是用法页面: https://www.mojohaus.org/exec-maven-plugin/usage.html
如果需要澄清,请告诉我!