Q:

Passing arguments to inner command of maven-exec-plugin failed

I am trying to use the maven-exec-plugin to launch the ejbdeploy command for my old project made with EJB 2.1
The thing is that one of the argument of the command is another command (RMIC) which has arguments too that I need to use. 
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>ejb-deploy</id>
            <phase>package</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>ejbdeploy</executable>
                    <arguments>
                        <argument>${project.build.directory}\${project.build.finalName}.jar</argument>
                        <argument>${project.build.directory}\working</argument>
                        <argument>${project.build.directory}\${project.build.finalName}-deployed.jar</argument>
                        <argument>-rmic "-d C:\java\classes"</argument>
                        <argument>-cp</argument>
                        <classpath/>
                    </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

This snippet generates an error during my mvn clean install :
[INFO] --- exec-maven-plugin:1.5.0:exec (ejb-deploy) @ SIMBOLight ---
Unrecognized option: -rmic -d. 
Unrecognized option: C:\java\classes. 
Error: Must specify the input JAR/EAR filename, the working directory, and output JAR/EAR filename. 
0 Errors, 0 Warnings, 0 Informational Messages

It's like I am malformatting my parameters.  Any ideas ? 

A:

When passing arguments with the exec-maven-plugin, you need to make sure that each <argument> don't contain unescaped space characters.  Each argument must be given as a separate <argument>. 
In your case, -rmic "-d C:\java\classes" is actually formed of 2 arguments: the first one is -rmic and the second one is "-d C:\java\classes" (which contains an escaped space), so you can't pass them into a single <argument>. 
As such, you can have the following configuration:
<arguments>
  <argument>${project.build.directory}\${project.build.finalName}.jar</argument>
  <argument>${project.build.directory}\working</argument>
  <argument>${project.build.directory}\${project.build.finalName}-deployed.jar</argument>
  <argument>-rmic</argument>
  <argument>"-d C:\java\classes"</argument>
  <argument>-cp</argument>
  <classpath />
</arguments>

When configured with those arguments, the main method of the launched executable will take -rmic as the 3rd element in the argument array, and -d C:\java\classes as the 4th element in the argument array.