0

I wrote a simple cli program to get input from the CLI when invoking. I was able to do this by adding the exec plugin in the pom.xml

          <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.1.1</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.mavericks.App</mainClass>
                            <arguments>
                                <argument>names.txt</argument>
                                <argument>expense.txt</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

But when I try to invoke the same thing via cli

mvn exec:java -Dexec.mainClass=“com.mavericks.App” -Dexec.args=“'names.txt' 'expense.txt'”

Unknown lifecycle phase "expense.txt”". You must specify a valid lifecycle phase or a goal. Help would be much appreciated.

Nirojan Selvanathan
  • 10,066
  • 5
  • 61
  • 82
  • 1
    See https://stackoverflow.com/questions/1335291/string-arrays-as-command-line-arguments-for-maven-plugin . Did you try comma separated arguments? – spinlok Mar 04 '18 at 04:22

1 Answers1

2

As per slinlok's comment it worked with these above modification,

mvn exec:java -Dexec.mainClass=com.mavericks.App -Dexec.args="names.txt expense.txt"

thanks.

Nirojan Selvanathan
  • 10,066
  • 5
  • 61
  • 82