[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Using Maven to build Debian packages

I've been thinking about how we could use Maven within Debian package
builds. Whichever way we go, I guess we'll need to package a lot of
Maven's run-time dependencies - Plexus components, Maven plugins etc.
(I've attached a list of what gets downloaded when running Maven against a
simple "Hello World" project).

As a way to start discussion, here's how I would expect it to work. Any
comments or corrections would be very welcome.

A new package, maven-deb-helper, will provide a number of tools to assist
with the common tasks involved in building packages using Maven. The tools
will generally be written in Java. The package will provide CDBS files (in
/usr/share/cdbs) so that packages using Maven can be built as easily as
packages using Ant.

Building a Debian package using Maven

  * Each build of a Debian package will use its own temporary, private
local repository (e.g. ./debian/.m2/repository)

  * To keep things simple (for the first release at least), a
configuration file for each package will define which Jars (and POMs)
should be loaded into the local repository.
    - It will be necessary to specify the maven artifact-id, version etc.
    - Loading a Jar into the local repository could be done using the
"install:file" target, or it might be easier to write our own utility.
    - If the package requires a newer version of a dependency (compared to
the one provided by debian), then an error should be raised.
    - If a package requires an older version of a dependency then we will
silently substitute the newer version (i.e. there is an implicit
assumption that libraries are backwards-compatible). This is no worse
than non-Maven packaging.
    - It would be better if we could remove the need for the configuration
file (e.g. by recursively parsing the POMs). Maybe in a later

  * maven-deb-helper can then create a settings.xml file in the build
    - The settings.xml file should enable the "offline" and
"non-interactive" flags, and specify the local repository location.
    - It might be useful to write our own super-pom.

  * The Maven "package" target could then be invoked, passing the location
of the settings.xml file (-s argument), and the resulting jar extracted
from the target directory.

Any comments?
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.2/maven-resources-plugin-2.2.jar
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.0.2/maven-compiler-plugin-2.0.2.jar
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.4.2/maven-surefire-plugin-2.4.2.jar
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.2/maven-jar-plugin-2.2.jar
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler-manager/1.5.3/plexus-compiler-manager-1.5.3.jar
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler-api/1.5.3/plexus-compiler-api-1.5.3.jar
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-compiler-javac/1.5.3/plexus-compiler-javac-1.5.3.jar
Downloading: http://repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.4.9/plexus-utils-1.4.9.jar
Downloading: http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-booter/2.4.2/surefire-booter-2.4.2.jar
Downloading: http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-api/2.4.2/surefire-api-2.4.2.jar
Downloading: http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-junit/2.4.2/surefire-junit-2.4.2.jar
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-io/1.0-alpha-1/plexus-io-1.0-alpha-1.jar
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-archiver/2.3/maven-archiver-2.3.jar
Downloading: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-archiver/1.0-alpha-9/plexus-archiver-1.0-alpha-9.jar
Downloading: http://repo1.maven.org/maven2/commons-lang/commons-lang/2.1/commons-lang-2.1.jar

Reply to: