JVM as Maven Dependency

103 views Asked by At

Is it possible to have a JVM as a Maven Dependency in a project?

I ask because I've got a project that outputs a Maven Assembly that consists of a Vagrant project, which currently downloads and installs Java when the Vagrant VM starts up. This Vagrant assembly project is uses purely by testing so that they can run up the Vagrant VMs and get the service running quickly, instead of needing to worry about getting everything working correctly every time on their test systems. The downloading of the JVM is currently 90% of the startup time for the VM, so if I can just bundle that in with the assembly then it makes it a lot quicker.

I only need a specific JVM - Java 7 on 32 bit Linux - but I can't work out if there's any standard way to do this. I could just build my own artifact and do it that way, but it seems like this must be something that someone else has already done.

1

There are 1 answers

0
K Erlandsson On

The most efficient way to solve this would be to make a Vagrant box with the specific version of Java you need already installed. That way you can skip the installation process entirely.

If you really want to do it the way you describe, if you use a repository manager such as Nexus or Artifactory, you could upload the Java installation file to the reposity manager with a made up group ID, artifact ID and version. Then you can add a dependency like this (if you upload a rpm - change type to tar.gz otherwise).

<dependency>
    <groupId>my.group.id</groupId>
    <artifactId>jdk-install</artifactId>
    <version>versionEnteredDuringUpload</version>
    <type>rpm</type>
</dependency>

If you do not have access to a repository manager where you can upload the installation I have no other idea than to do as you write, and create your own project and make sure it is installed in your local repository before building the assembly.