This is a discussion page for the pkg-java team's plan to use Maven to build Debian packages. If you just want to find out how to install and run Maven in Debian, you are probably looking at the wrong page. Instead run (from Lenny upwards!):


All core components are now in Debian and that means maven-debian-helper can be used to build Debian packages with Maven now.

The Repository Specification needs some minor updates.


TODO: we should support dh in the future, see Joey's Debconf9 talk.

At you can find a package (plexus-cdc) that uses maven-debian-helper for building. With maven-debian-helper the debian/rules can be as short as

include /usr/share/cdbs/1/rules/
include /usr/share/cdbs/1/class/
include /usr/share/cdbs/1/rules/

JAVA_HOME := /usr/lib/jvm/java-6-openjdk

        sh -e debian/

and the Build-Depends are

Build-Depends: debhelper (>= 5), cdbs, openjdk-6-jdk, quilt, maven-debian-helper,
 libslf4j-java, libjdom1-java

Unfortunately we need a small patch for the pom.xml. Additional properties can be specified in the file debian/ which is read automatically if it exists.

Helper script

There is a script mvn-debian that allows using Maven offline without cdbs. Please use it only on your local system but never for building real Debian packages. It is used in the same way as maven itself:

$ mvn-debian clean package


This plugin provides some useful goals:

$ mvn-debian debian:install -Ddebian.dir=$PWD/debian -Ddebian.package=libfoo-java

This goal is automatically called by the cdbs snippet.

$ sudo mvn-debian debian:sysinstall
$ sudo mvn-debian debian:sysuninstall

installs or uninstalls a freshly built package into /usr/share/maven-repo/... without building a Debian package. It is not recommended to use those goals but they can be useful on occasion.

$ mvn-debian debian:resolve-none
$ mvn-debian debian:resolve-compile
$ mvn-debian debian:resolve-runtime
$ mvn-debian debian:resolve-test

The first goal reads your pom.xml file or all pom.xml files in a multimodule project and the parent poms and validates them. The other three goal resolve the compile, runtime, and test dependencies without building the package.

To test, or not to test

Tests are automatically built and run. The property

maven.test.failure.ignore = true

ignores the results of running the tests. The property

maven.test.skip = true

skips building and running the tests entirely which can be useful if some test dependencies are not packaged yet.


See also

maven-repo-helper: This package provides helper scripts to include in existing packages the Maven POM and the jar in the Maven repository for Debian (/usr/share/maven-repo)