Translation(s): English - Español
In addition to the normal debhelper packaging tools there are some additional tools specifically for dealing with Java packages.
javahelper for packages without sane build systems or in combination with build systems to modify and make them Debian compliant,
maven-repo-helper for adding Maven artifacts to a non-Maven package,
maven-debian-helper as the primary helper tool for any Maven project and
gradle-debian-helper for Gradle-based projects.
This page will inform you about common Java packaging workflows in Debian and point you to real-life examples which can be used as a starting point for your own packages.
Contributing to Java packaging
We welcome any help with packaging new applications or libraries and keeping existing ones and their reverse-dependencies up-to-date. These days the easiest way to submit a contribution is via a pull request on https://salsa.debian.org/java-team. Just
- make your changes,
- document everything in debian/changelog,
- set it to UNRELEASED,
- test that reverse-dependencies continue to work and then
- make a pull request.
Alternatively you can follow the instructions from mentors.debian.net.
which is useful if you also want to learn the general process of uploading a package to Debian. The only change is that you don't have to ask for sponsorship on the mentors mailing list, just use email@example.com for that.
Java packages in Debian abide like all other packages by the Debian Policy. Java-specific Policy elements are documented in the Debian policy for Java.
Javahelper is Debian's helper tool to perform Java packaging tasks like
- installing jar files into the canonical /usr/share/java directory,
- building packages from source without a sane build system,
- manipulating MANIFEST files or
- setting the CLASSPATH.
It can also help with avoiding patches by creating automatic symlinks to system libraries.
Javahelper is documented in the javahelper package in /usr/share/doc/javahelper/tutorial.txt.gz, also replicated here.
In addition to the tutorial, a talk was given at DebConf10 covering the use of javahelper. The talk is available as:
The idea behind javahelper is that most Java packages should be trivial. The integration with debhelper and the dh sequencer means that you shouldn't need anything in debian/rules, just a few files under the debian directory.
Using javahelper and DH7 ideally your rules file will look like this:
export JAVA_HOME=/usr/lib/jvm/default-java %: dh $@ --with javahelper
All of the work is done by javahelper working from other files under debian/.
Java compilation 101
This section explains the basic terms and methods to compile Java source files into bytecode and the creation of jar files.
When a project has no build system
There are some upstream projects that don't provide a proper build system. In some cases it is useful to download source packages from Maven Central which will come without a build system, just source code. For all those reasons Javahelper is the perfect tool to compile the code and create a proper Debian package. NoBuildSystem examples
There are a few build systems in use by Java programs.
If your package uses Ant then debhelper and dh sequencer should automatically detect the build.xml and call things appropriately. Ant examples
Use maven-debian-helper for standard Maven projects, use maven-repo-helper in combination with other build systems to provide Maven artifacts and maven-ant-helper to fallback the build to Ant - usefull mostly for building a library which is part of the Build-Depends of Maven itself. Maven examples
Use gradle-debian-helper. A Gradle project often requires a patch to the build scripts anyway because the build logic varies from project to project. The gradle-debian-helper is currently in an early stage and mostly helps with the substitution of Maven coordinates, so that Gradle will use Debian's local /usr/share/maven-repo instead of downloading build-dependencies from the internet. See also Gradle examples
For autopkgtest is HELP and or information needed ...
Above is bad example, which discussed by:
Frequently asked questions and solutions
The Java Packaging FAQ gives answers to common Java packaging questions, explains some common error messages and provides solutions to fix them.