mojohaus / mojohaus/exec-maven-plugin

Passing argument -p to java application

Open
#334 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
191
Forks
111
Avg merge
1d 21h
Merged PRs (30d)
4

Description

When trying to use the exec goal in order to run a java application the argument -p is not passed to the java application as an argument.
I attached a minimal maven project to reproduce the issue: ExecMavenIssueTest.zip

Java application for testing:

package test.it.out;

import java.util.Arrays;

public class MainApp {
    public static void main(String... args) {
        System.out.println("Arguments: " + Arrays.toString(args));
    }
}

exec-maven-plugin configuration:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <!-- This only works with 3.0.0 but not with 3.1.0! -->
        <execution>
            <id>execution-no-quotes</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>java</executable>
                <arguments>
                    <argument>-classpath</argument>
                    <classpath/>
                    <argument>test.it.out.MainApp</argument>
                    <argument>-p</argument>
                    <argument>-q</argument>
                    <argument>-r</argument>
                </arguments>
                <classpathScope>runtime</classpathScope>
            </configuration>
        </execution>
        <!-- When quoting the "-p" argument, it works with 3.1.0 too! -->
        <execution>
            <id>execution-with-quotes</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>java</executable>
                <arguments>
                    <argument>-classpath</argument>
                    <classpath/>
                    <argument>test.it.out.MainApp</argument>
                    <argument>"-p"</argument>
                    <argument>-q</argument>
                    <argument>-r</argument>
                </arguments>
                <classpathScope>runtime</classpathScope>
            </configuration>
        </execution>
    </executions>
</plugin>

Output for 3.1.0:

...
[INFO] 
[INFO] --- exec-maven-plugin:3.1.0:exec (execution-no-quotes) @ runner ---
Arguments: [-p, -r]
[INFO] 
[INFO] --- exec-maven-plugin:3.1.0:exec (execution-with-quotes) @ runner ---
Arguments: [-p, -q, -r]
...

Output for 3.0.0:

...
[INFO] 
[INFO] --- exec-maven-plugin:3.0.0:exec (execution-no-quotes) @ runner ---
Arguments: [-p, -q, -r]
[INFO] 
[INFO] --- exec-maven-plugin:3.0.0:exec (execution-with-quotes) @ runner ---
Arguments: [-p, -q, -r]
...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached minimal Maven project and the exec goal configuration, comparing 3.1.0's argument handling with 3.0.0. Reproduce the no-quotes case and verify that the Java application receives -p, -q, and -r in order while the quoted case remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.