2016-09-20 64 views
1

我的目標是自動將獨立JRE與我的Java應用程序一起通過Maven封裝。適用於Java應用程序的JRE包裝

爲了達到這個目的,我使用了JDK的exec-maven-pluginjavapackager。我的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打包到目標目錄中。

回答

0

,如果你想在底座JRE添加到您的捆綁使用的部份

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

-srcdir是你的所有相關文件的目錄,所以我只需1排除-srcdir和使用-srcfiles

如果你不想要,添加一個path.separator到它的末尾