3

私の目標は、Maven を介して Java アプリケーションと一緒にスタンドアロン JRE を自動的にパッケージ化することです。

これを実現するために、JDKを使用exec-maven-pluginします。javapackager私のPOM設定は次のようになります。

 <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>exec-maven-plugin</artifactId>
   <version>1.5.0</version>
   <executions>
     <execution>
       <id>package-jar2</id>
       <phase>package</phase>
       <goals>
         <goal>exec</goal>
       </goals>
       <configuration>
         <executable>
           ${env.JAVA_HOME}/bin/javapackager
         </executable>

         <arguments>
           <argument>-deploy</argument>
           <argument>-native</argument>
           <argument>exe</argument>
           <argument>-appclass</argument>
           <argument>${app.main.class}</argument>
           <argument>-srcdir</argument>
           <argument>${project.build.directory}</argument>
           <argument>-srcfiles</argument>
           <argument>${project.build.directory}\${artifactId}-${version}.jar</argument>
           <argument>-outdir</argument>
           <argument>${project.build.directory}</argument>
           <argument>-outfile</argument>
           <argument>${project.artifactId}-${version}</argument>
           <argument>-v</argument>
         </arguments>
       </configuration>
     </execution>
    </executions>
 </plugin>

最後に、javapackager次のエラーが発生します。

[INFO] --- exec-maven-plugin:1.5.0:exec (package-jar2) @ cli-api ---
Error: Unknown argument: D:\Archiv\Dokumente\Entwicklung\PEProjekt\repository\core\cli-api\target
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: -1 (Exit value: -1)

Unknown argumentが私の-srcdirパラメータのようです。

私は何を間違っていますか?ネイティブ JRE をターゲット ディレクトリにパッケージ化したいと考えています。

4

1 に答える 1

0

ベース jre をバンドルに追加する場合は、ths を使用します

<argument>-Bruntime</argument>
<argument>${env.JAVA_HOME}</argument>

-srcdirはすべての依存ファイルのディレクトリであるため、1 を除外し-srcdirて使用するだけです。-srcfiles

したくない場合は、末尾に path.separator を追加します

于 2016-11-15T19:12:35.690 に答える