Qoros
Qoros

Reputation: 513

maven `exec:exec` fails but `exec:java` succeeds

I learned that the Exec Maven Plugin have two goals, exec:exec, and exec:java, but I don't know how to specify them:

In my case, the mvn exec:java works well, but the mvn exec:exec keeps throwing exceptions like below:

[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)

my pom.xml is like this:

    <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>

Upvotes: 1

Views: 766

Answers (1)

Luc
Luc

Reputation: 1433

in your pom you have the name of your executable: exec And the name "exec" is not a valid executable name.

You configure your goal there:

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

If you want to use exec:java, you need to change your goal from exec to java.

I am referring the usage page: https://www.mojohaus.org/exec-maven-plugin/usage.html

Let me know if something need clarification!

Upvotes: 1

Related Questions