Cercando di eseguire jar nel plugin Maven

Sep 01 2020

Sto usando org.codehaus.mojo exec-maven-plugin per eseguire un file .jar eseguibile attraverso i miei progetti pom.xml. Attualmente questo non funziona e non sono sicuro del perché. L'errore si verifica quando si specifica commandlineArgs.

Il mio plugin si presenta così:

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

In precedenza ho ottenuto la stessa funzionalità per funzionare utilizzando antrun.

Unrecognized option: -action

Errore: impossibile creare la Java Virtual Machine. Errore: si è verificata un'eccezione irreversibile. Il programma uscirà. [ERRORE] Esecuzione del comando non riuscita. org.apache.commons.exec.ExecuteException: processo terminato con un errore: 1 (valore di uscita: 1)

Risposte

jacobhm98 Sep 02 2020 at 16:17

Ho usato in modo improprio commandlineArgs! In realtà avrei dovuto usarlo per le opzioni specificate. Ho risolto facendo così:

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