Maven - JRE (Including it in your distribution)

Card Puncher Data Processing

About

A JRE is just a dependency

Therefore you can upload it to a repository and use it in your build.

Steps

Define the unique identifier

With a file named jre-1.7.80-windows-x64.zip, we will get the following artifact coordinates:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>jre</artifactId>
    <version>1.7.80</version>
    <type>zip</type>
    <classifier>windows-x64</classifier>
  </dependency>

Deploy

Get the JRE from the Oracle website and repackage it to get:

  • a zip file named jre-1.7.80-windows-x64.zip
  • with only one sub directory named jre.

With the deploy-file goal, you can deploy it to a remote repository.

Example:

mvn deploy:deploy-file \
           -Durl=scp://host:22/home/gerardni-m2repo \
           -DrepositoryId=m2-repo \
           -Dfile="pathTo/jre-1.7.80-windows-x64.zip" \
           -DgroupId=com.oracle 
           -DartifactId=jre \
           -Dversion=1.7.80 \
           -Dpackaging=zip \
           -Dclassifier=windows-x64

Build (get and unzip)

Add the below plugin dependency configuration to your pom.xml in order to unpack (ie unzip)

<plugin>
	<artifactId>maven-dependency-plugin</artifactId>
	<executions>
	  <execution>
		<id>get-window-x64-jre</id>
		<phase>prepare-package</phase>
		<goals>
		  <goal>unpack</goal>
		</goals>
		<configuration>
		  <outputDirectory>
			${project.build.directory}/jre-windows-x64
		  </outputDirectory>
		  <artifactItems>
			<artifactItem>
			  <groupId>com.oracle</groupId>
			  <artifactId>jre</artifactId>
			  <version>1.7.80</version>
			  <type>zip</type>
			  <classifier>windows-x64</classifier>
			</artifactItem>
		  </artifactItems>
		</configuration>
	  </execution>
	</executions>
</plugin>

Add the JRE to the zip

With the assmbly plugin, add the following fileset in your descriptor file:

<fileSet>
	<directory>${project.build.directory}/jre-windows-x64/jre</directory>
	<outputDirectory>/jre</outputDirectory>
	<includes>
		<include>**/*</include>
	</includes>
</fileSet>

Documentation / Reference







Share this page:
Follow us:
Task Runner