[pkg-java] r9344 - in trunk/maven-debian-helper: . bin debian etc maven-debian-helper maven-debian-helper/src/main maven-debian-helper/src/main/java/org/debian/maven maven-debian-plugin maven-debian-plugin/src/main/java/org/debian/maven/plugin maven-packager-utils maven-packager-utils/src maven-packager-utils/src/main maven-packager-utils/src/main/java maven-packager-utils/src/main/java/org maven-packager-utils/src/main/java/org/debian maven-packager-utils/src/main/java/org/debian/maven maven-packager-utils/src/main/java/org/debian/maven/packager maven-packager-utils/src/main/resources maven-packager-utils/src/test maven-packager-utils/src/test/java maven-packager-utils/src/test/java/org maven-packager-utils/src/test/java/org/debian maven-packager-utils/src/test/java/org/debian/maven maven-packager-utils/src/test/java/org/debian/maven/packager maven-packager-utils/src/test/resources share share/cdbs/1/class share/maven-debian-helper
Ludovic Claude
ludovicc-guest at alioth.debian.org
Tue Jul 14 21:01:22 UTC 2009
Author: ludovicc-guest
Date: 2009-07-14 21:01:22 +0000 (Tue, 14 Jul 2009)
New Revision: 9344
Added:
trunk/maven-debian-helper/bin/mh_genrules
trunk/maven-debian-helper/bin/mh_lspoms
trunk/maven-debian-helper/bin/mh_make
trunk/maven-debian-helper/bin/mh_resolve_dependencies
trunk/maven-debian-helper/debian/build.properties
trunk/maven-debian-helper/debian/build.xml
trunk/maven-debian-helper/debian/maven-debian-helper.poms
trunk/maven-debian-helper/debian/maven-settings.xml
trunk/maven-debian-helper/debian/maven.rules
trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallDocMojo.java
trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java
trunk/maven-debian-helper/maven-packager-utils/
trunk/maven-debian-helper/maven-packager-utils/pom.xml
trunk/maven-debian-helper/maven-packager-utils/src/
trunk/maven-debian-helper/maven-packager-utils/src/main/
trunk/maven-debian-helper/maven-packager-utils/src/main/java/
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesMojo.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/README.source.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/build.properties.ant.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/compat.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/java-doc.doc-base.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/java-doc.docs.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.properties.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/orig-tar.svn.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.ant.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/version.vm
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/watch.svn.vm
trunk/maven-debian-helper/maven-packager-utils/src/test/
trunk/maven-debian-helper/maven-packager-utils/src/test/java/
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java
trunk/maven-debian-helper/maven-packager-utils/src/test/resources/
trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.poms
trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.rules
trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.substvars
trunk/maven-debian-helper/maven-packager-utils/src/test/resources/plexus-active-collections.pom
Removed:
trunk/maven-debian-helper/maven-debian-helper/src/main/resources/
trunk/maven-debian-helper/share/maven-repo/
Modified:
trunk/maven-debian-helper/debian/changelog
trunk/maven-debian-helper/debian/compat
trunk/maven-debian-helper/debian/control
trunk/maven-debian-helper/debian/copyright
trunk/maven-debian-helper/debian/rules
trunk/maven-debian-helper/etc/fake-poms.conf
trunk/maven-debian-helper/maven-debian-helper/pom.xml
trunk/maven-debian-helper/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java
trunk/maven-debian-helper/maven-debian-plugin/pom.xml
trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java
trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysUninstallMojo.java
trunk/maven-debian-helper/pom.xml
trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk
trunk/maven-debian-helper/share/cdbs/1/class/maven.mk
trunk/maven-debian-helper/share/maven-debian-helper/copy-repo.sh
Log:
* Use maven-ant-helper for the build instead of recursively building
this package with itself (which required an ugly bootstrap script)
* Integrate the cdbs helper with maven-repo-helper, this unifies the
way the Maven repository is used, and simplifies the job of the
packager as maven-repo-helper takes care of most POM patching work.
* Use default-jdk for the build
* Change section to java, update Standards-Version to 3.8.1
Added: trunk/maven-debian-helper/bin/mh_genrules
===================================================================
--- trunk/maven-debian-helper/bin/mh_genrules (rev 0)
+++ trunk/maven-debian-helper/bin/mh_genrules 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,87 @@
+#!/bin/bash --
+
+. /usr/share/maven-repo-helper/mh_lib.sh
+
+syntax()
+{
+ echo -e "Usage: mh_genrules [option]... <package>"
+ echo -e "Generate the rules file, at least partially."
+ echo -e ""
+ echo -e "Where"
+ echo -e "\t<package> is the name of the binary package,"
+ echo -e "\t e.g. libcommons-lang-java. Default to the first binary"
+ echo -e "\t found in the debian/control file"
+ echo -e "Options:"
+ echo -e "\t-h --help: show this text"
+ echo -e "\t-V --version: show the version"
+ echo -e "\t-a --use-ant: add code to use Ant to build the sources"
+ exit 1
+}
+
+ARGS="a use-ant" parseargs "$@"
+
+if [ "$ARGC" -gt "0" ]; then
+ PACKAGE="${ARGV[0]}"
+else
+ PACKAGE=$(dh_listpackages | head -1)
+fi
+
+mh_lspoms $PACKAGE > /dev/null
+
+BIN_PACKAGE="\$(PACKAGE)"
+SOURCE=$(dpkg-parsechangelog | egrep '^Source:' | cut -f2 -d' ')
+if [ "lib$SOURCE-java" = "$PACKAGE" ]; then
+ BIN_PACKAGE="lib\$(PACKAGE)-java"
+elif [ "$SOURCE-java" = "$PACKAGE" ]; then
+ BIN_PACKAGE="\$(PACKAGE)-java"
+fi
+
+gen_rules() {
+ echo "#!/usr/bin/make -f"
+ echo ""
+ echo "include /usr/share/cdbs/1/rules/debhelper.mk"
+ if $USE_ANT ; then
+ echo "include /usr/share/cdbs/1/class/ant.mk"
+ fi
+ echo ""
+ echo "PACKAGE := \$(DEB_SOURCE_PACKAGE)"
+ echo "VERSION := \$(DEB_UPSTREAM_VERSION)"
+ echo "JAVA_HOME := /usr/lib/jvm/default-java"
+ if $USE_ANT ; then
+ echo "DEB_JARS := # TODO - fill the list of jars"
+ echo "DEB_ANT_BUILD_TARGET := package"
+ echo "DEB_ANT_BUILDFILE := debian/build.xml"
+ echo "DEB_ANT_ARGS := -Dpackage=\$(PACKAGE) -DartifactId=\$(PACKAGE) -Dversion=\$(VERSION)"
+ fi
+ echo ""
+ echo "binary-post-install/$BIN_PACKAGE::"
+ echo -e "\tmh_installpoms -p$BIN_PACKAGE"
+
+ cat debian/$PACKAGE.poms | while read POM OPTS; do
+ if [[ "$POM" = "pom.xml" || "$POM" = "debian/pom.xml" ]]; then
+ grep "<packaging>\s*pom" $POM > /dev/null
+ if [ $? != 0 ]; then
+ echo -e "\tmh_installjar -p$BIN_PACKAGE -l $POM build/\$(PACKAGE)-\$(VERSION).jar"
+ fi
+ elif [ ! -z "$POM" ]; then
+ BASENAME=$(basename $(dirname $POM))
+ grep "<packaging>\s*pom" $POM > /dev/null
+ if [ $? != 0 ]; then
+ echo -e "\tmh_installjar -p$BIN_PACKAGE -l $POM $BASENAME/build/$BASENAME-\$(VERSION).jar"
+ fi
+ fi
+ done
+ echo ""
+ echo "clean::"
+ echo -e "\t-rm -rf debian/tmp"
+}
+
+if [ -e debian/rules ]; then
+ gen_rules > debian/rules.new
+ echo "The new rules have been generated into debian/rules.new."
+ echo "You need to merge them manually into debian/rules"
+else
+ mkdir -p debian
+ gen_rules > debian/rules
+ echo "The new rules have been generated into debian/rules."
+fi
Added: trunk/maven-debian-helper/bin/mh_lspoms
===================================================================
--- trunk/maven-debian-helper/bin/mh_lspoms (rev 0)
+++ trunk/maven-debian-helper/bin/mh_lspoms 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,56 @@
+#!/bin/bash --
+
+. /usr/share/maven-repo-helper/mh_lib.sh
+
+syntax()
+{
+ echo -e "Usage: mh_lspoms [option]... <package>"
+ echo -e "Looks for all POM files defined in the source of the project."
+ echo -e ""
+ echo -e "Where"
+ echo -e "\t<package> is the name of the binary package,"
+ echo -e "\t e.g. libcommons-lang-java. Default to the first binary"
+ echo -e "\t found in the debian/control file"
+ echo -e "Options:"
+ echo -e "\t-h --help: show this text"
+ echo -e "\t-V --version: show the version"
+ echo -e "\t-p<package> --package=<package>: package to act on "
+ echo -e "\t-f --force: force run even if the .poms files exist."
+ echo -e "\t Only maven.rules will be created, assuming that it"
+ echo -e "\t did not exist before."
+ echo -e ""
+ echo -e "You need to execute it on the unpacked origial source tree, merged with the"
+ echo -e "debian/ folder. It will create the file debian/<binary package>.poms which"
+ echo -e "contains all the POMs to deploy to the Maven repository and is used by"
+ echo -e "mh_installpoms."
+ echo -e ""
+ echo -e "The contents of debian/<binary package>.poms should be:"
+ echo -e "\t* one POM file location per line,"
+ echo -e "\t* optionaly, the location is followed by the option --no-parent"
+ echo -e "\t to indicate that if this POM inherits from a parent, the parent"
+ echo -e "\t element will be removed."
+ exit 1
+}
+
+ARGS="p package f force" parseargs "$@"
+
+PACKAGE=$(getarg p package)
+FORCE=$(getarg f force)
+
+if [ -z "$PACKAGE" ]; then
+ if [ "$ARGC" -gt "0" ]; then
+ PACKAGE="${ARGV[0]}"
+ else
+ PACKAGE=$(dh_listpackages | head -1)
+ fi
+fi
+
+if [ -e debian/$PACKAGE.poms -a -z "$FORCE" ]; then
+ echo "debian/$PACKAGE.poms already exist. Please delete it if you want to regenerate it."
+else
+ mkdir -p debian
+ java -cp /usr/share/java/maven-project.jar:/usr/share/java/maven-repo-helper.jar:/usr/share/java/maven-packager-utils.jar org.debian.maven.packager.DependenciesSolver --package=$PACKAGE --maven-repo=/usr/share/maven-repo
+ rm debian/$PACKAGE.substvars
+ echo "The list of POM files is now in debian/$PACKAGE.poms"
+fi
+
Added: trunk/maven-debian-helper/bin/mh_make
===================================================================
--- trunk/maven-debian-helper/bin/mh_make (rev 0)
+++ trunk/maven-debian-helper/bin/mh_make 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+MH_VERSION=0.4
+. /usr/share/maven-repo-helper/mh_lib.sh
+
+syntax()
+{
+ echo -e "Usage: mh_make [option]..."
+ echo -e "Generate the Debian packaging by reading the information"
+ echo -e "from the Maven POM."
+ echo -e ""
+ echo -e "Options:"
+ echo -e "\t-h --help: show this text"
+ echo -e "\t-V --version: show the version"
+ echo -e "\t-p<package> --package=<package>: name of the source package"
+ echo -e "\t-b<package> --bin-package=<package>: name of the binary package"
+ echo -e "\t-t<true|false> --run-tests=<true|false>: include or not the tests"
+ echo -e "\t-d<true|false> --javadoc=<true|false>: include or not the javadoc"
+ echo -e "\t during the build"
+ echo -e "\t-a --ant: use Ant for the packaging instead of Maven"
+ echo -e "\t-v --verbose: show more information while running"
+ exit 1
+}
+
+ARGS="p package b bin-package t run-tests d javadoc a ant v verbose" parseargs "$@"
+
+if [ -z "$DEBFULLNAME" ]; then
+ echo "Please define the environment variable DEBFULLNAME, e.g."
+ echo "export DEBFULLNAME=\"Ludovic Claude\""
+ return;
+fi
+
+if [ -z "$DEBEMAIL" ]; then
+ echo "Please define the environment variable DEBEMAIL, e.g."
+ echo "export DEBEMAIL=\"ludovic.claude at laposte.net\""
+ return;
+fi
+
+PACKAGE=$(getarg p package)
+BIN_PACKAGE=$(getarg b bin-package)
+RUN_TESTS=$(getarg t run-tests)
+GEN_JAVADOC=$(getarg d javadoc)
+ANT=$(getarg a ant)
+
+if [ -z "$DEBLICENSE" ]; then
+ DEBLICENSE="GPL-3"
+fi
+
+if [ -z "$PACKAGE" ]; then
+ PACKAGE="$(basename $(pwd))"
+ echo "Enter the name of the new Debian source package. If empty, it will defaults to $PACKAGE"
+ read -p ">" USER_PACKAGE
+ if [ -n "$USER_PACKAGE" ]; then
+ PACKAGE=$USER_PACKAGE
+ fi
+fi
+
+if [ -z "$BIN_PACKAGE" ]; then
+ BIN_PACKAGE="lib${PACKAGE}-java"
+ echo "Enter the name of the binary package. If empty, it will defaults to $BIN_PACKAGE"
+ read -p ">" USER_PACKAGE
+ if [ -n "$USER_PACKAGE" ]; then
+ BIN_PACKAGE=$USER_PACKAGE
+ fi
+fi
+
+if [ -z "$RUN_TESTS" ]; then
+ RUN_TESTS="false"
+ echo "Enter y (yes) or n (no) to run tests while building the package. Defaults to no"
+ read -p ">" RUN
+ if [ "$RUN" == "y" ]; then
+ RUN_TESTS="true"
+ fi
+fi
+
+if [ -z "$GEN_JAVADOC" ]; then
+ GEN_JAVADOC="false"
+ echo "Enter y (yes) or n (no) to generate the Javadoc while building the package. Defaults to no"
+ read -p ">" GEN
+ if [ "$GEN" == "y" ]; then
+ GEN_JAVADOC="true"
+ fi
+fi
+
+if [ ! -e debian/${BIN_PACKAGE}.substvars ]; then
+ java -cp /usr/share/java/maven-project.jar:/usr/share/java/maven-repo-helper.jar:/usr/share/java/maven-packager-utils.jar org.debian.maven.packager.DependenciesSolver --package="$BIN_PACKAGE" ${ANT:--ant} --maven-repo=/usr/share/maven-repo
+fi
+
+if [ ! -e .debianVersion ]; then
+ touch .debianVersion
+ mh_patchpoms -p$BIN_PACKAGE --keep-pom-version
+fi
+
+mvn org.debian.maven:maven-packager-utils:$MH_VERSION:generate -Demail="$DEBEMAIL" -Dpackager="$DEBFULLNAME" -DpackagerLicense="$DEBLICENSE" -Dpackage="$PACKAGE" -Dbin.package="$BIN_PACKAGE" -DrunTests="$RUN_TESTS" -DgenerateJavadoc="$GEN_JAVADOC" -Dmaven.repo.local=/usr/share/maven-repo ${ANT:+-DpackageType=ant} --offline
+
+rm -f debian/*.substvars
+
+if [ ! -f debian/changelog ]; then
+ mkdir -p debian/tmp
+ mh_cleanpom -p$PACKAGE pom.xml debian/tmp/pom.xml debian/tmp/pom.properties
+ source debian/tmp/pom.properties
+ rm -R debian/tmp
+ version=$(echo $version | sed -re's/-(alpha|beta)-?/~\1/')
+ dch --create --newversion=${version}-1 --package=$PACKAGE "Initial release (Closes: #XXXXX)"
+fi
+
Added: trunk/maven-debian-helper/bin/mh_resolve_dependencies
===================================================================
--- trunk/maven-debian-helper/bin/mh_resolve_dependencies (rev 0)
+++ trunk/maven-debian-helper/bin/mh_resolve_dependencies 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+MH_VERSION=0.4
+. /usr/share/maven-repo-helper/mh_lib.sh
+
+syntax()
+{
+ echo -e "Usage: mh_revolve_dependencies [option]... <package>"
+ echo -e "Resolve the dependencies and generates the substvars"
+ echo -e "file containing the list of dependent packages."
+ echo -e ""
+ echo -e "Where"
+ echo -e "\t<package> is the name of the binary package,"
+ echo -e "\t e.g. libcommons-lang-java. Default to the first binary"
+ echo -e "\t found in the debian/control file"
+ echo -e "Options:"
+ echo -e "\t-h --help: show this text"
+ echo -e "\t-V --version: show the version"
+ echo -e "\t-p<package> --package=<package>: name of the package"
+ echo -e "\t-a --ant: use Ant for the packaging instead of Maven"
+ echo -e "\t-v --verbose: show more information while running"
+ echo -e ""
+ echo -e "Description:"
+ echo -e "This tool reads the POM files defined in debian/$package.poms"
+ echo -e "and scans the Maven repository in /usr/share/maven-repo."
+ echo -e "It then extracts the dependencies required for the current"
+ echo -e "package and store them in the file debian/$package.substvars"
+ echo -e "where they can be read by debhelper."
+ echo -e "The variables defined are:"
+ echo -e " maven:Depends - the list of runtime dependencies"
+ echo -e " maven:OptionalDepends - the list of optional runtime dependencies"
+ echo -e " maven:CompileDepends - the list of compile-time dependencies"
+ echo -e " maven:TestDepends - the list of test dependencies"
+ exit 1
+}
+
+ARGS="p package a ant v verbose" parseargs "$@"
+
+PACKAGE=$(getarg p package)
+ANT=$(getarg a ant)
+
+if [ -z "$PACKAGE" ]; then
+ if [ "$ARGC" -gt "0" ]; then
+ PACKAGE="${ARGV[0]}"
+ else
+ PACKAGE=$(dh_listpackages | head -1)
+ fi
+fi
+
+if [ ! -e .debianVersion -a ! -e debian/stamp-poms-patched ]; then
+ touch .debianVersion
+ CREATED_POMS=false
+ if [ ! -e debian/${PACKAGE}.poms ]; then
+ CREATED_POMS=true
+ mh_lspoms $PACKAGE
+ fi
+ mh_patchpoms -p$PACKAGE --keep-pom-version
+ if [ $CREATED_POMS ]; then
+ rm debian/${PACKAGE}.poms
+ fi
+fi
+
+mvn org.debian.maven:maven-packager-utils:$MH_VERSION:dependencies -Dpackage="$PACKAGE" ${ANT:+-DpackageType=ant} -Dmaven.repo.local=/usr/share/maven-repo --offline
+
+perl -p -i -e 's/maven\./maven:/' debian/${PACKAGE}.substvars
Added: trunk/maven-debian-helper/debian/build.properties
===================================================================
--- trunk/maven-debian-helper/debian/build.properties (rev 0)
+++ trunk/maven-debian-helper/debian/build.properties 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,4 @@
+build.directory=target
+javadoc.dir=target/api
+maven.test.skip=true
+
Added: trunk/maven-debian-helper/debian/build.xml
===================================================================
--- trunk/maven-debian-helper/debian/build.xml (rev 0)
+++ trunk/maven-debian-helper/debian/build.xml 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+
+<project name="pkg-java" default="package" basedir="..">
+
+ <property file="debian/build.properties"/>
+ <property name="maven.build" value="/usr/share/maven-ant-helper/maven-build.xml"/>
+ <property file="/usr/share/maven-ant-helper/maven-defaults.properties"/>
+
+ <macrodef name="cleanmodule">
+ <attribute name="dir"/>
+ <sequential>
+ <ant target="clean" antfile="${maven.build}" dir="@{dir}">
+ <property name="debian.dir" location="debian" />
+ <property name="project.dir" value="@{dir}" />
+ </ant>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="packagemodule">
+ <attribute name="dir"/>
+ <sequential>
+ <ant target="package" antfile="${maven.build}" dir="@{dir}">
+ <property name="debian.dir" location="debian" />
+ <property name="project.dir" value="@{dir}" />
+ <property name="keep-cleaned-pom" value="true" />
+ </ant>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="package-plugin-module">
+ <attribute name="dir"/>
+ <sequential>
+ <ant target="package" antfile="${maven.build}" dir="@{dir}">
+ <property name="debian.dir" location="debian" />
+ <property name="project.dir" value="@{dir}" />
+ <property name="maven.generate.target" value="plugin:descriptor" />
+ <property name="keep-cleaned-pom" value="true" />
+ <property name="use-local-repo" value="true" />
+ </ant>
+ </sequential>
+ </macrodef>
+
+ <target name="clean">
+ <cleanmodule dir=""/>
+ <cleanmodule dir="maven-debian-helper"/>
+ <cleanmodule dir="maven-debian-plugin"/>
+ <cleanmodule dir="maven-packager-utils"/>
+ </target>
+
+ <target name="package">
+ <packagemodule dir=""/>
+ <packagemodule dir="maven-debian-helper"/>
+ <package-plugin-module dir="maven-debian-plugin"/>
+ <package-plugin-module dir="maven-packager-utils"/>
+ </target>
+
+ <target name="javadoc">
+ <javadoc destdir="${javadoc.dir}">
+ <packageset dir="maven-debian-helper/src/main/java/"/>
+ <packageset dir="maven-debian-plugin/src/main/java/"/>
+ <packageset dir="maven-packager-utils/src/main/java/"/>
+ </javadoc>
+ </target>
+
+</project>
Modified: trunk/maven-debian-helper/debian/changelog
===================================================================
--- trunk/maven-debian-helper/debian/changelog 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/debian/changelog 2009-07-14 21:01:22 UTC (rev 9344)
@@ -1,9 +1,18 @@
-maven-debian-helper (0.4) unstable; urgency=low
+maven-debian-helper (0.4) experimental; urgency=low
- UNRELEASED
+ [Ludovic Claude]
+ * Use maven-ant-helper for the build instead of recursively building
+ this package with itself (which required an ugly bootstrap script)
+ * Integrate the cdbs helper with maven-repo-helper, this unifies the
+ way the Maven repository is used, and simplifies the job of the
+ packager as maven-repo-helper takes care of most POM patching work.
+ * Use default-jdk for the build
+ * Change section to java, update Standards-Version to 3.8.1
+
+ [Torsten Werner]
* Implement pom faking.
- -- Torsten Werner <twerner at debian.org> Thu, 29 Jan 2009 20:23:33 +0100
+ -- Ludovic Claude <ludovic.claude at laposte.net> Tue, 14 Jul 2009 20:17:16 +0100
maven-debian-helper (0.3) unstable; urgency=low
Modified: trunk/maven-debian-helper/debian/compat
===================================================================
--- trunk/maven-debian-helper/debian/compat 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/debian/compat 2009-07-14 21:01:22 UTC (rev 9344)
@@ -1 +1 @@
-5
+6
Modified: trunk/maven-debian-helper/debian/control
===================================================================
--- trunk/maven-debian-helper/debian/control 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/debian/control 2009-07-14 21:01:22 UTC (rev 9344)
@@ -1,22 +1,25 @@
Source: maven-debian-helper
-Section: libs
+Section: java
Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
Uploaders: Torsten Werner <twerner at debian.org>
-Build-Depends: cdbs, debhelper (>= 5), openjdk-6-jdk, libmaven-clean-plugin-java,
- libmaven-resources-plugin-java, libmaven-compiler-plugin-java,
- libmaven-jar-plugin-java, libmaven-site-plugin-java, libsurefire-java
-Standards-Version: 3.8.0
+Build-Depends: cdbs, debhelper (>= 6), default-jdk, maven-ant-helper (>> 4), ant-optional
+Build-Depends-Indep: maven-repo-helper (>> 0.5),
+ junit, testng, libmaven-plugin-tools-java, libplexus-velocity-java, velocity,
+ libmaven2-core-java
+Standards-Version: 3.8.1
Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/maven-debian-helper
Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/maven-debian-helper/
Homepage: http://wiki.debian.org/Java/MavenBuilder
Package: maven-debian-helper
Architecture: all
-Depends: ${misc:Depends}, openjdk-6-jre | java2-runtime,
+Depends: ${misc:Depends}, openjdk-6-jre | java2-runtime, maven-repo-helper (>> 0.5), maven2,
libmaven-clean-plugin-java, libmaven-resources-plugin-java,
libmaven-compiler-plugin-java, libmaven-jar-plugin-java, libmaven-site-plugin-java,
- libsurefire-java
+ libsurefire-java, velocity, libplexus-velocity-java
+Suggests: libmaven-javadoc-plugin-java
+Conflicts: maven-repo-helper (<= 0.5)
Description: Helper tools for building Debian packages with Maven
Maven is a software project management and comprehension tool. Based on the
concept of a project object model (POM), Maven can manage a project's build,
Modified: trunk/maven-debian-helper/debian/copyright
===================================================================
--- trunk/maven-debian-helper/debian/copyright 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/debian/copyright 2009-07-14 21:01:22 UTC (rev 9344)
@@ -1,6 +1,7 @@
This package was created by Torsten Werner<twerner at debian.org>.
Copyright: 2008 Torsten Werner <twerner at debian.org>
+Copyright: 2009 Ludovic Claude <ludovic.claude at laposte.net>
License:
@@ -21,30 +22,11 @@
----------
-File: src/main/resources/org/apache/maven/project/pom-4.0.0.xml
-
-Copyright: 2001-2007 Apache Software Foundation.
-
-License: Apache-2.0 (see above)
-
-The file is a slightly modified version of Maven's super POM. It
-mentions a file called NOTICE which contains the thirdparty copyright
-information for Maven's binary distribution.
-
-----------
-
-Files: maven-repo/org/codehaus/*
-
-Copyright: 2001-2008 Codehaus Foundation.
-
-License: Apache-2.0 (see above)
-
-----------
-
Files: cdbs/maven*.mk
Copyright: 2003 Stefan Gybas <sgybas at debian.org>
Copyright: 2008 Torsten Werner <twerner at debian.org>
+Copyright: 2009 Ludovic Claude <ludovic.claude at laposte.net>
License:
Added: trunk/maven-debian-helper/debian/maven-debian-helper.poms
===================================================================
--- trunk/maven-debian-helper/debian/maven-debian-helper.poms (rev 0)
+++ trunk/maven-debian-helper/debian/maven-debian-helper.poms 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,4 @@
+pom.xml --no-parent
+maven-debian-helper/pom.xml
+maven-debian-plugin/pom.xml
+maven-packager-utils/pom.xml
Added: trunk/maven-debian-helper/debian/maven-settings.xml
===================================================================
--- trunk/maven-debian-helper/debian/maven-settings.xml (rev 0)
+++ trunk/maven-debian-helper/debian/maven-settings.xml 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,9 @@
+<!--
+ This is a minimal settings.xml that switches maven to offline mode
+ and uses the Debian repo as the local repo.
+-->
+
+<settings>
+ <localRepository>/usr/share/maven-repo</localRepository>
+ <offline>true</offline>
+</settings>
Added: trunk/maven-debian-helper/debian/maven.rules
===================================================================
--- trunk/maven-debian-helper/debian/maven.rules (rev 0)
+++ trunk/maven-debian-helper/debian/maven.rules 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,3 @@
+junit junit jar s/3\..*/3.x/
+org.codehaus.plexus plexus-container-default jar s/1\.0-alpha-.*/1.0-alpha/
+
Modified: trunk/maven-debian-helper/debian/rules
===================================================================
--- trunk/maven-debian-helper/debian/rules 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/debian/rules 2009-07-14 21:01:22 UTC (rev 9344)
@@ -1,12 +1,45 @@
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/ant.mk
-install/maven-debian-helper::
- sh bootstrap.sh
+PACKAGE := $(DEB_SOURCE_PACKAGE)
+VERSION := $(DEB_UPSTREAM_VERSION)
+JAVA_HOME := /usr/lib/jvm/default-java
+DEB_JARS := ant-nodeps classworlds maven-core maven-artifact maven-artifact-manager maven-model \
+ maven-compat maven-plugin-api maven-project maven-scm-api velocity file-management plexus-utils \
+ plexus-container-default-alpha maven-repo-helper
+DEB_ANT_BUILD_TARGET := package #javadoc
+DEB_ANT_BUILDFILE := debian/build.xml
+DEB_ANT_ARGS := -Dpackage=$(PACKAGE) -Dbin.package=$(PACKAGE) -Dversion=$(VERSION)
+API_DOCS := target/api
+
+debian/tmp:
+ mkdir -p debian/tmp
+
+debian/tmp/bin: debian/tmp
+ cp -R bin debian/tmp/
+
+debian/tmp/etc: debian/tmp
+ cp -R etc debian/tmp/
+
+debian/tmp/share: debian/tmp
+ cp -R share debian/tmp/
+
+makebuilddir/$(PACKAGE):: debian/tmp/bin debian/tmp/etc debian/tmp/share
+
+install/$(PACKAGE)::
+ mh_installpoms -p$(PACKAGE)
+ mh_installjar -p$(PACKAGE) -l maven-debian-helper/pom.xml maven-debian-helper/target/maven-debian-helper-$(VERSION).jar
+ mh_installjar -p$(PACKAGE) -l maven-debian-plugin/pom.xml maven-debian-plugin/target/maven-debian-plugin-$(VERSION).jar
+ mh_installjar -p$(PACKAGE) -l maven-packager-utils/pom.xml maven-packager-utils/target/maven-packager-utils-$(VERSION).jar
pod2man -c 'Maven for Debian GNU/Linux' \
-r maven-debian-helper-$(DEB_UPSTREAM_VERSION) \
man/mvn-debian.pod > man/mvn-debian.1
clean::
+ -rm -rf debian/tmp
$(RM) man/mvn-debian.1
+
+clean::
+ $(RM) man/mvn-debian.1
Modified: trunk/maven-debian-helper/etc/fake-poms.conf
===================================================================
--- trunk/maven-debian-helper/etc/fake-poms.conf 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/etc/fake-poms.conf 2009-07-14 21:01:22 UTC (rev 9344)
@@ -1,47 +1,23 @@
-asm asm /usr/share/java/asm2.jar 2
-asm asm /usr/share/java/asm3.jar 3
+asm asm /usr/share/java/asm2.jar 2.x
bcel bcel
-classworlds classworlds
-commons-cli commons-cli
commons-el commons-el
-commons-logging commons-logging
dom4j dom4j
easymock easymock
gnu-getopt getopt /usr/share/java/gnu-getopt.jar
-com.google.code.google-collections google-collect
javax.activation activation /usr/share/java/glassfish-activation.jar
javax.ejb ejb-api /usr/share/java/glassfish-ejb-api.jar
javax.mail mail /usr/share/java/glassfish-mail.jar
javax.servlet servlet-api /usr/share/java/servlet-api-2.4.jar 2.4
-javax.servlet servlet-api /usr/share/java/servlet-api-2.5.jar 2.5
javax.servlet.jsp jsp-api /usr/share/java/jsp-api-2.0.jar 2.0
-javax.servlet.jsp jsp-api /usr/share/java/jsp-api-2.1.jar 2.1
jaxen jaxen
jboss.common jboss-common
jmock jmock
-junit junit /usr/share/java/junit.jar 3.8.1
-junit junit4 /usr/share/java/junit4.jar 4
+junit junit4 /usr/share/java/junit4.jar 4.x
org.antlr antlr
-org.apache.ant ant
-org.apache.ant ant-launcher
org.apache.geronimo.specs specs
-org.apache.maven maven-parent
-org.apache.maven.doxia doxia-sink-api
-org.apache.maven.plugins maven-plugins
-org.apache.maven.shared file-management
-org.apache.maven.shared maven-shared-components
-org.apache.maven.shared maven-shared-io
org.apache.ws.jaxme jaxmeapi
-org.apache.xbean xbean-reflect
-org.beanshell bsh
org.codehaus.groovy groovy
org.codehaus.mojo mojo
-org.codehaus.plexus plexus
-org.codehaus.plexus plexus-compiler-api
-org.codehaus.plexus plexus-compiler-javac
-org.codehaus.plexus plexus-container-default /usr/share/java/plexus-container-default-1.0.jar 1.0-beta
-org.codehaus.plexus plexus-component-factories
-org.codehaus.plexus plexus-velocity
org.codehaus.woodstox wstx-asl /usr/share/java/wstx.jar
org.eclipse.jdt core /usr/share/java/ecj.jar
org.jboss jboss-common-core /usr/share/java/jboss-common.jar
@@ -49,14 +25,8 @@
org.jboss.microcontainer jboss-dependency /usr/share/java/jboss-microcontainer.jar
org.jboss.microcontainer jboss-microcontainer
org.jboss.ws jbossws-parent
-org.slf4j jcl104-over-slf4j /usr/share/java/jcl-over-slf4j.jar
-org.slf4j slf4j-api
-org.slf4j slf4j-simple
-org.codehaus.plexus plexus-interactivity-api
regexp regexp
tomcat jasper-compiler /usr/share/tomcat5.5/common/lib/jasper-compiler.jar
tomcat jasper-compiler-jdt /usr/share/tomcat5.5/common/lib/jasper-compiler-jdt.jar
tomcat jasper-runtime /usr/share/tomcat5.5/common/lib/jasper-runtime.jar
-xerces xercesImpl
-xerces xmlParserAPIs
-xml-apis xml-apis
+
Modified: trunk/maven-debian-helper/maven-debian-helper/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-debian-helper/pom.xml 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/maven-debian-helper/pom.xml 2009-07-14 21:01:22 UTC (rev 9344)
@@ -17,8 +17,6 @@
<groupId>classworlds</groupId>
<artifactId>classworlds</artifactId>
<version>1.1</version>
- <scope>system</scope>
- <systemPath>/usr/share/java/classworlds.jar</systemPath>
</dependency>
</dependencies>
</project>
Modified: trunk/maven-debian-helper/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java 2009-07-14 21:01:22 UTC (rev 9344)
@@ -4,7 +4,7 @@
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
-import org.apache.maven.cli.MavenCli;
+import org.apache.maven.cli.compat.CompatibleMain;
import org.codehaus.classworlds.ClassWorld;
/* This is a wrapper for Maven's main function that reads 2 property
@@ -83,11 +83,10 @@
public static int main(String[] args, ClassWorld classWorld) throws IOException
{
- updateProperties("properties.file.auto");
updateProperties("properties.file.manual");
updateCommandLine(args);
- return MavenCli.main(newArgs, classWorld);
+ return CompatibleMain.main(newArgs, classWorld);
}
}
Modified: trunk/maven-debian-helper/maven-debian-plugin/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/pom.xml 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/maven-debian-plugin/pom.xml 2009-07-14 21:01:22 UTC (rev 9344)
@@ -11,4 +11,12 @@
<artifactId>maven-debian-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>Maven Debian Plugin</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-repo-helper</artifactId>
+ <version>0.5</version>
+ </dependency>
+ </dependencies>
</project>
Added: trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallDocMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallDocMojo.java (rev 0)
+++ trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallDocMojo.java 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,29 @@
+package org.debian.maven.plugin;
+
+/**
+ * Install the javadoc jar files into the debian/ directory
+ *
+ * @goal install-doc
+ *
+ * @author Ludovic Claude
+ */
+public class InstallDocMojo extends SysInstallDocMojo
+{
+
+ // ----------------------------------------------------------------------
+ // Public methods
+ // ----------------------------------------------------------------------
+
+ // ----------------------------------------------------------------------
+ // Private methods
+ // ----------------------------------------------------------------------
+
+ /* returns e.g. $CURDIR/debian/libfoobar-java
+ */
+
+ protected String packagePath()
+ {
+ return getDebianDir() + "/" + getDebianPackage();
+ }
+
+}
Modified: trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java 2009-07-14 21:01:22 UTC (rev 9344)
@@ -8,26 +8,6 @@
public class InstallMojo extends SysInstallMojo
{
// ----------------------------------------------------------------------
- // Mojo parameters
- // ----------------------------------------------------------------------
-
- /**
- * $(CURDIR)/debian - must be supplied because $(CURDIR) is not known
- *
- * @parameter expression="${debian.dir}"
- * @required
- */
- private String debianDir;
-
- /**
- * name of the debian binary package, e.g. libfoobar-java
- *
- * @parameter expression="${debian.package}"
- * @required
- */
- private String debianPackage;
-
- // ----------------------------------------------------------------------
// Public methods
// ----------------------------------------------------------------------
@@ -40,6 +20,6 @@
protected String packagePath()
{
- return debianDir + "/" + debianPackage;
+ return getDebianDir() + "/" + getDebianPackage();
}
}
Added: trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java (rev 0)
+++ trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,34 @@
+package org.debian.maven.plugin;
+
+import java.io.IOException;
+
+/**
+ * Install the javadoc jar.
+ *
+ * @author Ludovic Claude
+ *
+ * @goal sysinstall-doc
+ */
+public class SysInstallDocMojo extends SysInstallMojo
+{
+
+ protected String jarName()
+ {
+ return getArtifactId() + "-javadoc-" + getVersion() + ".jar";
+ }
+
+ protected String debianJarName()
+ {
+ return getArtifactId() + "-javadoc-" + getDebianVersion() + ".jar";
+ }
+
+ /**
+ * do the actual work
+ */
+ protected void runMojo() throws IOException
+ {
+ initProperties();
+ copyJar();
+ }
+
+}
Modified: trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java 2009-07-14 21:01:22 UTC (rev 9344)
@@ -1,10 +1,17 @@
package org.debian.maven.plugin;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
-import org.apache.maven.bootstrap.util.FileUtils;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import org.codehaus.plexus.util.FileUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
+import org.debian.maven.repo.POMCleaner;
+import org.debian.maven.repo.POMTransformer;
/**
* Install pom and jar files into the /usr/share/hierarchy
@@ -45,6 +52,13 @@
private String version;
/**
+ * debianVersion
+ *
+ * @parameter
+ */
+ private String debianVersion;
+
+ /**
* directory where the current pom.xml can be found
*
* @parameter expression="${basedir}"
@@ -62,6 +76,26 @@
*/
private String jarDir;
+ /**
+ * Debian directory
+ *
+ * @parameter expression="${debian.dir}"
+ */
+ private File debianDir;
+
+ /**
+ * Debian package
+ *
+ * @parameter expression="${debian.package}"
+ */
+ private String debianPackage;
+
+ /**
+ * @parameter expression="${maven.rules}" default-value="maven.rules"
+ * @required
+ */
+ private String mavenRules;
+
// ----------------------------------------------------------------------
// Public methods
// ----------------------------------------------------------------------
@@ -83,50 +117,126 @@
// Private methods
// ----------------------------------------------------------------------
- /* optional destination prefix, empty by default
+ protected String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ protected String getVersion()
+ {
+ return version;
+ }
+
+ protected String getDebianVersion()
+ {
+ return debianVersion;
+ }
+
+ protected File getDebianDir()
+ {
+ return debianDir;
+ }
+
+ protected String getDebianPackage()
+ {
+ return debianPackage;
+ }
+
+ /**
+ * optional destination prefix, empty by default
*/
-
protected String packagePath()
{
return "";
}
- /* returns e.g. /org/debian/maven/maven-debian-plugin/0.1/
+ /**
+ * returns e.g. /org/debian/maven/maven-debian-plugin/0.1/
*/
-
private String repoPath()
{
return "/" + groupId.replace( '.', '/' ) + "/" + artifactId + "/" + version + "/";
}
- /* absolute path to destination dir
+ /**
+ * returns e.g. /org/debian/maven/maven-debian-plugin/debian/
*/
+ private String debianRepoPath()
+ {
+ return "/" + groupId.replace( '.', '/' ) + "/" + artifactId + "/" + debianVersion + "/";
+ }
+ /**
+ * absolute path to destination dir
+ */
protected String fullRepoPath()
{
return packagePath() + "/usr/share/maven-repo" + repoPath();
}
- private String pomName()
+ /**
+ * absolute path to destination dir
+ */
+ protected String debianFullRepoPath()
{
+ return packagePath() + "/usr/share/maven-repo" + debianRepoPath();
+ }
+
+ protected String pomName()
+ {
return artifactId + "-" + version + ".pom";
}
+ protected String debianPomName()
+ {
+ return artifactId + "-" + debianVersion + ".pom";
+ }
+
private String pomSrcPath()
{
return basedir.getAbsolutePath() + "/pom.xml";
}
+ private String cleanedPomSrcPath()
+ {
+ return basedir.getAbsolutePath() + "/target/pom.xml";
+ }
+
+ private String cleanedPomPropertiesSrcPath()
+ {
+ return basedir.getAbsolutePath() + "/target/pom.properties";
+ }
+
+ private String debianPomSrcPath()
+ {
+ return basedir.getAbsolutePath() + "/target/pom.debian.xml";
+ }
+
+ private String debianPomPropertiesSrcPath()
+ {
+ return basedir.getAbsolutePath() + "/target/pom.debian.properties";
+ }
+
private String pomDestPath()
{
return fullRepoPath() + pomName();
}
- private String jarName()
+ private String debianPomDestPath()
{
+ return debianFullRepoPath() + debianPomName();
+ }
+
+ protected String jarName()
+ {
return artifactId + "-" + version + ".jar";
}
+ protected String debianJarName()
+ {
+ return artifactId + "-" + debianVersion + ".jar";
+ }
+
private String fullJarName()
{
return jarDir + "/" + jarName();
@@ -137,9 +247,19 @@
return fullRepoPath() + jarName();
}
- /* jar file name without version number
+ private String jarDestRelPath()
+ {
+ return "../" + version + "/" + jarName();
+ }
+
+ private String debianJarDestPath()
+ {
+ return debianFullRepoPath() + debianJarName();
+ }
+
+ /**
+ * jar file name without version number
*/
-
private String compatName()
{
return artifactId + ".jar";
@@ -160,21 +280,18 @@
return compatSharePath() + compatName();
}
- /* command for creating the relative symlink
- */
-
- private String[] linkCommand()
+ protected String versionedFullCompatPath()
{
- String[] command = {"ln", "-s", compatRelPath(), fullCompatPath()};
- return command;
+ return compatSharePath() + jarName();
}
- /* copy the pom.xml
+ /**
+ * command for creating the relative symlink
*/
-
- private void copyPom() throws IOException
+ private String[] linkCommand(String source, String dest)
{
- FileUtils.copyFile(new File(pomSrcPath()), new File(pomDestPath()));
+ String[] command = {"ln", "-s", source, dest};
+ return command;
}
private void mkdir(String path) throws IOException
@@ -195,26 +312,140 @@
Runtime.getRuntime().exec(command, null);
}
- /* if a jar exists: copy it and symlink it to the compat share dir
+ /**
+ * if a jar exists: copy it to the Maven repository
*/
-
- private void copyAndSymlinkJar() throws IOException
+ protected void copyJar() throws IOException
{
- FileUtils.copyFile(new File(pomSrcPath()), new File(pomDestPath()));
File jarFile = new File(fullJarName());
if (jarFile.exists())
{
FileUtils.copyFile(jarFile, new File(jarDestPath()));
+ if (debianVersion != null && !debianVersion.equals(version))
+ {
+ mkdir(debianFullRepoPath());
+ run(linkCommand(jarDestRelPath(), debianJarDestPath()));
+ }
mkdir(compatSharePath());
- run(linkCommand());
+ run(linkCommand(compatRelPath(), fullCompatPath()));
+ run(linkCommand(compatRelPath(), versionedFullCompatPath()));
}
}
- /* do the actual work
+ /**
+ * if a jar exists: symlink it to the compat share dir
*/
+ private void symlinkJar() throws IOException
+ {
+ File jarFile = new File(fullJarName());
+ if (jarFile.exists())
+ {
+ mkdir(compatSharePath());
+ run(linkCommand(compatRelPath(), fullCompatPath()));
+ run(linkCommand(compatRelPath(), versionedFullCompatPath()));
+ }
+ }
+
+ /**
+ * clean the pom.xml
+ */
+ private void cleanPom()
+ {
+ File pomOptionsFile = new File(debianDir, debianPackage + ".poms");
+ Map pomOptions = POMTransformer.getPomOptions(pomOptionsFile);
+ // Use the saved pom before cleaning as it was untouched by the transform operation
+ File pom = new File(pomSrcPath() + ".save");
+ File originalPom = new File(pomSrcPath()).getAbsoluteFile();
+ if (! pom.exists())
+ {
+ pom = originalPom;
+ }
+
+ String pomOption = (String) pomOptions.get(originalPom);
+
+ List params = new ArrayList();
+ params.add("--keep-pom-version");
+ params.add("--package=" + debianPackage);
+ String mavenRulesPath = new File(debianDir, mavenRules).getAbsolutePath();
+ params.add("--rules=" + mavenRulesPath);
+
+ System.out.println("Cleaning pom file: " + pom + " with options:");
+ System.out.println("\t--keep-pom-version --package=" + debianPackage);
+ System.out.println("\t--rules=" + mavenRulesPath);
+
+ // add optional --no-parent option
+ if (pomOption != null && !pomOption.isEmpty()) {
+ params.add(pomOption);
+ System.out.println("\t" + pomOption);
+ }
+
+ params.add(pom.getAbsolutePath());
+ params.add(cleanedPomSrcPath());
+ params.add(cleanedPomPropertiesSrcPath());
+
+ POMCleaner.main((String[]) params.toArray(new String[params.size()]));
+
+ // read debian version
+ if (debianVersion == null)
+ {
+ Properties pomProperties = new Properties();
+ try {
+ pomProperties.load(new FileReader(cleanedPomPropertiesSrcPath()));
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ debianVersion = pomProperties.getProperty("debianVersion");
+ }
+
+ if (debianVersion != null && !debianVersion.equals(version))
+ {
+ params.remove(0);
+ params.remove(params.size() -1);
+ params.remove(params.size() -1);
+ params.add(debianPomSrcPath());
+ params.add(debianPomPropertiesSrcPath());
+
+ POMCleaner.main((String[]) params.toArray(new String[params.size()]));
+ }
+ }
+
+ /**
+ * copy the pom.xml
+ */
+ protected void copyPom() throws IOException
+ {
+ FileUtils.copyFile(new File(cleanedPomSrcPath()), new File(pomDestPath()));
+ if (debianVersion != null && !debianVersion.equals(version))
+ {
+ FileUtils.copyFile(new File(debianPomSrcPath()), new File(debianPomDestPath()));
+ }
+ }
+
+ /**
+ * Initialize some properties which don't seem to be set automatically
+ * by Maven Mojo mechanism.
+ */
+ protected void initProperties()
+ {
+ if (debianDir == null)
+ {
+ debianDir = new File(System.getProperty("debian.dir"));
+ }
+ if (debianPackage == null)
+ {
+ debianPackage = System.getProperty("debian.package");
+ }
+ }
+
+ /**
+ * do the actual work
+ */
protected void runMojo() throws IOException
{
+ //initProperties();
+ cleanPom();
copyPom();
- copyAndSymlinkJar();
+ copyJar();
+ symlinkJar();
}
}
Modified: trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysUninstallMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysUninstallMojo.java 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysUninstallMojo.java 2009-07-14 21:01:22 UTC (rev 9344)
@@ -1,7 +1,7 @@
package org.debian.maven.plugin;
import java.io.IOException;
-import org.apache.maven.bootstrap.util.FileUtils;
+import org.codehaus.plexus.util.FileUtils;
/**
* Remove installed files and symlinks from the /usr/share hierarchy
Added: trunk/maven-debian-helper/maven-packager-utils/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/pom.xml (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/pom.xml 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>maven-debian</artifactId>
+ <groupId>org.debian.maven</groupId>
+ <version>0.4</version>
+ </parent>
+
+ <artifactId>maven-packager-utils</artifactId>
+ <packaging>maven-plugin</packaging>
+ <name>Maven Packager Utilities</name>
+
+ <dependencies>
+ <dependency> <!-- Not needed, but a temporary fix for a bug where plexus-utils 1.1 is searched for -->
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.5.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-repo-helper</artifactId>
+ <version>0.6</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesMojo.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesMojo.java 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,112 @@
+package org.debian.maven.packager;
+
+/*
+ * Copyright 2009 Ludovic Claude.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Analyze the Maven dependencies and extract the list of dependent packages,
+ * reusable as subvars in the Debian control file and the list of POM files
+ * to use and the rules if they did not exist already.
+ *
+ * @goal dependencies
+ * @aggregator
+ * @requiresDependencyResolution
+ * @phase process-sources
+ *
+ * @author Ludovic Claude
+ */
+public class DependenciesMojo
+ extends AbstractMojo {
+
+ /**
+ * The Maven Project Object
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ * @required
+ */
+ protected MavenProject project;
+ /**
+ * A list of every project in this reactor; provided by Maven
+ * @parameter expression="${project.collectedProjects}"
+ */
+ protected List collectedProjects;
+ /**
+ * Location of the file.
+ * @parameter expression="${debian.directory}"
+ * default-value="debian"
+ */
+ protected File outputDirectory;
+ /**
+ * Name of the package (e.g. 'commons-lang')
+ * @parameter expression="${package}"
+ * @required
+ */
+ protected String packageName;
+ /**
+ * Type of the package (e.g. 'maven' or 'ant')
+ * @parameter expression="${packageType}" default-value="maven"
+ */
+ protected String packageType;
+ /**
+ * Location of the Maven repository
+ *
+ * @parameter default-value="/usr/share/maven-repo"
+ */
+ protected File mavenRepo;
+
+ public void execute()
+ throws MojoExecutionException {
+ File f = outputDirectory;
+ if (!f.exists()) {
+ f.mkdirs();
+ }
+
+ DependenciesSolver solver = new DependenciesSolver();
+
+ File basedir = project.getBasedir();
+ List projects = new ArrayList();
+ projects.add(project.getFile());
+ if (collectedProjects != null) {
+ for (Iterator i = collectedProjects.iterator(); i.hasNext();) {
+ MavenProject subProject = (MavenProject) i.next();
+ projects.add(subProject.getFile());
+ }
+ }
+
+ solver.setProjects(projects);
+ solver.setBaseDir(basedir);
+ solver.setMavenRepo(mavenRepo);
+ solver.setOutputDirectory(outputDirectory);
+ solver.setPackageName(packageName);
+ solver.setPackageType(packageType);
+
+ solver.solveDependencies();
+
+ solver.saveListOfPoms();
+ solver.saveMavenRules();
+ solver.saveSubstvars();
+ }
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,521 @@
+package org.debian.maven.packager;
+
+/*
+ * Copyright 2009 Ludovic Claude.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.stream.XMLStreamException;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import org.debian.maven.repo.Dependency;
+import org.debian.maven.repo.POMInfo;
+import org.debian.maven.repo.POMReader;
+import org.debian.maven.repo.Repository;
+
+/**
+ * Analyze the Maven dependencies and extract the Maven rules to use
+ * as well as the list of dependent packages.
+ *
+ * @author Ludovic Claude
+ */
+public class DependenciesSolver {
+
+ protected File baseDir;
+ protected File outputDirectory;
+ protected String packageName;
+ protected String packageType;
+ protected File mavenRepo = new File("/usr/share/maven-repo");
+ protected boolean exploreProjects;
+ protected List projects = new ArrayList();
+
+ private Repository repository;
+ private List issues = new ArrayList();
+ private List pomsConfig = new ArrayList();
+ private Set compileDepends = new TreeSet();
+ private Set testDepends = new TreeSet();
+ private Set runtimeDepends = new TreeSet();
+ private Set optionalDepends = new TreeSet();
+ private Set rules = new TreeSet();
+ private boolean checkedAptFile;
+
+ public File getBaseDir() {
+ return baseDir;
+ }
+
+ public void saveListOfPoms() {
+ File listPoms = new File(outputDirectory, packageName + ".poms");
+ if (!listPoms.exists()) {
+ try {
+ PrintWriter out = new PrintWriter(new FileWriter(listPoms));
+ for (Iterator i = pomsConfig.iterator(); i.hasNext();) {
+ String config = (String) i.next();
+ out.println(config);
+ }
+ out.close();
+ } catch (Exception ex) {
+ Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+
+ public void saveMavenRules() {
+ File mavenRules = new File(outputDirectory, "maven.rules");
+ if (!mavenRules.exists()) {
+ try {
+ PrintWriter out = new PrintWriter(new FileWriter(mavenRules));
+ for (Iterator i = rules.iterator(); i.hasNext();) {
+ String rule = (String) i.next();
+ out.println(rule);
+ }
+ out.close();
+ } catch (IOException ex) {
+ Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+
+ public void saveSubstvars() {
+ File dependencies = new File(outputDirectory, packageName + ".substvars");
+ Properties depVars = new Properties();
+ if (dependencies.exists()) {
+ try {
+ depVars.load(new FileReader(dependencies));
+ } catch (IOException ex) {
+ Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ depVars.put("maven.CompileDepends", toString(compileDepends));
+ depVars.put("maven.TestDepends", toString(testDepends));
+ depVars.put("maven.Depends", toString(runtimeDepends));
+ depVars.put("maven.OptionalDepends", toString(optionalDepends));
+ try {
+ depVars.store(new FileWriter(dependencies), "List of dependencies for " + packageName + ", generated for use by debian/control");
+ } catch (IOException ex) {
+ Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ public void setBaseDir(File baseDir) {
+ this.baseDir = baseDir;
+ }
+
+ public boolean isExploreProjects() {
+ return exploreProjects;
+ }
+
+ public void setExploreProjects(boolean exploreProjects) {
+ this.exploreProjects = exploreProjects;
+ }
+
+ public File getMavenRepo() {
+ return mavenRepo;
+ }
+
+ public void setMavenRepo(File mavenRepo) {
+ this.mavenRepo = mavenRepo;
+ }
+
+ public File getOutputDirectory() {
+ return outputDirectory;
+ }
+
+ public void setOutputDirectory(File outputDirectory) {
+ this.outputDirectory = outputDirectory;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public String getPackageType() {
+ return packageType;
+ }
+
+ public void setPackageType(String packageType) {
+ this.packageType = packageType;
+ }
+
+ public List getProjects() {
+ return projects;
+ }
+
+ public void setProjects(List projects) {
+ this.projects = projects;
+ }
+
+ public List getIssues() {
+ return issues;
+ }
+
+ public void solveDependencies() {
+ File f = outputDirectory;
+ if (!f.exists()) {
+ f.mkdirs();
+ }
+
+ repository = new Repository((mavenRepo));
+ repository.scan();
+
+ if (exploreProjects) {
+ File pom = new File(baseDir, "pom.xml");
+ if (pom.exists()) {
+ projects.add(pom);
+ } else {
+ File debianPom = new File(baseDir, "debian/pom.xml");
+ if (debianPom.exists()) {
+ projects.add(debianPom);
+ } else {
+ System.err.println("Cannot find the POM file");
+ return;
+ }
+ }
+ resolveDependencies(pom);
+ } else {
+ for (Iterator i = projects.iterator(); i.hasNext();) {
+ File pom = (File) i.next();
+ resolveDependencies(pom);
+ }
+ }
+
+ for (Iterator i = issues.iterator(); i.hasNext();) {
+ String issue = (String) i.next();
+ System.err.println(issue);
+ }
+ }
+
+ private void resolveDependencies(File projectPom) {
+ POMReader reader = new POMReader();
+ String pomRelPath = projectPom.getAbsolutePath().substring(baseDir.getAbsolutePath().length() + 1);
+ try {
+ POMInfo pom = reader.readPom(projectPom);
+ repository.registerPom(projectPom, pom);
+
+ boolean noParent = false;
+ if (pom.getParent() != null) {
+ POMInfo parentPom = repository.searchMatchingPOM(pom.getParent());
+ if (parentPom == null) {
+ noParent = true;
+ }
+ if (!baseDir.equals(projectPom.getParentFile())) {
+ System.out.println("Check the parent dependency in the sub project " + projectPom);
+ Set parentDependencies = new TreeSet();
+ parentDependencies.add(pom.getParent());
+ resolveDependencies(parentDependencies, false, false);
+ }
+ }
+
+ if (noParent) {
+ pomsConfig.add(pomRelPath + " --no-parent");
+ } else {
+ pomsConfig.add(pomRelPath);
+ }
+
+ resolveDependencies(pom.getDependencies(), false, false);
+ resolveDependencies(pom.getPlugins(), true, true);
+ resolveDependencies(pom.getPluginDependencies(), true, true);
+ resolveDependencies(pom.getExtensions(), true, true);
+
+ if (exploreProjects) {
+ for (Iterator i = pom.getModules().iterator(); i.hasNext();) {
+ String module = (String) i.next();
+ File modulePom = new File(projectPom.getParent(), module + "/pom.xml");
+ resolveDependencies(modulePom);
+ }
+ }
+ } catch (XMLStreamException ex) {
+ Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ private void resolveDependencies(Collection poms, boolean buildTime, boolean mavenExtension) {
+ for (Iterator i = poms.iterator(); i.hasNext();) {
+ Dependency dependency = (Dependency) i.next();
+ POMInfo pom = repository.searchMatchingPOM(dependency);
+ if (pom == null && "maven-plugin".equals(dependency.getType())) {
+ List matchingPoms = repository.searchMatchingPOMsIgnoreVersion(dependency);
+ if (matchingPoms.size() > 1) {
+ issues.add("More than one version matches the plugin " + dependency.getGroupId() + ":" +
+ dependency.getArtifactId() + ":" + dependency.getVersion());
+ }
+ if (!matchingPoms.isEmpty()) {
+ pom = (POMInfo) matchingPoms.get(0);
+ // Adapt the version of the plugin to what is in the repository
+ rules.add(dependency.getGroupId() + " " +
+ dependency.getArtifactId() + " maven-plugin s/.*/" + pom.getOriginalVersion() + "/");
+ }
+ }
+ if (pom == null) {
+ issues.add("Dependency is not packaged in the Maven repository for Debian: " + dependency.getGroupId() + ":" +
+ dependency.getArtifactId() + ":" + dependency.getVersion());
+ return;
+ }
+ String library = null;
+ if (pom.getProperties() != null) {
+ library = (String) pom.getProperties().get("debian.package");
+ }
+ if (library == null) {
+ issues.add("Dependency is missing the Debian properties in its POM: " + dependency.getGroupId() + ":" +
+ dependency.getArtifactId() + ":" + dependency.getVersion());
+ File pomFile = new File(mavenRepo, dependency.getGroupId().replace(".", "/") + "/" + dependency.getArtifactId() + "/" + dependency.getVersion() + "/" + dependency.getArtifactId() + "-" + dependency.getVersion() + ".pom");
+ library = searchPkg(pomFile);
+ }
+ if (library != null) {
+ if (buildTime) {
+ if ("test".equals(dependency.getScope())) {
+ testDepends.add(library);
+ } else if ("maven-plugin".equals(dependency.getType())) {
+ if (!packageType.equals("ant")) {
+ compileDepends.add(library + " (>= " + pom.getOriginalVersion() + ")");
+ }
+ } else if (mavenExtension) {
+ if (!packageType.equals("ant")) {
+ compileDepends.add(library);
+ }
+ } else {
+ compileDepends.add(library);
+ }
+ } else {
+ if (dependency.isOptional()) {
+ optionalDepends.add(library);
+ } else if ("test".equals(dependency.getScope())) {
+ testDepends.add(library);
+ } else if ("compile".equals(dependency.getScope())) {
+ compileDepends.add(library);
+ } else {
+ runtimeDepends.add(library);
+ }
+ }
+ }
+ String mavenRules = (String) pom.getProperties().get("debian.mavenRules");
+ if (mavenRules != null) {
+ StringTokenizer st = new StringTokenizer(mavenRules, ",");
+ while (st.hasMoreTokens()) {
+ rules.add(st.nextToken().trim());
+ }
+ }
+ }
+ }
+
+ private String searchPkg(File pomFile) {
+ GetPackageResult packageResult = new GetPackageResult();
+ executeProcess(new String[]{"dpkg", "--search", pomFile.getAbsolutePath()}, packageResult);
+ if (packageResult.getResult() != null) {
+ return packageResult.getResult();
+ }
+
+ if (!checkedAptFile) {
+ if (!"maven2".equals(searchPkg(new File("/usr/bin/mvn")))) {
+ System.err.println("Warning: apt-file doesn't seem to be configured");
+ System.err.println("Please run the following command and start again:");
+ System.err.println(" sudo apt-file update");
+ return null;
+ }
+ checkedAptFile = true;
+ }
+ executeProcess(new String[]{"apt-file", "search", pomFile.getAbsolutePath()}, packageResult);
+ return packageResult.getResult();
+ }
+
+ public static void executeProcess(final String[] cmd, final OutputHandler handler) {
+ try {
+ ProcessBuilder pb = new ProcessBuilder(cmd);
+ pb.redirectErrorStream(true);
+ System.out.print("> ");
+ for (int i = 0; i < cmd.length; i++) {
+ String arg = cmd[i];
+ System.out.print(arg + " ");
+ }
+ System.out.println();
+ final Process process = pb.start();
+ try {
+ ThreadFactory threadFactory = new ThreadFactory() {
+
+ public Thread newThread(Runnable r) {
+ Thread t = new Thread(r, "Run command " + cmd[0]);
+ t.setDaemon(true);
+ return t;
+ }
+ };
+
+ ExecutorService executor = Executors.newSingleThreadExecutor(threadFactory);
+ executor.execute(new Runnable() {
+
+ public void run() {
+ try {
+ InputStreamReader isr = new InputStreamReader(process.getInputStream());
+ BufferedReader br = new BufferedReader(isr);
+ LineNumberReader aptIn = new LineNumberReader(br);
+ String line;
+ while ((line = aptIn.readLine()) != null) {
+ System.out.println(line);
+ handler.newLine(line);
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+
+ process.waitFor();
+ executor.awaitTermination(5, TimeUnit.SECONDS);
+ if (process.exitValue() == 0) {
+ } else {
+ System.out.println("Cannot execute " + cmd[0]);
+ }
+ process.destroy();
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ Thread.interrupted();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private String toString(Set s) {
+ StringBuffer sb = new StringBuffer();
+ for (Iterator i = s.iterator(); i.hasNext();) {
+ String st = (String) i.next();
+ sb.append(st);
+ if (i.hasNext()) {
+ sb.append(", ");
+ }
+ }
+ return sb.toString();
+ }
+
+ public static interface OutputHandler {
+
+ void newLine(String line);
+ }
+
+ public static class NoOutputHandler implements OutputHandler {
+
+ public void newLine(String line) {
+ }
+ }
+
+ static class GetPackageResult implements OutputHandler {
+
+ private String result;
+
+ public void newLine(String line) {
+ int colon = line.indexOf(':');
+ if (colon > 0 && line.indexOf(' ') > colon) {
+ result = line.substring(0, colon);
+ // Ignore lines such as 'dpkg : xxx'
+ if (!result.equals(result.trim()) || result.startsWith("dpkg")) {
+ result = null;
+ } else {
+ System.out.println("Found " + result);
+ }
+ }
+ }
+
+ public String getResult() {
+ return result;
+ }
+ };
+
+ public static void main(String[] args) {
+ if (args.length == 0 || "-h".equals(args[0]) || "--help".equals(args[0])) {
+ System.out.println("Purpose: Solve the dependencies in the POM(s).");
+ System.out.println("Usage: [option]");
+ System.out.println("");
+ System.out.println("Options:");
+ System.out.println(" -v, --verbose: be extra verbose");
+ System.out.println(" -p<package>, --package=<package>: name of the Debian package containing");
+ System.out.println(" this library");
+ System.out.println(" -r<rules>, --rules=<rules>: path to the file containing the");
+ System.out.println(" extra rules to apply when cleaning the POM");
+ System.out.println(" -i<rules>, --published-rules=<rules>: path to the file containing the");
+ System.out.println(" extra rules to publish in the property debian.mavenRules in the cleaned POM");
+ System.out.println(" --ant: use ant for the packaging");
+ return;
+ }
+ DependenciesSolver solver = new DependenciesSolver();
+
+ solver.setBaseDir(new File("."));
+ solver.setExploreProjects(true);
+ solver.setOutputDirectory(new File("debian"));
+
+ int i = inc(-1, args);
+ boolean verbose = false;
+ String debianPackage = "";
+ String packageType = "maven";
+ while (i < args.length && (args[i].trim().startsWith("-") || args[i].trim().isEmpty())) {
+ String arg = args[i].trim();
+ if ("--verbose".equals(arg) || "-v".equals(arg)) {
+ verbose = true;
+ } else if (arg.startsWith("-p")) {
+ debianPackage = arg.substring(2);
+ } else if (arg.startsWith("--package=")) {
+ debianPackage = arg.substring("--package=".length());
+ } else if (arg.startsWith("--ant")) {
+ packageType = "ant";
+ }
+ i = inc(i, args);
+ }
+
+ solver.setPackageName(debianPackage);
+ solver.setPackageType(packageType);
+ solver.setExploreProjects(true);
+
+ if (verbose) {
+ System.out.println("Solving dependencies for package " + debianPackage);
+ }
+
+ solver.solveDependencies();
+
+ solver.saveListOfPoms();
+ solver.saveMavenRules();
+ solver.saveSubstvars();
+ }
+
+ private static int inc(int i, String[] args) {
+ do {
+ i++;
+ } while (i < args.length && args[i].isEmpty());
+ return i;
+ }
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,380 @@
+package org.debian.maven.packager;
+
+/*
+ * Copyright 2009 Ludovic Claude.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+
+/**
+ * Generate the Debian files for packaging the current Maven project.
+ *
+ * @goal generate
+ * @aggregator
+ * @requiresDependencyResolution
+ * @phase process-sources
+ *
+ * @author Ludovic Claude
+ */
+public class GenerateDebianFilesMojo
+ extends AbstractMojo {
+
+ /**
+ * The Maven Project Object
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ * @required
+ */
+ protected MavenProject project;
+ /**
+ * A list of every project in this reactor; provided by Maven
+ * @parameter expression="${project.collectedProjects}"
+ */
+ protected List collectedProjects;
+ /**
+ * @parameter expression="${localRepository}"
+ * @required
+ * @readonly
+ */
+ protected ArtifactRepository localRepository;
+ /**
+ * Location of the file.
+ * @parameter expression="${debian.directory}"
+ * default-value="debian"
+ */
+ protected File outputDirectory;
+ /**
+ * Name of the packager (e.g. 'Ludovic Claude')
+ * @parameter expression="${packager}"
+ * @required
+ */
+ protected String packager;
+ /**
+ * Email of the packager (e.g. 'ludovic.claude at laposte.net')
+ * @parameter expression="${email}"
+ * @required
+ */
+ protected String email;
+ /**
+ * License used by the packager (e.g. 'GPL-3' or 'Apache-2.0')
+ * See http://dep.debian.net/deps/dep5/ for the list of licenses.
+ * @parameter expression="${packagerLicense}" default-value="GPL-3"
+ * @required
+ */
+ protected String packagerLicense;
+ /**
+ * Name of the source package (e.g. 'commons-lang')
+ * @parameter expression="${package}"
+ * @required
+ */
+ protected String packageName;
+ /**
+ * Name of the binary package (e.g. 'libcommons-lang-java')
+ * @parameter expression="${bin.package}"
+ * @required
+ */
+ protected String binPackageName;
+ /**
+ * Type of the package (e.g. 'maven' or 'ant')
+ * @parameter expression="${packageType}" default="maven"
+ */
+ protected String packageType;
+ /**
+ * URL for downloading the source code, in the form scm:[svn|cvs]:http://xxx/
+ * for downloads using a source code repository,
+ * or http://xxx.[tar|zip|gz|tgz] for downloads using source tarballs.
+ * @parameter expression="${downloadUrl}"
+ */
+ protected String downloadUrl;
+ /**
+ * If true, include running the tests during the build.
+ * @parameter expression="${runTests}" default="true"
+ */
+ protected boolean runTests;
+ /**
+ * If true, generate the Javadoc packaged in a separate package.
+ * @parameter expression="${generateJavadoc}" default="true"
+ */
+ protected boolean generateJavadoc;
+
+ public void execute()
+ throws MojoExecutionException {
+ File f = outputDirectory;
+ if (!f.exists()) {
+ f.mkdirs();
+ }
+
+ String controlTemplate = "control.vm";
+ String rulesTemplate = "rules.vm";
+ String javadocsTemplate = "java-doc.docs.vm";
+ if ("ant".equals(packageType)) {
+ controlTemplate = "control.ant.vm";
+ rulesTemplate = "rules.ant.vm";
+ }
+
+ try {
+
+ Properties velocityProperties = new Properties();
+ velocityProperties.put("resource.loader", "class");
+ velocityProperties.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
+ Velocity.init(velocityProperties);
+ VelocityContext context = new VelocityContext();
+ context.put("package", packageName);
+ context.put("binPackage", binPackageName);
+ context.put("packager", packager);
+ context.put("packagerEmail", email);
+ context.put("packagerLicense", packagerLicense);
+ context.put("project", project);
+ context.put("runTests", Boolean.valueOf(runTests));
+ context.put("generateJavadoc", Boolean.valueOf(generateJavadoc));
+
+ String copyrightYear;
+ int currentYear = new GregorianCalendar().get(Calendar.YEAR);
+ if (project.getInceptionYear() != null) {
+ copyrightYear = project.getInceptionYear();
+ if (Integer.parseInt(copyrightYear) < currentYear) {
+ copyrightYear += "-" + currentYear;
+ }
+ } else {
+ copyrightYear = String.valueOf(currentYear);
+ }
+ context.put("copyrightYear", copyrightYear);
+ context.put("currentYear", new Integer(currentYear));
+ context.put("licenses", new TreeSet());
+ List description = new ArrayList();
+ if (project.getDescription() != null) {
+ StringTokenizer st = new StringTokenizer(project.getDescription().trim(), "\n");
+ while (st.hasMoreTokens()) {
+ description.add(st.nextToken().trim());
+ }
+ }
+ context.put("description", description);
+
+ String projectVersion = project.getVersion();
+
+ int downloadType = DownloadType.UNKNOWN;
+ if (downloadUrl == null) {
+ if (project.getScm() != null) {
+ downloadUrl = project.getScm().getConnection();
+ }
+ }
+ if (downloadUrl != null && downloadUrl.startsWith("scm:svn:")) {
+ downloadType = DownloadType.SVN;
+ downloadUrl = downloadUrl.substring("scm:svn:".length());
+ final int versionPos = downloadUrl.indexOf(projectVersion);
+ if (versionPos > 0) {
+ String baseUrl = downloadUrl.substring(0, versionPos);
+ String suffixUrl = downloadUrl.substring(versionPos + projectVersion.length());
+ if (!suffixUrl.endsWith("/")) {
+ suffixUrl += "/";
+ }
+ int slashPos = baseUrl.lastIndexOf("/");
+ String tagMarker = baseUrl.substring(slashPos + 1);
+ baseUrl = baseUrl.substring(0, slashPos);
+
+ context.put("baseUrl", baseUrl);
+ context.put("tagMarker", tagMarker);
+ context.put("suffixUrl", suffixUrl);
+
+ FileWriter out = new FileWriter(new File(outputDirectory, "watch"));
+ Velocity.mergeTemplate("watch.svn.vm", "UTF8", context, out);
+ out.flush();
+ out.close();
+
+ out = new FileWriter(new File(outputDirectory, "orig-tar.sh"));
+ Velocity.mergeTemplate("orig-tar.svn.vm", "UTF8", context, out);
+ out.flush();
+ out.close();
+
+ makeExecutable("debian/orig-tar.sh");
+
+ } else {
+ System.err.println("Cannot locate the version in the download url (" +
+ downloadUrl + ").");
+ System.err.println("Please run again and provide the download location with an explicit version tag, e.g.");
+ System.err.println("-DdownloadUrl=scm:svn:http://svn.codehaus.org/modello/tags/modello-1.0-alpha-21/");
+ }
+ }
+
+ if (downloadType == DownloadType.UNKNOWN) {
+ System.err.println("Cannot recognize the download url (" +
+ downloadUrl + ").");
+ }
+
+ File substvarsFile = new File(outputDirectory, binPackageName + ".substvars");
+ if (substvarsFile.exists()) {
+ Properties substvars = new Properties();
+ substvars.load(new FileReader(substvarsFile));
+ List depends = new ArrayList();
+ depends.addAll(split(substvars.getProperty("maven.CompileDepends")));
+ depends.addAll(split(substvars.getProperty("maven.Depends")));
+ if (runTests) {
+ depends.addAll(split(substvars.getProperty("maven.TestDepends")));
+ }
+ if ("maven".equals(packageType) && generateJavadoc) {
+ depends.add("libmaven-javadoc-plugin-java");
+ }
+ context.put("compileDependencies", depends);
+ context.put("runtimeDependencies", split(substvars.getProperty("maven.Depends")));
+ context.put("optionalDependencies", split(substvars.getProperty("maven.OptionalDepends")));
+
+ if ("ant".equals(packageType)) {
+ Set buildJars = new TreeSet();
+ for (Iterator i = depends.iterator(); i.hasNext();) {
+ String library = (String) i.next();
+ buildJars.addAll(listSharedJars(library));
+ }
+ context.put("buildJars", buildJars);
+ }
+ } else {
+ System.err.println("Cannot find file " + substvarsFile);
+ }
+
+ if ("ant".equals(packageType)) {
+ List pomDirs = new ArrayList();
+ if (collectedProjects.isEmpty()) {
+ pomDirs.add("");
+ }
+ for (Iterator i = collectedProjects.iterator(); i.hasNext();) {
+ MavenProject mavenProject = (MavenProject) i.next();
+ String basedir = project.getBasedir().getAbsolutePath();
+ String dirRelPath = mavenProject.getBasedir().getAbsolutePath().substring(basedir.length() + 1);
+ pomDirs.add(dirRelPath);
+ }
+ context.put("pomDirs", pomDirs);
+ }
+
+ FileWriter out = new FileWriter(new File(outputDirectory, "README.source"));
+ Velocity.mergeTemplate("README.source.vm", "UTF8", context, out);
+ out.flush();
+ out.close();
+
+ out = new FileWriter(new File(outputDirectory, "copyright"));
+ Velocity.mergeTemplate("copyright.vm", "UTF8", context, out);
+ out.flush();
+ out.close();
+
+ out = new FileWriter(new File(outputDirectory, "compat"));
+ Velocity.mergeTemplate("compat.vm", "UTF8", context, out);
+ out.flush();
+ out.close();
+
+ out = new FileWriter(new File(outputDirectory, "rules"));
+ Velocity.mergeTemplate(rulesTemplate, "UTF8", context, out);
+ out.flush();
+ out.close();
+
+ makeExecutable("debian/rules");
+
+ String debianVersion = projectVersion.replace("-alpha-", "~alpha");
+ debianVersion = debianVersion.replace("-beta-", "~beta");
+ debianVersion += "-1";
+ context.put("debianVersion", debianVersion);
+ out = new FileWriter(".debianVersion");
+ Velocity.mergeTemplate("version.vm", "UTF8", context, out);
+ out.flush();
+ out.close();
+
+ if (generateJavadoc) {
+ out = new FileWriter(new File(outputDirectory, binPackageName + "-doc.doc-base"));
+ Velocity.mergeTemplate("java-doc.doc-base.vm", "UTF8", context, out);
+ out.flush();
+ out.close();
+
+ out = new FileWriter(new File(outputDirectory, binPackageName + "-doc.docs"));
+ Velocity.mergeTemplate(javadocsTemplate, "UTF8", context, out);
+ out.flush();
+ out.close();
+ }
+
+ if ("ant".equals(packageType)) {
+ out = new FileWriter(new File(outputDirectory, "build.properties"));
+ Velocity.mergeTemplate("build.properties.ant.vm", "UTF8", context, out);
+ out.flush();
+ out.close();
+ } else {
+ out = new FileWriter(new File(outputDirectory, "maven.properties"));
+ Velocity.mergeTemplate("maven.properties.vm", "UTF8", context, out);
+ out.flush();
+ out.close();
+ }
+
+ out = new FileWriter(new File(outputDirectory, "control"));
+ Velocity.mergeTemplate(controlTemplate, "UTF8", context, out);
+ out.flush();
+ out.close();
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private List listSharedJars(String library) {
+ final List jars = new ArrayList();
+ DependenciesSolver.executeProcess(new String[]{"/usr/bin/dpkg", "--listfiles", library},
+ new DependenciesSolver.OutputHandler() {
+
+ public void newLine(String line) {
+ if (line.startsWith("/usr/share/java/") && line.endsWith(".jar")) {
+ String jar = line.substring("/usr/share/java/".length());
+ jar = jar.substring(0, jar.length() - 4);
+ if (!line.matches(".*/.*-\\d.*")) {
+ jars.add(jar);
+ }
+ }
+ }
+ });
+ return jars;
+ }
+
+ private List split(String s) {
+ List l = new ArrayList();
+ StringTokenizer st = new StringTokenizer(s, ",");
+ while (st.hasMoreTokens()) {
+ l.add(st.nextToken().trim());
+ }
+ return l;
+ }
+
+ private void makeExecutable(String file) {
+ DependenciesSolver.executeProcess(new String[]{"chmod", "+x", file}, new DependenciesSolver.NoOutputHandler());
+ }
+
+ interface DownloadType {
+
+ int UNKNOWN = 0;
+ int SVN = 1;
+ int CVS = 2;
+ int TARBALL = 3;
+ }
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/README.source.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/README.source.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/README.source.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,9 @@
+Information about ${package}
+------------------------------
+
+This package was debianized using the mh_make command
+from the maven-debian-helper package.
+
+The build system uses Maven but prevent it from downloading
+anything from the Internet, making the build compliant with
+the Debian policy.
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/build.properties.ant.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/build.properties.ant.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/build.properties.ant.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,5 @@
+build.directory=target
+javadoc.dir=target/docs/api
+#if(!$runTests)
+maven.test.skip=true
+#end
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/compat.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/compat.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/compat.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1 @@
+7
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,68 @@
+#set ($dollar = "$")
+#set ($space = " ")
+#macro(printDependencies $dependencies)
+#set ($lineLength=0)
+#foreach ($dependency in $dependencies)
+#if($lineLength==0)${space}#end${dependency}#if($velocityHasNext), #end
+#set ($lineLength = $lineLength + $dependency.length() + 2)
+#if ($lineLength > 70)
+$space
+#set ($lineLength=0)
+#end
+#end
+#end
+Source: ${package}
+Section: java
+Priority: optional
+Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
+Uploaders: ${packager} <${packagerEmail}>
+Build-Depends: debhelper (>= 7), cdbs, default-jdk, ant-optional, maven-ant-helper (>> 4)
+Build-Depends-Indep: maven-repo-helper,
+#printDependencies($compileDependencies)
+Standards-Version: 3.8.2
+Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/${package}
+Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}/
+Homepage:#if(${project.Url}) ${project.Url} #else TODO #end
+
+
+Package: ${binPackage}
+Architecture: all
+## libraries should not depend on runtime - default-jre-headless | java2-runtime-headless,
+Depends: ${dollar}{misc:Depends},
+#printDependencies($runtimeDependencies)
+#if(!$optionalDependencies.isEmpty())
+Recommends: #printDependencies($optionalDependencies)
+#fi
+Description:#if ($description.isEmpty()) TODO - fill the description #else $description.get(0) #end
+#foreach ($line in $description)
+#if ($velocityCount > 1)
+ #if ($line == "")
+ .
+ #else
+ $line
+ #end
+#end
+#end
+
+
+#if ($generateJavadoc)
+Package: ${binPackage}-doc
+Architecture: all
+Section: doc
+Depends: ${dollar}{misc:Depends}
+Suggests: ${binPackage}
+Description: Documentation for ${project.Name}
+#if ($description.isEmpty()) TODO - fill the description #else $description.get(0) #end
+#foreach ($line in $description)
+#if ($velocityCount > 1)
+ #if ($line == "")
+ .
+ #else
+ $line
+ #end
+#end
+#end
+
+ .
+ This package provides the API documentation for ${binPackage}.
+#end
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,66 @@
+#set ($dollar = "$")
+#set ($space = " ")
+#macro(printDependencies $dependencies)
+#set ($lineLength=0)
+#foreach ($dependency in $dependencies)
+#if($lineLength==0)${space}#end${dependency}#if($velocityCount<$dependencies.size()), #else
+$space
+#end
+#set ($lineLength = $lineLength + $dependency.length() + 2)
+#if ($lineLength > 70)
+$space
+#set ($lineLength=0)
+#end
+#end
+#end
+Source: ${package}
+Section: java
+Priority: optional
+Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
+Uploaders: ${packager} <${packagerEmail}>
+Build-Depends: debhelper (>= 7), cdbs, default-jdk, maven-debian-helper
+Build-Depends-Indep: #printDependencies($compileDependencies)
+Standards-Version: 3.8.2
+Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/${package}
+Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}/
+Homepage:#if(${project.Url}) ${project.Url} #else TODO #end
+
+
+Package: ${binPackage}
+Architecture: all
+## libraries should not depend on runtime - default-jre-headless | java2-runtime-headless,
+Depends: ${dollar}{misc:Depends}, ${dollar}{maven:Depends}
+Recommends: ${dollar}{maven:OptionalDepends}
+Description:#if ($description.isEmpty()) TODO - fill the description #else $description.get(0) #end
+#foreach ($line in $description)
+#if ($velocityCount > 1)
+ #if ($line == "")
+ .
+ #else
+ $line
+ #end
+#end
+#end
+
+
+#if ($generateJavadoc)
+Package: ${binPackage}-doc
+Architecture: all
+Section: doc
+Depends: ${dollar}{misc:Depends}
+Suggests: ${binPackage}
+Description: Documentation for ${project.Name}
+#if ($description.isEmpty()) TODO - fill the description #else $description.get(0) #end
+#foreach ($line in $description)
+#if ($velocityCount > 1)
+ #if ($line == "")
+ .
+ #else
+ $line
+ #end
+#end
+#end
+
+ .
+ This package provides the API documentation for ${binPackage}.
+#end
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,79 @@
+#set ($space = " ")
+Format-Specification: http://dep.debian.net/deps/dep5/
+Name: ${project.Name}
+Maintainer: ${project.Organization.Name}
+Source: ${project.Url}
+
+Files: *
+#set ($copyrightHeader = "Copyright: ")
+#foreach ($developer in $project.Developers)
+${copyrightHeader} ${copyrightYear}, ${developer.Name} #if (${developer.Email})<${developer.Email}>
+#set ($copyrightHeader = " ")
+#else $space
+#end
+#end
+#foreach ($contributor in $project.Contributors)
+${copyrightHeader} ${copyrightYear}, ${contributor.Name} #if (${contributor.Email})<${contributor.Email}>
+#set ($copyrightHeader = " ")
+#else $space
+#end
+#end
+#set ($knownLicenses = ["Apache-2.0", "BSD", "GFDL-1.2", "GPL-2", "LGPL-2.1", "Artistic", "GPL-3", "LGPL-2", "LGPL-3"])
+#foreach ($license in $project.Licenses)
+#set ($licenseName = "")
+#if ($license.Name)#set ($licenseName = $license.Name.toLowerCase() + " ")#end
+#set ($licenseUrl = "")
+#if ($license.Url)#set ($licenseUrl = $license.Url.toLowerCase())#end
+#if ($licenseName.indexOf("mit ") >= 0 || $licenseUrl.indexOf("mit-license") >= 0)
+#set ($x = $licenses.add("MIT"))
+#elseif ($licenseName.indexOf("bsd ") >= 0 || $licenseUrl.indexOf("bsd-license") >= 0)
+#set ($x = $licenses.add("BSD"))
+#elseif ($licenseName.indexOf("artistic ") >= 0 || $licenseUrl.indexOf("artistic-license") >= 0)
+#set ($x = $licenses.add("Artistic"))
+#elseif ($licenseName.indexOf("apache ") >= 0 || $licenseUrl.indexOf("apache") >= 0)
+#if ($licenseName.indexOf("2.") >= 0 || $licenseUrl.indexOf("2.") >= 0)
+#set ($x = $licenses.add("Apache-2.0"))
+#end
+#elseif ($licenseName.indexOf("lgpl ") >= 0 || $licenseUrl.indexOf("lgpl") >= 0)
+#if ($licenseName.indexOf("2.1") >= 0 || $licenseUrl.indexOf("2.1") >= 0)
+#set ($x = $licenses.add("LGPL-2.1"))
+#elseif ($licenseName.indexOf("2") >= 0 || $licenseUrl.indexOf("2") >= 0)
+#set ($x = $licenses.add("LGPL-2"))
+#elseif ($licenseName.indexOf("3") >= 0 || $licenseUrl.indexOf("3") >= 0)
+#set ($x = $licenses.add("LGPL-2"))
+#end
+#elseif ($licenseName.indexOf("gpl ") >= 0 || $licenseUrl.indexOf("gpl") >= 0)
+#if ($licenseName.indexOf("2") >= 0 || $licenseUrl.indexOf("2") >= 0)
+#set ($x = $licenses.add("GPL-2"))
+#elseif ($licenseName.indexOf("3") >= 0 || $licenseUrl.indexOf("3") >= 0)
+#set ($x = $licenses.add("GPL-3"))
+#else
+#if ($licenseName)#set ($x = $licenses.add("$licenseName"))
+#elseif($licenseUrl)#set ($x = $licenses.add("$licenseUrl"))
+#else#set ($x = $licenses.add("UNKNOWN-LICENSE"))
+#end
+#end
+#end
+#end
+#if ($licenses.isEmpty())
+#set ($x = $licenses.add("NOT-FOUND"))
+#end
+License: #foreach($license in $licenses)${license}#if($velocityHasNext) or #end#end
+
+
+Files: debian/*
+Copyright: Copyright ${currentYear}, ${packager} <${packagerEmail}>
+License: ${packagerLicense}
+#set ($x = $licenses.add("${packagerLicense}"))
+
+#foreach ($license in $licenses)
+License: $license
+#if ($knownLicenses.contains($license))
+ On Debian GNU/Linux system you can find the complete text of the
+ $license license in '/usr/share/common-licenses/$license'
+#else
+ TODO: include the full license text here
+#end
+
+#end
+
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/java-doc.doc-base.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/java-doc.doc-base.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/java-doc.doc-base.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,10 @@
+Document: ${binPackage}
+Title: API Javadoc for ${project.Name}
+Author: ${project.Organization.Name} developers
+Abstract: This is the API Javadoc provided for the
+ ${binPackage} library.
+Section: Programming
+
+Format: HTML
+Index: /usr/share/doc/${binPackage}-doc/api/index.html
+Files: /usr/share/doc/${binPackage}-doc/api/*
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/java-doc.docs.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/java-doc.docs.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/java-doc.docs.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1 @@
+target/docs/api
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.properties.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.properties.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.properties.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,3 @@
+#if(!$runTests)
+maven.test.skip=true
+#end
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/orig-tar.svn.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/orig-tar.svn.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/orig-tar.svn.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,17 @@
+#!/bin/sh -e
+
+VERSION=$2
+TAR=../${package}_$VERSION.orig.tar.gz
+DIR=${package}-$VERSION
+TAG=$(echo "${tagMarker}$VERSION" | sed -re's/~(alpha|beta)/-\1-/')
+
+svn export ${baseUrl}/${TAG}${suffixUrl} $DIR
+tar -c -z -f $TAR $DIR
+rm -rf $DIR ../$TAG
+
+# move to directory 'tarballs'
+if [ -r .svn/deb-layout ]; then
+ . .svn/deb-layout
+ mv $TAR $origDir
+ echo "moved $TAR to $origDir"
+fi
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.ant.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.ant.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.ant.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,36 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/ant.mk
+#macro(printJars $jars)
+#set ($lineLength=0)
+#foreach ($jar in $jars)
+#if($lineLength==0)${space}#end${jar}#if($velocityHasNext), #end
+#set ($lineLength = $lineLength + $jar.length() + 2)
+#if ($lineLength > 70)
+$space
+#set ($lineLength=0)
+#end
+#end
+#end
+
+PACKAGE := $(DEB_SOURCE_PACKAGE)
+VERSION := $(DEB_UPSTREAM_VERSION)
+JAVA_HOME := /usr/lib/jvm/default-java
+DEB_JARS := ant-nodeps#if (!$buildJars.isEmpty()),#end
+#printJars($buildJars)
+DEB_ANT_BUILDFILE := /usr/share/maven-ant-helper/maven-build.xml
+DEB_ANT_ARGS := -Dbasedir=$(realpath .) -Dpackage=$(PACKAGE) -Dversion=$(VERSION)
+
+get-orig-source:
+ uscan --download-version $(DEB_UPSTREAM_VERSION) --force-download --rename
+
+binary-post-install/lib$(PACKAGE)-java::
+ mh_installpoms -plib$(PACKAGE)-java
+#foreach ( $dir in $pomDirs )
+#if ($dir != '') #set ($dir = '$dir/') #end
+ mh_installjar -plib$(PACKAGE)-java -l ${dir}pom.xml ${dir}target/$(PACKAGE)-$(VERSION).jar
+#end
+
+clean::
+ -rm -rf debian/tmp
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,9 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/maven.mk
+
+JAVA_HOME := /usr/lib/jvm/default-java
+
+get-orig-source:
+ uscan --download-version $(DEB_UPSTREAM_VERSION) --force-download --rename
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/version.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/version.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/version.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1 @@
+$debianVersion
\ No newline at end of file
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/watch.svn.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/watch.svn.vm (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/watch.svn.vm 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,4 @@
+version=3
+opts="uversionmangle=s/-(alpha|beta)-/~$1/" \
+ ${baseUrl}/ \
+ ${tagMarker}(\d.*)/ debian debian/orig-tar.sh
Added: trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,111 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.debian.maven.packager;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import junit.framework.TestCase;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+
+/**
+ *
+ * @author ludo
+ */
+public class DependenciesSolverTest extends TestCase {
+
+ private File testDir = new File("tmp");
+ private File pomFile = new File(testDir, "pom.xml");
+ private List openedReaders = new ArrayList();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ testDir.mkdir();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ for (Iterator i = openedReaders.iterator(); i.hasNext(); ) {
+ Reader reader = (Reader) i.next();
+ try {
+ reader.close();
+ } catch (IOException ex) {
+ Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ openedReaders.clear();
+ FileUtils.deleteDirectory(testDir);
+ }
+
+ /**
+ * Test of solveDependencies method, of class DependenciesSolver.
+ */
+ public void testSolveDependencies() throws Exception {
+ useFile("plexus-active-collections.pom", pomFile);
+ DependenciesSolver solver = new DependenciesSolver();
+ solver.setBaseDir(testDir);
+ solver.setOutputDirectory(testDir);
+ solver.setExploreProjects(true);
+ solver.setPackageName("libplexus-active-collections-java");
+ solver.setPackageType("maven");
+
+ solver.solveDependencies();
+
+ assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
+
+ solver.saveListOfPoms();
+ solver.saveMavenRules();
+ solver.saveSubstvars();
+
+ assertFileEquals("libplexus-active-collections-java.poms", "libplexus-active-collections-java.poms");
+ assertFileEquals("libplexus-active-collections-java.substvars", "libplexus-active-collections-java.substvars");
+ assertFileEquals("libplexus-active-collections-java.rules", "maven.rules");
+ }
+
+ protected void assertFileEquals(String resource, String fileName) throws Exception {
+ File file = new File(testDir, fileName);
+ assertTrue(file.exists());
+ LineNumberReader fileReader = new LineNumberReader(new FileReader(file));
+ LineNumberReader refReader = new LineNumberReader(read(resource));
+
+ while (true) {
+ String test = fileReader.readLine();
+ String ref = refReader.readLine();
+ if (ref == null) {
+ return;
+ }
+ if (ref.startsWith("#")) {
+ continue;
+ }
+ assertEquals("Error in " + fileName, ref, test);
+ }
+ }
+
+ protected void useFile(String resource, File file) throws IOException {
+ final FileWriter out = new FileWriter(file);
+ final Reader in = read(resource);
+ IOUtils.copy(in,out);
+ in.close();
+ out.close();
+ }
+
+ protected Reader read(String resource) {
+ Reader r = new InputStreamReader(this.getClass().getResourceAsStream("/" + resource));
+ openedReaders.add(r);
+ return r;
+ }
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.poms
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.poms (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.poms 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1 @@
+pom.xml --no-parent
Added: trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.rules
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.rules (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.rules 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,2 @@
+junit junit jar s/3\..*/3.x/
+org.codehaus.plexus plexus-maven-plugin maven-plugin s/.*/1.3.8/
Added: trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.substvars
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.substvars (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.substvars 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,6 @@
+#List of dependencies for libplexus-active-collections-java, generated for use by debian/control
+#Wed Jun 24 22:57:35 BST 2009
+maven.CompileDepends=libplexus-maven-plugin-java (>\= 1.3.8), libsurefire-java (>\= 2.4.3)
+maven.Depends=libplexus-component-api-java, libplexus-containers-java
+maven.OptionalDepends=
+maven.TestDepends=junit
Added: trunk/maven-debian-helper/maven-packager-utils/src/test/resources/plexus-active-collections.pom
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/resources/plexus-active-collections.pom (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/resources/plexus-active-collections.pom 2009-07-14 21:01:22 UTC (rev 9344)
@@ -0,0 +1,81 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>plexus-components</artifactId>
+ <groupId>org.codehaus.plexus</groupId>
+ <version>1.1.6</version>
+ </parent>
+
+ <artifactId>plexus-active-collections</artifactId>
+ <version>1.0-beta-2</version>
+ <name>Plexus Container-Backed Active Collections</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ <version>1.0-beta-2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0-beta-2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/TestComponent.java</exclude>
+ <exclude>**/TestBadComponent.java</exclude>
+ <exclude>**/*TCK.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-maven-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <id>create-component-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ <!--
+ <execution>
+ <id>merge</id>
+ <configuration>
+ <output>${project.build.outputDirectory}/META-INF/plexus/components.xml</output>
+ <descriptors>
+ <descriptor>${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml</descriptor>
+ <descriptor>src/main/resources/META-INF/plexus/components.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>merge-descriptors</goal>
+ </goals>
+ </execution>
+ -->
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <scm>
+ <connection>scm:svn:http://svn.codehaus.org/plexus/tags/plexus-active-collections-1.0-beta-2</connection>
+ <developerConnection>scm:svn:https://svn.codehaus.org/plexus/tags/plexus-active-collections-1.0-beta-2</developerConnection>
+ </scm>
+</project>
\ No newline at end of file
Modified: trunk/maven-debian-helper/pom.xml
===================================================================
--- trunk/maven-debian-helper/pom.xml 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/pom.xml 2009-07-14 21:01:22 UTC (rev 9344)
@@ -11,15 +11,24 @@
<modules>
<module>maven-debian-helper</module>
<module>maven-debian-plugin</module>
+ <module>maven-packager-utils</module>
</modules>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
- <version>2.0.9</version>
- <scope>system</scope>
- <systemPath>/usr/share/java/maven2.jar</systemPath>
+ <version>2.2.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>2.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.5.8</version>
+ </dependency>
</dependencies>
</project>
Modified: trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk
===================================================================
--- trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk 2009-07-14 21:01:22 UTC (rev 9344)
@@ -26,10 +26,16 @@
ifndef _cdbs_class_maven_vars
_cdbs_class_maven_vars = 1
+# Declare Build-Deps for packages using this file
+CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), cdbs (>= 0.4.43)
+CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), maven-debian-helper (>> 0.3)
+
# Maven home directory. Doesn't need to be changed except when using
# nonstandard Maven installations.
MAVEN_HOME = /usr/share/maven2
+MAVEN_DEBIAN_VERSION = 0.4
+
# The home directory of the Java Runtime Environment (JRE) or Java Development
# Kit (JDK). You can either directly set JAVA_HOME in debian/rules or set
# JAVA_HOME_DIRS to multiple possible home directories. The first existing
@@ -77,13 +83,19 @@
# first package by default.
DEB_JAR_PACKAGE = $(firstword $(shell dh_listpackages))
+# The name of the package containing the documentation. The second package
+# by default. Leave empty to skip generating documentation.
+DEB_DOC_PACKAGE = $(word 2, $(shell dh_listpackages))
+
# Targets to invoke for building, installing, testing and cleaning up.
# Building uses the default target from build.xml, installing and testing is
# only called if the corresponding variable is set. You can also specify
# multiple targets for each step.
DEB_MAVEN_BUILD_TARGET = package
-DEB_MAVEN_INSTALL_TARGET = debian:install
+DEB_MAVEN_INSTALL_TARGET = org.debian.maven:maven-debian-plugin:$(MAVEN_DEBIAN_VERSION):install
DEB_MAVEN_CHECK_TARGET =
DEB_MAVEN_CLEAN_TARGET = clean
+DEB_MAVEN_DOC_TARGET = javadoc:jar
+DEB_MAVEN_INSTALL_DOC_TARGET = org.debian.maven:maven-debian-plugin:$(MAVEN_DEBIAN_VERSION):install-doc
endif
Modified: trunk/maven-debian-helper/share/cdbs/1/class/maven.mk
===================================================================
--- trunk/maven-debian-helper/share/cdbs/1/class/maven.mk 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/share/cdbs/1/class/maven.mk 2009-07-14 21:01:22 UTC (rev 9344)
@@ -32,11 +32,14 @@
DEB_MAVEN_REPO := $(CURDIR)/debian/maven-repo
JAVA_OPTS = \
- $(shell test -n "$(DEB_MAVEN_PROPERTYFILE)" && echo -Dproperties.file.manual=$(DEB_MAVEN_PROPERTYFILE)) \
- -Dproperties.file.auto=$(CURDIR)/debian/auto.properties
+ $(shell test -n "$(DEB_MAVEN_PROPERTYFILE)" && echo -Dproperties.file.manual=$(DEB_MAVEN_PROPERTYFILE))
DEB_PHONY_RULES += maven-sanity-check
+cdbs_use_maven_substvars := $(shell grep -q "{maven:\w*Depends}" debian/control && echo yes)
+cdbs_new_poms_file := $(shell test ! -f debian/$(DEB_JAR_PACKAGE).poms && echo yes)
+cdbs_new_maven_rules_file := $(shell test ! -f debian/maven.rules && echo yes)
+
maven-sanity-check:
@if ! test -x "$(JAVACMD)"; then \
echo "You must specify a valid JAVA_HOME or JAVACMD!"; \
@@ -47,33 +50,69 @@
exit 1; \
fi
-debian/auto.properties:
+debian/$(DEB_JAR_PACKAGE).poms:
+ mh_lspoms -p$(DEB_JAR_PACKAGE)
+
+debian/maven.rules:
+ mh_lspoms -p$(DEB_JAR_PACKAGE) --force
+
+debian/stamp-poms-patched:
+ mh_patchpoms -p$(DEB_JAR_PACKAGE) --keep-pom-version
+ touch debian/stamp-poms-patched
+
+patch-poms: debian/$(DEB_JAR_PACKAGE).poms debian/maven.rules debian/stamp-poms-patched
+
+unpatch-poms: debian/$(DEB_JAR_PACKAGE).poms
+ mh_unpatchpoms -p$(DEB_JAR_PACKAGE)
+ rm -f debian/stamp-poms-patched
+
+debian/maven-repo:
/usr/share/maven-debian-helper/copy-repo.sh $(CURDIR)/debian
+post-patches:: patch-poms
+
+clean:: unpatch-poms
+
common-build-arch common-build-indep:: debian/stamp-maven-build maven-sanity-check
-debian/stamp-maven-build: debian/auto.properties
+debian/stamp-maven-build: debian/maven-repo
$(DEB_MAVEN_INVOKE) $(DEB_MAVEN_BUILD_TARGET)
touch $@
-cleanbuilddir:: maven-sanity-check apply-patches debian/auto.properties
+cleanbuilddir:: maven-sanity-check post-patches debian/maven-repo
-$(DEB_MAVEN_INVOKE) $(DEB_MAVEN_CLEAN_TARGET)
- $(RM) -r debian/auto.properties $(DEB_MAVEN_REPO) debian/stamp-maven-build
+ $(RM) -r $(DEB_MAVEN_REPO) debian/stamp-maven-build
+ $(if $(cdbs_new_poms_file), $(RM) debian/$(DEB_JAR_PACKAGE).poms)
+ $(if $(cdbs_new_maven_rules_file), $(RM) debian/maven.rules)
# extra arguments for the installation step
PLUGIN_ARGS = -Ddebian.dir=$(CURDIR)/debian -Ddebian.package=$(DEB_JAR_PACKAGE)
common-install-arch common-install-indep:: common-install-impl
common-install-impl::
- $(if $(DEB_MAVEN_INSTALL_TARGET),$(DEB_MAVEN_INVOKE) $(DEB_MAVEN_INSTALL_TARGET) $(PLUGIN_ARGS), at echo "DEB_MAVEN_INSTALL_TARGET unset, skipping default maven.mk common-install target")
+ $(if $(DEB_MAVEN_INSTALL_TARGET),$(DEB_MAVEN_INVOKE) $(PLUGIN_ARGS) $(DEB_MAVEN_INSTALL_TARGET), at echo "DEB_MAVEN_INSTALL_TARGET unset, skipping default maven.mk common-install target")
+ $(if $(cdbs_use_maven_substvars), mh_resolve_dependencies -p$(DEB_JAR_PACKAGE))
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
common-build-arch common-build-indep:: debian/stamp-maven-check
debian/stamp-maven-check: debian/stamp-maven-build
- $(if $(DEB_MAVEN_CHECK_TARGET),$(DEB_MAVEN_INVOKE) $(DEB_MAVEN_CHECK_TARGET), at echo "DEB_MAVEN_CHECK_TARGET unset, not running checks")
+ $(if $(DEB_MAVEN_CHECK_TARGET),$(DEB_MAVEN_INVOKE) $(PLUGIN_ARGS) $(DEB_MAVEN_CHECK_TARGET), at echo "DEB_MAVEN_CHECK_TARGET unset, not running checks")
$(if $(DEB_MAVEN_CHECK_TARGET),touch $@)
-clean::
+clean::
$(if $(DEB_MAVEN_CHECK_TARGET),$(RM) debian/stamp-maven-check)
endif
+ifneq (,$(DEB_DOC_PACKAGE))
+common-build-arch common-build-indep:: debian/stamp-maven-doc
+debian/stamp-maven-doc: debian/stamp-maven-build
+ $(if $(DEB_MAVEN_DOC_TARGET),$(DEB_MAVEN_INVOKE) $(PLUGIN_ARGS) $(DEB_MAVEN_DOC_TARGET), at echo "DEB_MAVEN_DOC_TARGET unset, not generating documentation")
+ $(if $(DEB_MAVEN_DOC_TARGET),touch $@)
+
+common-install-impl::
+ $(if $(DEB_MAVEN_INSTALL_DOC_TARGET),$(DEB_MAVEN_INVOKE) $(PLUGIN_ARGS) $(DEB_MAVEN_INSTALL_DOC_TARGET), at echo "DEB_MAVEN_INSTALL_DOC_TARGET unset, skipping documentation maven.mk common-install target")
+
+clean::
+ $(if $(DEB_MAVEN_DOC_TARGET),$(RM) debian/stamp-maven-doc)
endif
+
+endif
Modified: trunk/maven-debian-helper/share/maven-debian-helper/copy-repo.sh
===================================================================
--- trunk/maven-debian-helper/share/maven-debian-helper/copy-repo.sh 2009-07-14 18:19:12 UTC (rev 9343)
+++ trunk/maven-debian-helper/share/maven-debian-helper/copy-repo.sh 2009-07-14 21:01:22 UTC (rev 9344)
@@ -19,10 +19,6 @@
sed -e's,#.*,,' $CONFFILES
}
-find_dest_poms() {
- find -L $DEST_REPO -name '*.pom' -printf '%P\n'
-}
-
find_all_meta() {
find $DEST_REPO -name 'maven-metadata-tmp.xml'
}
@@ -89,16 +85,6 @@
.EOF
done
-find_dest_poms | while read POM; do
- VER_DIR=$(dirname $POM)
- VERSION=$(basename $VER_DIR)
- BASEDIR=$(dirname $VER_DIR)
- VER_TAG=" <version>$VERSION</version>"
- echo "$VER_TAG" >> $DEST_REPO/$BASEDIR/maven-metadata-tmp.xml
- KEY=$(echo $BASEDIR | tr / .)
- echo "$KEY.version = $VERSION"
-done > $1/auto.properties
-
find_all_meta | while read META; do
DIR=$(dirname $META)
echo_meta > $DIR/maven-metadata-local.xml
More information about the pkg-java-commits
mailing list