wiki:java-packaging

Java Packaging

There a multiples way to package Java apps on Ubuntu.

  1. Fastest way is to get the jar/war file and make a package containing them. Your debian/rules will simply extract it at the right place.
  1. It ends up making a package similar to the first way, but using tools like jdeb to make it automatically for you.

jdeb(https://github.com/tcurdt/jdeb) is a plugin for maven/ant that automatically creates a package from your Java app if it's using Maven or Ant to build.

  1. There are also tools to help creating a package built from source https://wiki.debian.org/Java/Packaging.

It works out of the box for ants and manually building the app

  1. For maven projects, Maven-Debian-Helper(https://wiki.debian.org/Java/MavenDebianHelper) makes it really easy to package an app if all the depencies are available.

Maven Debian Helper

For maven debian helper to work, your java apps need to build using maven. If the project you want to package doesn't have many dependencies, it's pretty easy to create a pom.xml file to make it maven compatible.

Maven-Debian-Helper will use all the information found in the pom.xml file to create all the required files for the package. It will also look for any dependencies needed in the Ubuntu repository. Since it creates a standard Debian Package, it needs to be built from source. So all the dependencies must be available in a repository. The dependencies must also be packaging with a pom.xml file in the /usr/share/maven-repo as it is used as a offline repository by maven-debian-helper.

If the dependencies is packaged but it's not the right version, you can create rules to modify the pom.xml file to use a different version when building.

The most complicated things about this approach is converting the project to maven, if it has many dependencies this can take a while. Off course, you can use IDE like Eclipse or IntelliJ Idea to help you make the conversion. Once it is maven compatible, Maven-Debian-Helper is pretty straight forward.

You can find a simple example of a package made using Maven-Debian-Helper here: https://scm.lan.mapgears.com/packages/debian/jsr-275

Last modified 3 years ago Last modified on Aug 20, 2014 7:24:44 AM