3

My goal is to to package a standalone JRE alongside with my Java application via Maven, automatically.

In order to achieve this, I use exec-maven-plugin and javapackager from JDK. My POM setting looks like this:

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

Finally, the javapackager emits following error:

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

The Unknown argument seems to be my -srcdir parameter.

What am I doing wrong? I'd like to package my native JRE in target directory.

PAX
  • 1,056
  • 15
  • 33

1 Answers1

0

if you want to add the base jre to your bundle use ths

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

-srcdir is the directory of all your dependent files, so i you just need 1 exclude the -srcdir and use -srcfiles

if you dont want to, add a path.separator to the end of it

Elltz
  • 10,730
  • 4
  • 31
  • 59