Maven 2.x Exec Plugin

The class path string generated using the <classpath> argument is being placed at the end of the generated command string.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.1.1
  • Fix Version/s: None
  • Component/s: exec
  • Labels:
    None
  • Environment:
    Fedora release 11 (Leonidas),
  • Number of attachments :
    0

Description

When trying to run a java executable the class path string generated using the <classpath> argument is being placed at the end of the generated command string unless it is the very first argument in which case it is places directly after the "java" command.

For example:

<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>com.example.Main</argument>
<arguments>
</arguments>

Produces:
java -classpath com.example.Main {the classpath dependencies here}

Activity

Hide
Nick Foote added a comment -

This appears to be because elements in the <arguments> list with the same name are concatenated.

For example:

<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>com.example.Main</argument>
<arguments>

is essentially the same as:

<arguments>
<argument>-classpath com.example.Main</argument>
<classpath/>
<arguments>

I'm not sure if this is intended functionality but since it breaks the example on the Exec website I'd assume not. I'm new to Maven but this concatenation does not appear to be coming from the ExecMojo code and I'd guess has something to do with the way the pom elements are being parsed before being passed into the ExecMojo object.
A workaround appears to utilise the fact that elements in the <arguments> list currently DO NOT have to be named <argument>.

For example:

<arguments>
<classpathArg>-classpath</classpathArg>
<classpath/>
<mainClassArg>com.example.Main</mainClassArg>
<progArg1>113</progArg1>
<arguments>

Produces:
java -classpath {the classpath dependencies here} com.example.Main 113

Show
Nick Foote added a comment - This appears to be because elements in the <arguments> list with the same name are concatenated. For example: <arguments> <argument>-classpath</argument> <classpath/> <argument>com.example.Main</argument> <arguments> is essentially the same as: <arguments> <argument>-classpath com.example.Main</argument> <classpath/> <arguments> I'm not sure if this is intended functionality but since it breaks the example on the Exec website I'd assume not. I'm new to Maven but this concatenation does not appear to be coming from the ExecMojo code and I'd guess has something to do with the way the pom elements are being parsed before being passed into the ExecMojo object. A workaround appears to utilise the fact that elements in the <arguments> list currently DO NOT have to be named <argument>. For example: <arguments> <classpathArg>-classpath</classpathArg> <classpath/> <mainClassArg>com.example.Main</mainClassArg> <progArg1>113</progArg1> <arguments> Produces: java -classpath {the classpath dependencies here} com.example.Main 113
Hide
Robert Scholte added a comment -

Added an integration-test, can't reproduce the issue: rev. 14710

Show
Robert Scholte added a comment - Added an integration-test, can't reproduce the issue: rev. 14710

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: