Trying to execute jar in maven plugin

Viewed 114

I am using the org.codehaus.mojo exec-maven-plugin to execute an executable .jar file through my projects pom.xml. Currently this isn't working, and I'm unsure why. The error occurs when I specify commandlineArgs.

My plugin looks like this:

            <plugin>
        <inherited>false</inherited>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
           <param>${VID}</param>
           <param>${VKEY}</param>
           <executable>java</executable>
        </configuration>
           <executions>
              <execution>
                 <id>veracode</id>
                 <configuration>
                    <arguments>
                       <argument>-jar</argument>
                       <argument>${settings.localRepository}/com/veracode/vosp/api/wrappers/vosp-api-wrappers-java/20.7.7.0/vosp-api-wrappers-java-20.7.7.0.jar</argument>
                    </arguments>
                    <classpathScope>run</classpathScope>
                    <includePluginDependencies>true</includePluginDependencies>
                    <commandlineArgs>-action UploadAndScan -vid ${VID} -vkey ${VKEY} -criticality High -createprofile false -createsandbox false -version ${project.artifactId}-${project.version} -appname <appname> -sandboxname <proxy-standard> -filepath proxy-service/target/lib</commandlineArgs>
                 </configuration>
                 <goals>
                    <goal>exec</goal>
                 </goals>
              </execution>
           </executions>
        <dependencies>
           <dependency>
              <groupId>com.veracode.vosp.api.wrappers</groupId>
              <artifactId>vosp-api-wrappers-java</artifactId>
              <version>20.7.7.0</version>
           </dependency>
        </dependencies>
     </plugin>

I have previously gotten the same functionality to work using antrun.

Unrecognized option: -action

Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. [ERROR] Command execution failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)

1 Answers

I misused commandlineArgs! I was actually supposed to use for the options specified. I solved it by doing as such:

 <arguments>
                   <argument>-jar</argument>
                   <argument>${settings.localRepository}/com/veracode/vosp/api/wrappers/vosp-api-wrappers-java/20.7.7.0/vosp-api-wrappers-java-20.7.7.0.jar</argument>
                   <argument>-action</argument>
                   <argument>UploadAndScan</argument>
                   <argument>-vid</argument>
                   <argument>${VID}</argument>
                   <argument>-vkey</argument>
                   <argument>${VKEY}</argument>
                   <argument>-criticality</argument>
                   <argument>High</argument>
                   <argument>-createprofile</argument>
                   <argument>false</argument>
                   <argument>-createprofile</argument>
                   <argument>false</argument>
                   <argument>-version</argument>
                   <argument>${BUILD_NUMBER}</argument>
                   <argument>-appname</argument>
                   <argument>PULSE-DELIVERY</argument>
                   <argument>-sandboxname</argument>
                   <argument>proxy-standard</argument>
                   <argument>-filepath</argument>
                   <argument>proxy-service/target/lib</argument>
                </arguments>
Related