尝试在Maven插件中执行jar

问题描述

我正在使用org.codehaus.mojo exec-maven-plugin通过我的项目pom.xml执行一个可执行的.jar文件。目前,这行不通,我不确定为什么。当我指定commandlineArgs时发生错误。

我的插件如下:

            <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>

我以前使用antrun获得了相同的功能。

Unrecognized option: -action

错误:无法创建Java虚拟机。 错误:发生致命异常。程序将会退出。 [错误]命令执行失败。 org.apache.commons.exec.ExecuteException:进程退出,错误为1(退出值:1)

解决方法

我滥用了命令行参数!我实际上应该用于指定的选项。我是这样解决的:

 <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>

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...