Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exec-maven-plugin difference between arguments and commandlineArgs

I'm trying to use exec-maven-plugin with the java goal. However, I am confused by the difference between the two options:

  • arguments
  • commandlineArgs

If I try using arguments, the call to my java class fails.

The signature of my class being called is:

 public static void main(String[] args)
  {
    VeracodeParser parser = new VeracodeParser();
    parser.parse(args);
  }

My pom:

        <plugin>
            <artifactId>exec-maven-plugin</artifactId>
            <groupId>org.codehaus.mojo</groupId>
            <executions>
                <execution>
                    <id>Zip packaging and deployment</id>
                    <phase>process-sources</phase>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <mainClass>com.veracode.apiwrapper.cli.VeracodeCommand</mainClass>
                        <arguments>
                            <argument>-action GetAppList</argument>
                            <argument>-vuser ${veracode.username}</argument>
                            <argument>-vpassword ${veracode.password}</argument>
                        </arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>

However, I get error messages from my VeracodeCommand class indicating that I am missing my -action, -vuser and -vpassword arguments.

However, when I switch it to using a single string commandlineArgs parameter, it works as expected:

        <plugin>
            <artifactId>exec-maven-plugin</artifactId>
            <groupId>org.codehaus.mojo</groupId>
            <executions>
                <execution>
                    <id>Zip packaging and deployment</id>
                    <phase>process-sources</phase>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <mainClass>com.veracode.apiwrapper.cli.VeracodeCommand</mainClass>
                        <commandlineArgs>-action UploadFile -vuser ${veracode.username} -vpassword ${veracode.password} -appid ${veracode.appId} -filepath ${project.build.directory}/dependency/sbip_ear_pres.ear</commandlineArgs>
                    </configuration>
                </execution>
            </executions>
        </plugin>

The problem is that <commandlineArgs> will become unwieldy long. Which is why I would have preferred using the <arguments> parameter.

Can anyone explain to me the difference between the two and/or if/how I can use the arguments parameter?

like image 936
Eric B. Avatar asked Jun 29 '15 18:06

Eric B.


1 Answers

Maybe you have to provide your arguments in that way, individually? according to the post in Maven - pass argument to use in exec-maven-plugin

    <arguments>
        <argument>-action</argument>
        <argument>GetAppList</argument>
        <argument>-vuser</argument>
        <argument>${veracode.username}</argument>
        <argument>-vpassword</argument>
        <argument>${veracode.password}</argument>
    </arguments>
like image 175
user140547 Avatar answered Oct 11 '22 19:10

user140547