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!):


Status

I am preparing a [wiki:Java/MavenRepoSpec Repository Specification] for further discussion.

At http://svn.debian.org/wsvn/pkg-java/trunk/plexus-cdc/ you can find a package (plexus-cdc) that uses maven-debian-helper for building. Maven-debian-helper has not been uploaded yet but preliminary packages are available at [http://people.debian.org/~twerner/]. I [TorstenWerner] have built maven-plugin-plugin, maven-clean-plugin, maven-resource-plugin, maven-compiler-plugin, maven-jar-plugin, maven-site-plugin, and surefire. That is enought to build Debian packages and I will continue to package other important maven-core-plugins. My packages are using the path /usr/share/maven-repo as the local repository.

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.

How Many Jars?!!??

As an indication of how many jars we need to package before we can think about using Maven in Debian builds, I ran a mvn install for Jetty-6. It downloaded 58 jars.

Some of these jars we have already packaged, and some are specific to Jetty, but it still looks like a big list:

Questions

Offline Mode + Repository

When building a Debian package I expect we'll be running Maven with the offline flag, so I believe we'll have to set up the temporary repository in the local cache, e.g. debian/.m2/repository (and provide a <localRepository> setting). Or is there a better way?

We should probably use a repo like /usr/share/maven/repository/ -- TorstenWerner

Versions

The POMs will refer to an explicit version of a dependency, e.g. junit-3.8.1, and its unlikely we'd have exactly the right version in /usr/share/java (the Maven build of jetty, for instance, downloaded two different versions of junit). I guess we will have to "fake" it and pretend our jar is the correct version.

E.g. the POM could require JUnit-3.8.1 but Debian has packaged version 3.8.2. In this case we would set up a link in the temporary Maven repository:

We should check that the Debian version is not *older* than the version required by the POM, but we are still relying on releases being backwards compatible. Any comments?

We can just patch the pom.xml file to depend on a range like [3.8, 4) (for junit3). -- TorstenWerner

Mapping Maven Artifacts to Our Jar Names

Any ideas how we'd generate the list of jars to copy into our temporary repository? I think most of the time a simple naming convention is good enough (e.g. artifact junit maps onto /usr/share/java/junit.jar). But I think we also need to allow the packager to override the default - for example if Debian has packaged two ABI-incompatible versions of a jar, or used non-standard jar names.

I guess that *indirect* dependencies wouldn't be set up in the temporary maven repository - we'd just add them to the classpath as we do for ant builds. Would this work? I can't see an alternative here, as we wouldn't have the dependencies' POMs.

The java packages (like junit) can just provide the pom.xml files and symlinks to their jar files. -- TorstenWerner

The "No-Dependencies" Alternative

Alternatively we could add *all* required jars to the classpath (same as we do now for ant builds), and remove all dependencies from the POM(s). I think that would work, but haven't tested it. Instead of modifying the POM(s) we could write a Maven plugin so that Maven ignores any dependencies - I'm not sure how easy that would be.

Then I believe we would only need to put the plugins (e.g. maven-compiler-plugin) in the temporary repository.

missing packages

The following packages are missing in Debian at least if we want to run the plugin's tests.

httpunit

cobertura

jetty6


CategoryJava