Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing argument -p to java application #334

Open
javaguru-ch opened this issue Aug 25, 2022 · 1 comment
Open

Passing argument -p to java application #334

javaguru-ch opened this issue Aug 25, 2022 · 1 comment
Labels

Comments

@javaguru-ch
Copy link

javaguru-ch commented Aug 25, 2022

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]
...
@pzygielo
Copy link
Contributor

pzygielo commented Aug 27, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants