maven`exec:exec`失败,但`exec:java`成功

时间:2018-04-23 09:50:01

标签: maven maven-3 maven-plugin

我了解到Exec Maven Plugin有两个目标,exec:execexec: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>

1 个答案:

答案 0 :(得分:1)

在你的pom中,你有可执行文件的名称: EXEC 而名称&#34; exec&#34;不是有效的可执行文件名。

您可以在那里配置目标:

<execution>
    <id>bar</id>
    <goals>
        <goal>exec</goal>
    </goals>
</execution>

如果要使用exec:java,则需要将目标从exec更改为java。

我指的是用法页面: https://www.mojohaus.org/exec-maven-plugin/usage.html

如果需要澄清,请告诉我!

相关问题