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:

apt-get install maven


Status

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.

Features

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

Support for dh has been implemented in the Debian::Debhelper::Buildsystem::maven Perl module. The build system is automatically detected by dh.

At https://salsa.debian.org/java-team/plexus-cdc 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/debhelper.mk
include /usr/share/cdbs/1/class/maven.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk

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

get-orig-source:
        sh -e debian/orig-tar.sh

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/maven.properties 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

maven-debian-plugin

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.

Plans

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)


CategoryJava