Maven Exec Plugin not reading configuration

maven-2maven-plugin

I'm trying to execute my project using the Maven exec:exec goal and I've tried to configure it with this snippet:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1.1</version>
    <configuration>
        <executable>java</executable>
        <arguments>
            <argument>-jar ${staging.dir}/project.jar</argument>
        </arguments>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
</plugin>

When I run mvn exec:exec I get the output:

------------------------------------------------------------------------
[ERROR]BUILD ERROR
------------------------------------------------------------------------
One or more required plugin parameters are invalid/missing for 'exec:exec'

[0] Inside the definition for plugin 'exec-maven-plugin' specify the following:

<configuration>
  ...
  <executable>VALUE</executable>
</configuration>

-OR-

on the command line, specify: '-Dexec.executable=VALUE'

I've tried reorganising the <plugin> everyway I can think of but nothing makes any difference? The project is a POM not a jar.

Any ideas?

Best Solution

I see one issue with your code. You need to put -jar into its own argument element. You will get an error if you don't. The rest of your code is dead on acurate. Here is a working example from one of my projects. This executes a jar that is packaged in the target directory after executing mvn package. If you still get the same error I would try deleting the plugin from your local repository to get a fresh copy. Also ensure that the plugin is not in the pluginsManagement element. If that fails, post your entire POM.

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1.1</version>
    <executions>
        <execution>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <executable>java</executable>
        <workingDirectory>/target</workingDirectory>            
        <arguments>
            <argument>-jar</argument>
            <argument>${project.build.directory}/${project.build.finalName}.jar</argument>
        </arguments>          
    </configuration>
</plugin>
Related Question