【问题标题】:Trying to execute jar in maven plugin尝试在 Maven 插件中执行 jar
【发布时间】:2020-12-20 14:42:45
【问题描述】:

我正在使用 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)

【问题讨论】:

    标签: java maven executable-jar


    【解决方案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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-08
      相关资源
      最近更新 更多