Essayer d'exécuter jar dans le plugin Maven

Sep 01 2020

J'utilise org.codehaus.mojo exec-maven-plugin pour exécuter un fichier exécutable .jar via mes projets pom.xml. Actuellement, cela ne fonctionne pas, et je ne sais pas pourquoi. L'erreur se produit lorsque je spécifie commandlineArgs.

Mon plugin ressemble à ceci:

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

J'ai précédemment obtenu la même fonctionnalité pour fonctionner en utilisant antrun.

Unrecognized option: -action

Erreur: impossible de créer la machine virtuelle Java. Erreur: une exception fatale s'est produite. Le programme se terminera. [ERROR] L'exécution de la commande a échoué. org.apache.commons.exec.ExecuteException: Processus terminé avec une erreur: 1 (valeur de sortie: 1)

Réponses

jacobhm98 Sep 02 2020 at 16:17

J'ai mal utilisé commandlineArgs! J'étais en fait censé utiliser pour les options spécifiées. Je l'ai résolu en faisant comme tel:

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