[pkg-java] r12602 - in trunk/maven-repo-helper: . debian src/main/bin src/main/java/org/debian/maven/repo src/main/share src/test/java/org/debian/maven/repo src/test/resources

Ludovic Claude ludovicc-guest at alioth.debian.org
Sun Jun 20 19:51:09 UTC 2010


Author: ludovicc-guest
Date: 2010-06-20 19:51:03 +0000 (Sun, 20 Jun 2010)
New Revision: 12602

Added:
   trunk/maven-repo-helper/debian/README.Debian
   trunk/maven-repo-helper/src/main/bin/mh_clean
   trunk/maven-repo-helper/src/main/bin/mh_linkrepojar
   trunk/maven-repo-helper/src/main/bin/mh_patchpom
   trunk/maven-repo-helper/src/test/resources/hibernate-validator.cleaned
   trunk/maven-repo-helper/src/test/resources/hibernate-validator.pom
Modified:
   trunk/maven-repo-helper/debian/changelog
   trunk/maven-repo-helper/debian/control
   trunk/maven-repo-helper/debian/rules
   trunk/maven-repo-helper/pom.xml
   trunk/maven-repo-helper/src/main/bin/mh_cleanpom
   trunk/maven-repo-helper/src/main/bin/mh_installjar
   trunk/maven-repo-helper/src/main/bin/mh_installpom
   trunk/maven-repo-helper/src/main/bin/mh_installpoms
   trunk/maven-repo-helper/src/main/bin/mh_linkjar
   trunk/maven-repo-helper/src/main/bin/mh_patchpoms
   trunk/maven-repo-helper/src/main/bin/mh_unpatchpoms
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMTransformer.java
   trunk/maven-repo-helper/src/main/share/mh_lib.sh
   trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMCleanerTest.java
   trunk/maven-repo-helper/src/test/resources/antlr3-tools.transformed
Log:
* New release



Added: trunk/maven-repo-helper/debian/README.Debian
===================================================================
--- trunk/maven-repo-helper/debian/README.Debian	                        (rev 0)
+++ trunk/maven-repo-helper/debian/README.Debian	2010-06-20 19:51:03 UTC (rev 12602)
@@ -0,0 +1,205 @@
+
+This package contains some essential tools for building Debian packages where upstream uses Maven as its build tool,
+or where upstream uses another build tool (Ant...) but you want to deploy the jars into the Debian Maven repository
+at /usr/share/maven-repo with the necessary metadata - in Maven terms, POM files - and make them available to other
+projects.
+
+== The Debian Maven repository ==
+
+/usr/share/maven-repo contains a Maven-compatible repository but entirely managed by Debian.
+
+One differenciating feature of this repository is that you will find for most artifacts only 2 versions: one current version, and a 
+symbolic version, usually named 'debian'. The reason for this is simple: the Debian project tries to keep the number of versions
+for its libraries to its minimum, that's in order to ease the maintenance burden and make upgrades of shared libraries easier.
+So that's why there is usually one current version of the library. The symbolic (or debian) version of the library is there in
+order to minimize the amount of change when one library is updated.
+
+This leads to another feature of the repository: the POM files are stripped of some elements, like <build> tags with the details
+of the build process - this is similar to what is done in Maven Central, but if you look at the versions in the <dependency> section,
+you will notice that most of them point to a symbolic 'debian' version (or 2.x or similar). The reason for this is simple:
+if the dependency is updated, its symbolic version will stay the same but the jar itself will be updated. As we point already
+to this symbolic version, then we see no change and that means that upgrading one package will not force upgrades of the packages
+using it. 
+Note: In Maven 3.0, the support for version ranges should start to work well, so it will be possible to replace the version in the
+dependency by a version range to achieve a similar effect (easy upgrades) and be even more compatible with upstream Maven.
+
+There are other changes made to the POM files. For example, some properties are inserted in the POM:
+  - debian.originalVersion: to keep track of the original version of the artifact
+  - debian.package: the name of the Debian package containing the artifact. Used by mh_make
+  - debian.mavenRules: the substitution rules applied on the groupId, artifactId and version of this artifact. Used by mh_make
+
+A tool is provided, mh_checkrepo, which checks the consistency of the Maven repository and it's useful to run it from time to time
+when you are packaging software, the goal is to keep the number of errors and warnings low.
+
+== Installing artifacts in the Debian Maven repository ==
+
+mh_installjar and mh_installpoms are the main tools to use when you want to install an artifact and its metadata in the repository.
+They take care of putting the files at the correct locations, maintain the integrity of the repository and cleanup the POM files
+before their inclusion in the repository.
+mh_installpom, mh_linkjar, mh_linkrepojar are also available for some special needs when installing an artifact in the repository.
+The maven.mk CDBS script provided by maven-debian-helper can also install artifacts with the correct transformations to the repository.
+
+To use those tools in your package, use the following templates, or try mh_make (provided by maven-debian-helper) which can build
+most of the packaging control files from the upstream sources with either Maven or Ant as the build system, provided that the POM
+files are present.
+
+* Template debian/rules for installing a single artifact into the Maven repository: 
+=======================
+include /usr/share/cdbs/1/rules/debhelper.mk
+
+PACKAGE := $(DEB_SOURCE_PACKAGE)
+VERSION := $(DEB_UPSTREAM_VERSION)
+
+binary-post-install/lib$(PACKAGE)-java::
+	# Install all POM files registered in debian/$package.pom into /usr/share/maven-repo,
+        mh_installpoms -plib$(PACKAGE)-java
+	# Install the jar file associated with the POM into /usr/share/maven-repo,
+	# The -l option tells it to also add a link to the jar into /usr/share/java, with and without the version (to comply with
+	# the Debian Java packaging guidelines)
+        mh_installjar -plib$(PACKAGE)-java -l pom.xml build/$(PACKAGE)-$(VERSION).jar 
+
+# Cleanup temporary files
+clean::
+        -mh_clean
+=======================
+
+You will need also at least a file called debian/<package>.poms (where <package> is the name of the binary package) and containing:
+=======================
+pom.xml
+=======================
+
+
+* Template debian/rules for installing multiple artifacts into the Maven repository: 
+=======================
+include /usr/share/cdbs/1/rules/debhelper.mk
+
+PACKAGE := $(DEB_SOURCE_PACKAGE)
+VERSION := $(DEB_UPSTREAM_VERSION)
+
+binary-post-install/lib$(PACKAGE)-java::
+	# Install all POM files registered in debian/$package.pom into /usr/share/maven-repo,
+        mh_installpoms -plib$(PACKAGE)-java
+	# Install the jar file associated with the POM into /usr/share/maven-repo,
+	# The -l option tells it to also add a link to the jar into /usr/share/java, with and without the version (to comply with
+	# the Debian Java packaging guidelines)
+        mh_installjar -plib$(PACKAGE)-java -l module1/pom.xml module1/target/module1-$(VERSION).jar 
+        mh_installjar -plib$(PACKAGE)-java -l module2/pom.xml module2/target/module2-$(VERSION).jar 
+
+# Cleanup temporary files
+clean::
+        -mh_clean
+=======================
+
+You will need also at least a file called debian/<package>.poms (where <package> is the name of the binary package) and containing:
+=======================
+# Remove the <parent> tag from the multiproject POM
+pom.xml --no-parent
+module1/pom.xml
+module2/pom.xml
+=======================
+
+* debian/<package>.poms (where <package> is the name of the binary package):
+
+This file lists the POM files in the source tree which need to be installed in the repository, and indicates with the --no-parent option that if the POM inherits from a parent POM, then this inheritance relationship will be removed in the cleaned POM. Removing the parent inheritence can often simplify the packaging, as the parent POM mostly does not contain any useful information - we need only the list of dependencies in our repository, the other details for the build are irrelevant.
+In this file you can also add --ignore after the name of the POM files for each module that you want to ignore. This option is only
+useful when building the package with Maven and the maven.mk CDBS script provided by maven-debian-helper.
+
+Other configuration files are used by mh_installjar and mh_installpoms. All those files are optional.
+
+* debian/maven.rules:
+
+This file contains the substitution rules to apply on any reference to an artifact present on the original POM during the cleanup phase, that is before adding the POM to the Debian Maven repository.
+
+Its syntax is:
+<rule for artifact groupId> <rule for artifact id> <rule for artifact type> <rule for artifact version> [optional rule for artifact classifier]
+
+where a rule can be:
+  * - to match any element and leave it unchanged
+  <a word> - to match that element only and leave it unchanged
+  s/regexp/replacement/ - to match an element with a regexp and replace it. The regexp is in the Java format which is similar to Perl
+       for most cases.
+
+And the following elements of the POM can be affected by those rules:
+- the groupId, artifactId and version for the current POM
+- the <parent> element
+- any <dependency>, <plugin> or <extension> element
+
+For example, this is the content of debian/maven.rules from the modello package:
+
+junit junit jar s/3\..*/3.x/
+
+It specifies that the dependency on junit will use the version '3.x' instead of the default 'debian' version if the native version starts with '3.'. If the group id of the dependency is 'junit, the artifact id of the dependency is 'junit', the type of the dependency is 'jar' and the version starts with '3.', then this rule is used. 's/3\..*/3.x/' performs the replacement for the version, the syntax should be obvious to any sed user.
+
+This example from the commons-configuration package shows a few more possibilities: here, the version for commons-collections is converted to '2.x' if it starts with '2.' or '3.x' if it starts with '3.'. The line with ant is more interesting: if the group id is 'ant', then it is converted to 'org.apache.ant' - great trick for dealing with artifacts which are coming from Maven 1. Any artifact id or type will be matched and left unchanged, while the version will be converted to 'debian'. There is also the line with javax.servlet: this line keeps the version number used by this dependency, so if 2.4 is used, then 2.4 is also used in the cleaned POM.
+
+junit junit jar s/3\..*/3.x/
+commons-collections commons-collections jar s/2\..*/2.x/
+commons-collections commons-collections jar s/3\..*/3.x/
+s/ant/org.apache.ant/ * * s/.*/debian/
+log4j log4j jar s/1\.2\..*/1.2.x/
+javax.servlet servlet-api jar *
+
+* debian/maven.publishedRules:
+
+This file complements debian/maven.rules. The rules defined here are of no immediate use to the package, but they can be useful when
+packaging other libraries related to the current package. The rules listed here will be added to the <debian.mavenRules> property added
+to the cleaned POM stored in the repository. mh_make will read those additional rules, and use them when you are building the Debian
+packaging for an upstream project.
+Typically, those rules are used to help migrate POM files built with the Maven 1 conventions to use the Maven 2 conventions.
+
+For example, in the ant package, debian/maven.publishedRules contains:
+
+s/ant/org.apache.ant/ * * s/.*/debian/
+
+Ant used to have the identifier ant:ant in the Maven 1 repository, instead of org.apache.ant:ant.
+A project B may still use as a dependency on Ant the following:
+
+  <dependency>
+    <groupId>ant</groupId>
+    <artifactId>ant</artifactId>
+    <version>1.2</version>
+  </dependency>
+
+When building the Debian packaging for project B, mh_make will read the published rule
+  s/ant/org.apache.ant/ * * s/.*/debian/
+from the repository (assuming that the ant package is installed). It will then be able to match B's dependency and transform it into:
+
+  <dependency>
+    <groupId>org.apache.ant</groupId>
+    <artifactId>ant</artifactId>
+    <version>debian</version>
+  </dependency>
+
+So now project B can use the version of Ant packaged for Debian.
+
+* debian/maven.ignoreRules:
+
+This file lists the rules which are used to ignore certain dependencies, plugins or extensions present in the upstream POM but that you
+want to ignore in a Debian context. The <parent> element is not affected, but can be removed anyway with the --no-parent option.
+
+The syntax of this file is similar to debian/maven.rules, but more relaxed as we are interested here only in elements that match:
+
+<rule for artifact groupId> [rule for artifact id] [rule for artifact type] [rule for artifact version] [rule for artifact classifier]
+
+Any element, except the first is optional and replaced automatically by * to match anything, but if it omitted then all following
+elements must also be omitted.
+
+For example, debian/maven.ignoreRules from the wagon package contains:
+
+junit junit
+org.apache.maven.wagon wagon-provider-test
+
+It will instruct the mh_* utilities to remove all references to junit and wagon-provider-test from the POM files in the wagon package.
+
+== Typical workflow when using this package ==
+
+   1. sudo apt-get install maven-repo-helper maven-debian-helper
+   2. Get the original sources and unpack them, copy the debian/ folder if you are working on an existing package.
+   3. [optional] mh_lspoms
+   4. [optional] edit debian/$package.poms to check that only the POM that are needed are present, and maybe to fix the --no-parent options
+   5. mh_make --ant
+   6. edit debian/rules (to fix the last remaining packaging details)
+   7. edit debian/control (to add maven-repo-helper to Build-Depends: ) 
+
+
+

Modified: trunk/maven-repo-helper/debian/changelog
===================================================================
--- trunk/maven-repo-helper/debian/changelog	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/debian/changelog	2010-06-20 19:51:03 UTC (rev 12602)
@@ -1,3 +1,20 @@
+maven-repo-helper (1.1) unstable; urgency=low
+
+  * Add mh_patchpom, useful in some situations to patch
+    individual POM files
+  * Add mh_linkrepojar, to create a link from a jar present in the
+    Maven repository
+  * Correctly identify <extension> tag used by Maven (Closes: #584512)
+  * Add documentation for the package and in particular for the syntax
+    of the debian/<package>.poms file (Closes: #586151)
+  * All mh_* scripts now use debian/.mh/ as their temporary work folder
+    instead of debian/tmp, this better satisfies the Debian policies.
+  * Add mh_cleantmp to remove the temporary files produced when using
+    any other mh_* script
+  * Fix typo in package description (Closes: #586573)
+
+ -- Ludovic Claude <ludovic.claude at laposte.net>  Fri, 21 May 2010 00:11:48 +0200
+
 maven-repo-helper (1.0.6) unstable; urgency=low
 
   * Rule.java: harden our handling of version string (from pom.xml)

Modified: trunk/maven-repo-helper/debian/control
===================================================================
--- trunk/maven-repo-helper/debian/control	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/debian/control	2010-06-20 19:51:03 UTC (rev 12602)
@@ -37,4 +37,4 @@
  Packages built with Maven (using maven-debian-helper) will benefit as
  many of their dependencies are already packaged in Debian but they are
  missing the necessary metadata (Maven POM) which is required by Maven
- when its using dependencies.
+ when it is using dependencies.

Modified: trunk/maven-repo-helper/debian/rules
===================================================================
--- trunk/maven-repo-helper/debian/rules	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/debian/rules	2010-06-20 19:51:03 UTC (rev 12602)
@@ -15,27 +15,30 @@
 
 # Generation of man pages
 SCRIPTS       := $(wildcard src/main/bin/mh_*)
-MAN_PAGES     := $(addprefix debian/tmp/doc/,$(addsuffix .1, $(notdir $(SCRIPTS))))
+MAN_PAGES     := $(addprefix debian/.mh/doc/,$(addsuffix .1, $(notdir $(SCRIPTS))))
 mh_checkrepo_description = "Checks the Maven repository."
+mh_clean_description = "Cleans the temporary files created by the other mh_* utilities."
 mh_cleanpom_description = "Cleans a POM file."
 mh_genrules_description = "Generates the debian/rules file with Maven support."
 mh_installjar_description = "Installs a jar into /usr/share/maven-repo."
 mh_installpom_description = "Installs a POM file into /usr/share/maven-repo."
 mh_installpoms_description = "Installs all POMs for the package into /usr/share/maven-repo."
 mh_linkjar_description = "Installs a link to the jar into /usr/share/maven-repo."
+mh_linkrepojar_description = "Installs a link from the jar in /usr/share/maven-repo."
 mh_lspoms_description = "Generates a list of POMs for the package."
+mh_patchpom_description = "Patches one POM file using the Maven dependency rules."
 mh_patchpoms_description = "Patches the POM files using the Maven dependency rules."
 mh_unpatchpoms_description = "Undo the patches on the POM files."
-debian/tmp/mh_lib.sh : src/main/share/mh_lib.sh
-	mkdir -p debian/tmp
-	cp src/main/share/mh_lib.sh debian/tmp/mh_lib.sh
-debian/tmp/mh_% : src/main/bin/mh_% debian/tmp/mh_lib.sh
-	mkdir -p debian/tmp
+debian/.mh/mh_lib.sh : src/main/share/mh_lib.sh
+	mkdir -p debian/.mh
+	cp src/main/share/mh_lib.sh debian/.mh/mh_lib.sh
+debian/.mh/mh_% : src/main/bin/mh_% debian/.mh/mh_lib.sh
+	mkdir -p debian/.mh
 	cp $< $@
-	perl -i -pe 's,\. /usr/share/maven-repo-helper/mh_lib.sh,\. debian/tmp/mh_lib.sh,' $@
+	perl -i -pe 's,\. /usr/share/maven-repo-helper/mh_lib.sh,\. debian/.mh/mh_lib.sh,' $@
 	chmod +x $@
-debian/tmp/doc/mh_%.1 : debian/tmp/mh_% 
-	mkdir -p debian/tmp/doc
+debian/.mh/doc/mh_%.1 : debian/.mh/mh_% 
+	mkdir -p debian/.mh/doc
 	help2man -N -n $(mh_$*_description) -o $@ $<
 man-pages: $(MAN_PAGES)
 build/$(PACKAGE):: man-pages
@@ -47,11 +50,11 @@
 	dh_install -p$(PACKAGE) src/main/share/* /usr/share/$(PACKAGE)
 	dh_link -p$(PACKAGE) /usr/share/maven-repo/org/debian/maven/$(PACKAGE)/debian/$(PACKAGE)-debian.jar /usr/share/java/$(PACKAGE).jar
 	dh_installman $(MAN_PAGES)
-	mkdir -p debian/tmp
-	java -cp $(CLASSPATH) $(JAVA_OPTIONS) org.debian.maven.repo.POMCleaner --no-parent --rules=debian/maven.rules pom.xml debian/tmp/$(PACKAGE)-debian.pom debian/tmp/pom.properties 
-	dh_install -p$(PACKAGE) --sourcedir=debian/tmp $(PACKAGE)-debian.pom \
+	mkdir -p debian/.mh
+	java -cp $(CLASSPATH) $(JAVA_OPTIONS) org.debian.maven.repo.POMCleaner --no-parent --rules=debian/maven.rules pom.xml debian/.mh/$(PACKAGE)-debian.pom debian/.mh/pom.properties 
+	dh_install -p$(PACKAGE) --sourcedir=debian/.mh $(PACKAGE)-debian.pom \
 		usr/share/maven-repo/org/debian/maven/$(PACKAGE)/debian
 
 clean::
-	-rm -rf debian/tmp
+	-rm -rf debian/.mh
 

Modified: trunk/maven-repo-helper/pom.xml
===================================================================
--- trunk/maven-repo-helper/pom.xml	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/pom.xml	2010-06-20 19:51:03 UTC (rev 12602)
@@ -5,7 +5,7 @@
     <artifactId>maven-repo-helper</artifactId>
     <name>Maven Repo helper</name>
     <packaging>jar</packaging>
-    <version>0.6</version>
+    <version>1.1</version>
     <description>Provides support for managing the Maven repository in a Debian distribution.</description>
 
     <inceptionYear>2009</inceptionYear>

Added: trunk/maven-repo-helper/src/main/bin/mh_clean
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_clean	                        (rev 0)
+++ trunk/maven-repo-helper/src/main/bin/mh_clean	2010-06-20 19:51:03 UTC (rev 12602)
@@ -0,0 +1,18 @@
+#!/bin/bash --
+
+set -e
+
+. /usr/share/maven-repo-helper/mh_lib.sh
+
+syntax()
+{
+   echo -e "Usage: mh_clean"
+   echo -e "Cleans the temporary files created by the other mh_* utilities."
+   echo -e ""
+   exit 1
+}
+
+parseargs "$@"
+
+rm -rf debian/.mh
+

Modified: trunk/maven-repo-helper/src/main/bin/mh_cleanpom
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_cleanpom	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/main/bin/mh_cleanpom	2010-06-20 19:51:03 UTC (rev 12602)
@@ -1,5 +1,7 @@
 #!/bin/bash --
 
+set -e
+
 . /usr/share/maven-repo-helper/mh_lib.sh
 
 syntax()
@@ -12,9 +14,9 @@
    echo -e "\t[pom] is the location of the POM file to clean."
    echo -e "\t  Default to pom.xml or debian/pom.xml"
    echo -e "\t[target] is where the cleaned POM is written to."
-   echo -e "\t  Default to debian/tmp/pom.xml"
+   echo -e "\t  Default to debian/.mh/pom.xml"
    echo -e "\t[pom-props] is where the POM properties file will be written."
-   echo -e "\t  Default to debian/tmp/pom.properties"
+   echo -e "\t  Default to debian/.mh/pom.properties"
    echo -e "Options:"
    echo -e "\t-h --help: show this text"
    echo -e "\t-V --version: show the version"
@@ -25,8 +27,6 @@
    echo -e "\t  convert all other versions in dependencies and plugins"
    echo -e "\t-e<version>, --set-version=<version>: set the version for the POM,"
    echo -e "\t  do not use the version declared in the POM file."
-   echo -e "\t-k --keep-all-elements: keep all elements in the POM, do a version"
-   echo -e "\t  transformation only, don't delete the build and other elements."
    echo -e "\t-r<rules> --rules=<rules>: path to the file containing the"
    echo -e "\t  extra rules to apply when cleaning the POM."
    echo -e "\t  Optional, the default location is debian/maven.rules"
@@ -137,8 +137,8 @@
 VERBOSE=$(getarg v verbose)
 NOACT=$(getarg n no-act)
 POM="${ARGV[0]}"
-TARGET="${ARGV[1]:-debian/tmp/pom.xml}"
-POM_PROPS="${ARGV[2]:-debian/tmp/pom.properties}"
+TARGET="${ARGV[1]:-debian/.mh/pom.xml}"
+POM_PROPS="${ARGV[2]:-debian/.mh/pom.properties}"
 
 if [ -z "$POM" ]; then
     if [ -f debian/pom.xml ]; then

Modified: trunk/maven-repo-helper/src/main/bin/mh_installjar
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_installjar	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/main/bin/mh_installjar	2010-06-20 19:51:03 UTC (rev 12602)
@@ -80,14 +80,14 @@
 DH_OPTS="${VERBOSE:+-v} ${NOACT:+-n}"
 CLEAN_ARGS="--package=${PACKAGE} ${SETVERSION:+--set-version=$SETVERSION} ${RULES:+--rules=$RULES}"
 
-mkdir -p debian/tmp 2> /dev/null
+mkdir -p debian/.mh 2> /dev/null
 
 if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
-    echo -e "\tmh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/tmp/pom.xml debian/tmp/pom.properties"
+    echo -e "\tmh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/.mh/pom.xml debian/.mh/pom.properties"
 fi
 
-mh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/tmp/pom.xml debian/tmp/pom.properties
-source debian/tmp/pom.properties
+mh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/.mh/pom.xml debian/.mh/pom.properties
+source debian/.mh/pom.properties
 
 groupPath=$(echo $groupId | tr . / )
 
@@ -146,7 +146,7 @@
 		if [[ -n "$JAR_INSTALLED" ]]; then 
 			return 
 		fi
-		cp ${srcJar} debian/tmp/${destJar}
+		cp ${srcJar} debian/.mh/${destJar}
 		if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
 			echo -e "\tinstall -m 644 -D ${srcJar} debian/${PACKAGE}/${destDir}/${destJar}"
 		fi

Modified: trunk/maven-repo-helper/src/main/bin/mh_installpom
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_installpom	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/main/bin/mh_installpom	2010-06-20 19:51:03 UTC (rev 12602)
@@ -63,35 +63,35 @@
 DH_OPTS="${VERBOSE:+-v} ${NOACT:+-n}"
 CLEAN_ARGS="--package=${PACKAGE} ${VERBOSE:+--verbose} ${NOPARENT:+--no-parent} ${SETVERSION:+--set-version=$SETVERSION} ${RULES:+--rules=$RULES} ${PUBLISHED_RULES:+--published-rules=$PUBLISHED_RULES} ${IGNORE_RULES:+--ignore-rules=$IGNORE_RULES}"
 
-mkdir -p debian/tmp 2> /dev/null
+mkdir -p debian/.mh 2> /dev/null
 
 if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
-    echo -e "\tmh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/tmp/pom.xml debian/tmp/pom.properties"
+    echo -e "\tmh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/.mh/pom.xml debian/.mh/pom.properties"
 fi
 
-mh_cleanpom $DH_OPTS $CLEAN_ARGS --keep-pom-version $POM debian/tmp/pom.xml.keep debian/tmp/pom.properties.keep
-mh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/tmp/pom.xml debian/tmp/pom.properties
-source debian/tmp/pom.properties
+mh_cleanpom $DH_OPTS $CLEAN_ARGS --keep-pom-version $POM debian/.mh/pom.xml.keep debian/.mh/pom.properties.keep
+mh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/.mh/pom.xml debian/.mh/pom.properties
+source debian/.mh/pom.properties
 
 groupPath=$(echo $groupId | tr . / )
 
 if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
-    echo -e "\tmv debian/tmp/pom.xml debian/tmp/${artifactId}-${debianVersion}.pom"
+    echo -e "\tmv debian/.mh/pom.xml debian/.mh/${artifactId}-${debianVersion}.pom"
 fi
 
-mv debian/tmp/pom.xml.keep debian/tmp/${artifactId}-${version}.pom
-mv debian/tmp/pom.xml debian/tmp/${artifactId}-${debianVersion}.pom
+mv debian/.mh/pom.xml.keep debian/.mh/${artifactId}-${version}.pom
+mv debian/.mh/pom.xml debian/.mh/${artifactId}-${debianVersion}.pom
 
 if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
-    echo -e "\tinstall -m 644 -D debian/tmp/${artifactId}-${version}.pom debian/${PACKAGE}/usr/share/maven-repo/${groupPath}/${artifactId}/${version}/${artifactId}-${version}.pom"
+    echo -e "\tinstall -m 644 -D debian/.mh/${artifactId}-${version}.pom debian/${PACKAGE}/usr/share/maven-repo/${groupPath}/${artifactId}/${version}/${artifactId}-${version}.pom"
 fi
 
-install -m 644 -D debian/tmp/${artifactId}-${version}.pom debian/${PACKAGE}/usr/share/maven-repo/${groupPath}/${artifactId}/${version}/${artifactId}-${version}.pom
+install -m 644 -D debian/.mh/${artifactId}-${version}.pom debian/${PACKAGE}/usr/share/maven-repo/${groupPath}/${artifactId}/${version}/${artifactId}-${version}.pom
 
 if [[ "${version}" != "${debianVersion}" ]]; then
     if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
-        echo -e "\tinstall -m 644 -D debian/tmp/${artifactId}-${debianVersion}.pom debian/${PACKAGE}/usr/share/maven-repo/${groupPath}/${artifactId}/${debianVersion}/${artifactId}-${debianVersion}.pom"
+        echo -e "\tinstall -m 644 -D debian/.mh/${artifactId}-${debianVersion}.pom debian/${PACKAGE}/usr/share/maven-repo/${groupPath}/${artifactId}/${debianVersion}/${artifactId}-${debianVersion}.pom"
     fi
 
-    install -m 644 -D debian/tmp/${artifactId}-${debianVersion}.pom debian/${PACKAGE}/usr/share/maven-repo/${groupPath}/${artifactId}/${debianVersion}/${artifactId}-${debianVersion}.pom
+    install -m 644 -D debian/.mh/${artifactId}-${debianVersion}.pom debian/${PACKAGE}/usr/share/maven-repo/${groupPath}/${artifactId}/${debianVersion}/${artifactId}-${debianVersion}.pom
 fi

Modified: trunk/maven-repo-helper/src/main/bin/mh_installpoms
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_installpoms	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/main/bin/mh_installpoms	2010-06-20 19:51:03 UTC (rev 12602)
@@ -46,11 +46,17 @@
 DH_OPTS="${VERBOSE:+-v} ${NOACT:+-n}"
 MH_ARGS="--package=${PACKAGE} ${VERBOSE:+--verbose} ${SETVERSION:+--set-version=$SETVERSION} ${RULES:+--rules=$RULES} ${PUBLISHED_RULES:+--published-rules=$PUBLISHED_RULES} ${IGNORE_RULES:+--ignore-rules=$IGNORE_RULES}"
 
-cat debian/$PACKAGE.poms | while read POM OPT1 OPT2; do
-    if [ ! -z "$POM" ]; then
-        if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
+if [ -z "$NOACT" ]; then
+    cat debian/$PACKAGE.poms | while read POM OPT1 OPT2; do
+        # Remove comments
+        POM=${POM##\#*}
+        if [[ ! -z "$POM" ]]; then
+            if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
 	        echo -e "\tmh_installpom $DH_OPTS $MH_ARGS $OPT1 $OPT2 $POM"
-		fi
-        mh_installpom $DH_OPTS $MH_ARGS $OPT1 $OPT2 $POM
-    fi
-done
+            fi
+            if [[ ! "--ignore" == "$OPT1" ]]; then
+                mh_installpom $DH_OPTS $MH_ARGS $OPT1 $OPT2 $POM
+            fi
+        fi
+    done
+fi

Modified: trunk/maven-repo-helper/src/main/bin/mh_linkjar
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_linkjar	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/main/bin/mh_linkjar	2010-06-20 19:51:03 UTC (rev 12602)
@@ -71,14 +71,14 @@
 DH_OPTS="${VERBOSE:+-v} ${NOACT:+-n}"
 CLEAN_ARGS="--package=${PACKAGE} ${RULES:+--rules=$RULES}"
 
-mkdir -p debian/tmp 2> /dev/null
+mkdir -p debian/.mh 2> /dev/null
 
 if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
-    echo -e "\tmh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/tmp/pom.xml debian/tmp/pom.properties"
+    echo -e "\tmh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/.mh/pom.xml debian/.mh/pom.properties"
 fi
 
-mh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/tmp/pom.xml debian/tmp/pom.properties
-source debian/tmp/pom.properties
+mh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/.mh/pom.xml debian/.mh/pom.properties
+source debian/.mh/pom.properties
 
 groupPath=$(echo $groupId | tr . / )
 

Added: trunk/maven-repo-helper/src/main/bin/mh_linkrepojar
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_linkrepojar	                        (rev 0)
+++ trunk/maven-repo-helper/src/main/bin/mh_linkrepojar	2010-06-20 19:51:03 UTC (rev 12602)
@@ -0,0 +1,91 @@
+#!/bin/bash --
+
+set -e
+
+. /usr/share/maven-repo-helper/mh_lib.sh
+
+syntax()
+{
+   echo -e "Usage: mh_linkrepojar [option]... [pom] [link]..."
+   echo -e "Create symlinks from the jar in the Maven repository to any location,"
+   echo -e "usually to a file located in /usr/share/java."
+   echo -e ""
+   echo -e "Where"
+   echo -e "\t[pom] is the location of the POM associated with the jar to install."
+   echo -e "\t  GroupId, artifactId and version will be extracted from this file."
+   echo -e "\t[link] is a link to the jar to install, usually there should"
+   echo -e "\t  be a link to usr/share/java/$jar.jar and"
+   echo -e "\t  usr/share/java/$jar-$version.jar to comply with the Java packaging"
+   echo -e "\t  guidelines. Note that there is no need to specify those particular"
+   echo -e "\t  links if the --java-lib option is used."
+   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-r<rules> --rules=<rules>: gives the location of the rules file for"
+   echo -e "\t  special properties. Optional, the default location is"
+   echo -e "\t  debian/maven.rules"
+   echo -e "\t-c<classifier> --classifier=<classifier>: Optional, the classifier for"
+   echo -e "\t  the jar in the Maven repository. Empty by default."
+   echo -e "\t-v --verbose: show more information while running"
+   echo -e "\t-n --no-act: don't actually do anything, just print the results"
+   exit 1
+}
+
+ARGS="p package r rules c classifier v verbose n no-act" parseargs "$@"
+
+if [ "$ARGC" -lt "1" ]; then
+   syntax
+fi
+
+RULES=$(getarg r rules)
+PACKAGE=$(getarg p package)
+PACKAGE=${PACKAGE:?"Package parameter (-p) is mandatory"}
+CLASSIFIER=$(getarg c classifier)
+VERBOSE=$(getarg v verbose)
+NOACT=$(getarg n no-act)
+POM="${ARGV[0]}"
+
+DH_OPTS="${VERBOSE:+-v} ${NOACT:+-n}"
+CLEAN_ARGS="--package=${PACKAGE} ${RULES:+--rules=$RULES}"
+
+mkdir -p debian/.mh 2> /dev/null
+
+if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
+    echo -e "\tmh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/.mh/pom.xml debian/.mh/pom.properties"
+fi
+
+mh_cleanpom $DH_OPTS $CLEAN_ARGS $POM debian/.mh/pom.xml debian/.mh/pom.properties
+source debian/.mh/pom.properties
+
+groupPath=$(echo $groupId | tr . / )
+
+VERSIONED_JAR_NAME="${artifactId}-${version}.jar"
+if [ ! -z "$CLASSIFIER" ]; then
+    VERSIONED_JAR_NAME="${artifactId}-${version}-${CLASSIFIER}.jar"
+fi
+
+MVN_VERSIONED_DIR=usr/share/maven-repo/${groupPath}/${artifactId}/${version}
+MVN_VERSIONED_JAR=$MVN_VERSIONED_DIR/$VERSIONED_JAR_NAME
+
+link_jar ()
+{
+	local src=$1
+	local dest=$2
+
+	if [[ "$src" == "$dest" ]]; then
+		return
+	fi
+
+	if [[ ! -z "$VERBOSE" || "$DH_VERBOSE" = "1" ]]; then
+		echo -e "\tdh_link $DH_OPTS -p${PACKAGE} ${src} ${dest}"
+	fi
+	dh_link $DH_OPTS -p${PACKAGE} ${src} ${dest}
+}
+
+# Create the links supplied on the argument list
+for (( i=1; i < $ARGC; i++ )); do
+    LINK_JAR="${ARGV[i]}"
+    link_jar "$MVN_VERSIONED_JAR" "$LINK_JAR"
+done
+

Added: trunk/maven-repo-helper/src/main/bin/mh_patchpom
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_patchpom	                        (rev 0)
+++ trunk/maven-repo-helper/src/main/bin/mh_patchpom	2010-06-20 19:51:03 UTC (rev 12602)
@@ -0,0 +1,115 @@
+#!/bin/bash --
+
+set -e
+
+. /usr/share/maven-repo-helper/mh_lib.sh
+
+syntax()
+{
+   echo -e "Usage: mh_patchpom [option]... [pom] [backup]"
+   echo -e "Transform the POM using the transformation rules."
+   echo -e ""
+   echo -e "Where"
+   echo -e "\t[pom] is the location of the POM file to transform."
+   echo -e "\t  Default to pom.xml"
+   echo -e "\t[backup] is the backup file for the pom."
+   echo -e "\t  Default to pom.xml.save"
+   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 Debian package containing"
+   echo -e "\t  this library"
+   echo -e "\t-o --no-parent: don't inherit from a parent POM"
+   echo -e "\t-e<version>, --set-version=<version>: set the version for the POM,"
+   echo -e "\t  do not use the version declared in the POM file."
+   echo -e "\t-r<rules> --rules=<rules>: path to the file containing the"
+   echo -e "\t  extra rules to apply when cleaning the POM."
+   echo -e "\t  Optional, the default location is debian/maven.rules"
+   echo -e "\t-u<rules> --published-rules=<rules>: path to the file containing the"
+   echo -e "\t  extra rules to publish in the property debian.mavenRules in the"
+   echo -e "\t  cleaned POM."
+   echo -e "\t  Optional, the default location is debian/maven.publishedRules"
+   echo -e "\t-i<rules> --ignore-rules=<rules>: path to the file containing the"
+   echo -e "\t  rules used to remove certain dependencies from the cleaned POM"
+   echo -e "\t  Optional, the default location is debian/maven.ignoreRules"
+   echo -e "\t-c<rules> --clean-ignore-rules=<rules>: path to the file containing the"
+   echo -e "\t  rules use to remove certain dependencies from the cleaned POM,"
+   echo -e "\t  in addition to the ignore rules specified previously. This is"
+   echo -e "\t  useful in situations such as when the Maven clean target requires more"
+   echo -e "\t  dependencies or plugins to ignore than the build target"
+   echo -e "\t  Optional, it is ignored by default"
+   echo -e "\t-s --no-rules: don't apply any rules for converting versions,"
+   echo -e "\t  do not even convert versions to the default 'debian' version"
+   echo -e "\t-k --keep-pom-version: keep the original version of the POMs but, "
+   echo -e "\t  convert all other versions in dependencies and plugins"
+   echo -e "\t-d --debian-build: transform during a Debian build, which means that"
+   echo -e "\t  some POM elements will be removed"
+   echo -e "\t-b --build-no-docs: transform during a build where no documentation is generated,"
+   echo -e "\t  which means that some POM elements will be removed"
+   echo -e "\t-m<repo root>--maven-repo=<repo root>: location of the Maven repository,"
+   echo -e "\t  used to force the versions of the Maven plugins used in the current"
+   echo -e "\t  POM file with the versions found in the repository"
+   echo -e "\t-v --verbose: show more information while running"
+   echo -e "\t-n --no-act: don't actually do anything, just print the results"
+   exit 1
+}
+
+ARGS="p package o no-parent k keep-pom-version e set-version r rules u published-rules i ignore-rules c clean-ignore-rules s no-rules v verbose n no-act d debian-build b build-no-docs m maven-repo" parseargs "$@"
+
+if [ "$ARGC" -lt "1" ]; then
+   syntax
+fi
+
+NOPARENT=$(getarg o no-parent)
+SETVERSION=$(getarg e set-version)
+RULES=$(getarg r rules)
+PUBLISHED_RULES=$(getarg u published-rules)
+IGNORE_RULES=$(getarg i ignore-rules)
+CLEAN_IGNORE_RULES=$(getarg c clean-ignore-rules)
+NORULES=$(getarg s no-rules)
+KEEP_POM_VERSION=$(getarg k keep-pom-version)
+MAVEN_REPO=$(getarg m maven-repo)
+PACKAGE=$(getarg p package)
+PACKAGE=${PACKAGE:?"Package parameter (-p) is mandatory"}
+VERBOSE=$(getarg v verbose)
+NOACT=$(getarg n no-act)
+DEBIAN_BUILD=$(getarg d debian-build)
+BUILD_NO_DOCS=$(getarg b build-no-docs)
+POM="${ARGV[0]}"
+BACKUP="${ARGV[1]}"
+
+if [ -z "$POM" ]; then
+    POM="pom.xml"
+fi
+if [ -z "$BACKUP" ]; then
+    BACKUP="${POM}.save"
+fi
+if [ -z "$PUBLISHED_RULES" ]; then
+    if [ -f debian/maven.publishedRules ]; then
+        PUBLISHED_RULES="debian/maven.publishedRules"
+    fi
+fi
+if [ -z "$IGNORE_RULES" ]; then
+    if [ -f debian/maven.ignoreRules ]; then
+        IGNORE_RULES="debian/maven.ignoreRules"
+    fi
+fi
+if [ -z "$RULES" ]; then
+    if [ -f debian/maven.rules ]; then
+        RULES="debian/maven.rules"
+    fi
+fi
+if [ -z "$MAVEN_REPO" ]; then
+    if [ -f /usr/share/maven-repo ]; then
+        MAVEN_REPO="/usr/share/maven-repo"
+    fi
+fi
+
+DH_OPTS="${VERBOSE:+-v}"
+MH_ARGS="--package=${PACKAGE} ${NOPARENT:+--no-parent} ${SETVERSION:+--set-version=$SETVERSION} ${RULES:+--rules=$RULES} ${KEEP_POM_VERSION:+--keep-pom-version} ${PUBLISHED_RULES:+--published-rules=$PUBLISHED_RULES} ${IGNORE_RULES:+--ignore-rules=$IGNORE_RULES} ${CLEAN_IGNORE_RULES:+--ignore-rules=$CLEAN_IGNORE_RULES} ${NORULES:+--no-rules} ${DEBIAN_BUILD:+--debian-build} ${BUILD_NO_DOCS:+--build-no-docs} ${MAVEN_REPO:+--maven-repo=$MAVEN_REPO}"
+
+if [ -z "$NOACT" ]; then
+	cp $POM $BACKUP
+	java -cp $CLASSPATH $JAVA_OPTIONS org.debian.maven.repo.POMTransformer --single $DH_OPTS $MH_ARGS $POM
+fi
+

Modified: trunk/maven-repo-helper/src/main/bin/mh_patchpoms
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_patchpoms	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/main/bin/mh_patchpoms	2010-06-20 19:51:03 UTC (rev 12602)
@@ -16,14 +16,15 @@
    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-r<rules> --rules=<rules>: gives the location of the rules file for"
-   echo -e "\t  special properties. Optional, the default location is"
-   echo -e "\t  debian/maven.rules"
+   echo -e "\t-r<rules> --rules=<rules>: path to the file containing the"
+   echo -e "\t  extra rules to apply when cleaning the POM."
+   echo -e "\t  Optional, the default location is debian/maven.rules"
    echo -e "\t-u<rules> --published-rules=<rules>: path to the file containing the"
-   echo -e "\t  extra rules to publish in the property debian.mavenRules in the cleaned POM"
+   echo -e "\t  extra rules to publish in the property debian.mavenRules in the"
+   echo -e "\t  cleaned POM."
    echo -e "\t  Optional, the default location is debian/maven.publishedRules"
    echo -e "\t-i<rules> --ignore-rules=<rules>: path to the file containing the"
-   echo -e "\t  rules use to remove certain dependencies from the cleaned POM"
+   echo -e "\t  rules used to remove certain dependencies from the cleaned POM"
    echo -e "\t  Optional, the default location is debian/maven.ignoreRules"
    echo -e "\t-c<rules> --clean-ignore-rules=<rules>: path to the file containing the"
    echo -e "\t  rules use to remove certain dependencies from the cleaned POM,"
@@ -44,6 +45,8 @@
    echo -e "\t  POM file with the versions found in the repository"
    echo -e "\t-v --verbose: show more information while running"
    echo -e "\t-n --no-act: don't actually do anything, just print the results"
+   echo -e ""
+   echo -e "See also: mh_installpoms(1)"
    exit 1
 }
 
@@ -89,6 +92,8 @@
 
 if [ -z "$NOACT" ]; then
     cat debian/$PACKAGE.poms | while read POM OPT1 OPT2; do
+        # Remove comments
+        POM=${POM##\#*}
         if [ ! -z "$POM" ]; then
             cp $POM $POM.save
         fi

Modified: trunk/maven-repo-helper/src/main/bin/mh_unpatchpoms
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_unpatchpoms	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/main/bin/mh_unpatchpoms	2010-06-20 19:51:03 UTC (rev 12602)
@@ -27,6 +27,8 @@
 
 if [ -z "$NOACT" ]; then
     cat debian/$PACKAGE.poms | while read POM OPT1 OPT2; do
+        # Remove comments
+        POM=${POM##\#*}
         if [ ! -z "$POM" ]; then
             if [ -e ${POM}.save ]; then
                 rm $POM

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMTransformer.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMTransformer.java	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMTransformer.java	2010-06-20 19:51:03 UTC (rev 12602)
@@ -190,6 +190,11 @@
         });
     }
 
+    public void keepPomVersion(File pomFile) throws XMLStreamException, FileNotFoundException {
+        Dependency pom = readPom(pomFile).getThisPom();
+        addRule(new DependencyRule(pom.getGroupId() + " " + pom.getArtifactId() + " " + pom.getType() + " " + pom.getVersion()));
+    }
+
     public void transformPoms(File poms, final String debianPackage, final boolean keepPomVersion,
             final String setVersion) {
         foreachPoms(poms, new POMHandler() {
@@ -206,6 +211,15 @@
         });
     }
 
+    public void transformPom(File pomFile, String debianPackage,
+            boolean noParent, boolean keepPomVersion, String setVersion) throws XMLStreamException, FileNotFoundException, IOException {
+
+        File targetFile = new File(pomFile.getAbsolutePath() + ".new");
+        transformPom(pomFile, targetFile, noParent, keepPomVersion, setVersion, debianPackage);
+        pomFile.delete();
+        targetFile.renameTo(pomFile);
+    }
+
     public void transformPom(File originalPom, File targetPom) throws XMLStreamException, FileNotFoundException, IOException {
         transformPom(originalPom, targetPom, false, false, null, null);
     }
@@ -277,12 +291,12 @@
                             // Handle the special case of dependencies or plugins which can be ignored
                             // such as test dependencies during a clean operation
                             if ("dependency".equals(element) || "plugin".equals(element) || "extension".equals(element)) {
-                                sawVersion = false;
                                 dependency = null;
                                 if ("dependency".equals(element)) {
                                     String parentElement = (String) path.get(path.size() - 2);
                                     String parentParentElement = (String) path.get(path.size() - 3);
                                     if ("dependencies".equals(parentElement)) {
+                                        sawVersion = false;
                                         String listSelector = null;
                                         if ("dependencyManagement".equals(parentParentElement)) {
                                             String p3Element = (String) path.get(path.size() - 4);
@@ -310,10 +324,10 @@
                                         }
                                     }
                                 } else if ("plugin".equals(element)) {
-                                    sawVersion = false;
                                     String parentElement = (String) path.get(path.size() - 2);
                                     String parentParentElement = (String) path.get(path.size() - 3);
                                     if ("plugins".equals(parentElement)) {
+                                        sawVersion = false;
                                         String listSelector = POMInfo.PLUGINS;
                                         if ("pluginManagement".equals(parentParentElement)) {
                                             listSelector = POMInfo.PLUGIN_MANAGEMENT;
@@ -323,9 +337,12 @@
                                         dependency = (Dependency) dependencyList.get(index);
                                     }
                                 } else if ("extension".equals(element)) {
-                                    sawVersion = false;
-                                    int index = inc(dependencyIndexes, POMInfo.EXTENSIONS);
-                                    dependency = (Dependency) info.getExtensions().get(index);
+                                    String parentElement = (String) path.get(path.size() - 2);
+                                    if ("extensions".equals(parentElement)) {
+                                        sawVersion = false;
+                                        int index = inc(dependencyIndexes, POMInfo.EXTENSIONS);
+                                        dependency = (Dependency) info.getExtensions().get(index);
+                                    }
                                 }
                                 // Skip dependency if we can't find it (== null)
                                 if (dependency == null || !acceptDependency(dependency, info)) {
@@ -793,6 +810,9 @@
         boolean verbose = false;
         boolean noRules = false;
         boolean keepPomVersion = false;
+        boolean singlePom = false;
+        boolean noParent = false;
+        
         String setVersion = null;
         String debianPackage = "";
         File rulesFile = null;
@@ -804,6 +824,10 @@
             String arg = args[i].trim();
             if ("--verbose".equals(arg) || "-v".equals(arg)) {
                 verbose = true;
+            } else if ("--single".equals(arg)) {
+                singlePom = true;
+            } else if ("--no-parent".equals(arg)) {
+                noParent = true;
             } else if ("--no-rules".equals(arg)) {
                 noRules = true;
             } else if ("--keep-pom-version".equals(arg)) {
@@ -850,9 +874,12 @@
 
         transformer.setVerbose(verbose);
 
-        File poms;
+        File poms = null;
+        File pom = null;
 
-        if (i + 1 < args.length) {
+        if (singlePom) {
+            pom = new File(args[i++].trim());
+        } else if (i + 1 < args.length) {
             poms = new File(args[i++].trim());
         } else {
             poms = new File("debian/" + debianPackage + ".poms");
@@ -877,7 +904,17 @@
             }
 
             if (keepPomVersion) {
-                transformer.keepPomVersions(poms, debianPackage);
+                if (singlePom) {
+                    try {
+                        transformer.keepPomVersion(pom);
+                    } catch (XMLStreamException e) {
+                        e.printStackTrace();
+                    } catch (FileNotFoundException e) {
+                        e.printStackTrace();
+                    }
+                } else {
+                    transformer.keepPomVersions(poms, debianPackage);
+                }
             }
 
             if (publishedRulesFile != null) {
@@ -896,7 +933,17 @@
             transformer.addPluginRulesFromRepository();
         }
 
-        transformer.transformPoms(poms, debianPackage, keepPomVersion, setVersion);
+        if (singlePom) {
+            try {
+                transformer.transformPom(pom, debianPackage, noParent, keepPomVersion, setVersion);
+            } catch (XMLStreamException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        } else {
+            transformer.transformPoms(poms, debianPackage, keepPomVersion, setVersion);
+        }
     }
 
     private static int inc(int i, String[] args) {

Modified: trunk/maven-repo-helper/src/main/share/mh_lib.sh
===================================================================
--- trunk/maven-repo-helper/src/main/share/mh_lib.sh	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/main/share/mh_lib.sh	2010-06-20 19:51:03 UTC (rev 12602)
@@ -4,7 +4,7 @@
 # - package selection
 #
 
-MH_VERSION=${MH_VERSION:-1.0.2}
+MH_VERSION=${MH_VERSION:-1.1}
 CLASSPATH=/usr/share/java/stax-api.jar:/usr/share/java/stax.jar:/usr/share/java/xml-apis.jar:/usr/share/java/maven-repo-helper.jar
 JAVA_OPTIONS="-Djavax.xml.stream.XMLOutputFactory=com.bea.xml.stream.XMLOutputFactoryBase -Djavax.xml.stream.XMLInputFactory=com.bea.xml.stream.MXParserFactory"
 

Modified: trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMCleanerTest.java
===================================================================
--- trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMCleanerTest.java	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMCleanerTest.java	2010-06-20 19:51:03 UTC (rev 12602)
@@ -9,7 +9,6 @@
 import java.util.Properties;
 
 /**
- *
  * @author ludo
  */
 public class POMCleanerTest extends TestBase {
@@ -228,6 +227,28 @@
     }
 
     /**
+     * Test of cleanPom method, of class POMCleaner.
+     */
+    public void testCleanHibernateValidatorPom() throws Exception {
+        pomProperties = new File(testDir, "pom.properties");
+        usePom("hibernate-validator.pom");
+        boolean noParent = true;
+        POMCleaner instance = new POMCleaner();
+        instance.addDefaultRules();
+        instance.addIgnoreRule(new DependencyRule("org.apache.maven.wagon wagon-webdav jar *"));
+        instance.addIgnoreRule(new DependencyRule("org.jboss.maven.plugins maven-jdocbook-plugin maven-plugin *"));
+        instance.cleanPom(pom, updatedPom, pomProperties, noParent, false, null, "libhibernate-validator-java");
+        assertXMLEqual(read("hibernate-validator.cleaned"), read(updatedPom));
+        Properties pomInfo = new Properties();
+        pomInfo.load(new FileInputStream(pomProperties));
+        assertEquals("org.hibernate", pomInfo.get("groupId"));
+        assertEquals("hibernate-validator-parent", pomInfo.get("artifactId"));
+        assertEquals("pom", pomInfo.get("type"));
+        assertEquals("4.0.2.GA", pomInfo.get("version"));
+        assertEquals("debian", pomInfo.get("debianVersion"));
+    }
+
+    /**
      * Test of main method, of class DebianPOM.
      */
     public void testMain() throws Exception {
@@ -236,7 +257,7 @@
         usePom("maven.xml");
         useFile("maven.rules", specialDependencies);
         String[] args = {"--no-parent", "-pmaven2", "-r" + specialDependencies.getAbsolutePath(),
-            pom.getAbsolutePath(), updatedPom.getAbsolutePath(), pomProperties.getAbsolutePath() };
+                pom.getAbsolutePath(), updatedPom.getAbsolutePath(), pomProperties.getAbsolutePath()};
         POMCleaner.main(args);
         assertXMLEqual(read("maven.cleaned"), read(updatedPom));
     }

Modified: trunk/maven-repo-helper/src/test/resources/antlr3-tools.transformed
===================================================================
--- trunk/maven-repo-helper/src/test/resources/antlr3-tools.transformed	2010-06-20 19:25:52 UTC (rev 12601)
+++ trunk/maven-repo-helper/src/test/resources/antlr3-tools.transformed	2010-06-20 19:51:03 UTC (rev 12602)
@@ -63,6 +63,7 @@
 						</goals>
 					</execution>
 				</executions>
+				<version>2.1</version>
 			</plugin>
 			<plugin>
 				<artifactId>maven-compiler-plugin</artifactId>
@@ -74,4 +75,4 @@
 			</plugin>
 		</plugins>
 	</build>
-</project>
\ No newline at end of file
+</project>

Added: trunk/maven-repo-helper/src/test/resources/hibernate-validator.cleaned
===================================================================
--- trunk/maven-repo-helper/src/test/resources/hibernate-validator.cleaned	                        (rev 0)
+++ trunk/maven-repo-helper/src/test/resources/hibernate-validator.cleaned	2010-06-20 19:51:03 UTC (rev 12602)
@@ -0,0 +1,84 @@
+<?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>
+	<groupId>org.hibernate</groupId>
+	<artifactId>hibernate-validator-parent</artifactId>
+	<version>debian</version>
+	<packaging>pom</packaging>
+	<properties>
+		<debian.originalVersion>4.0.2.GA</debian.originalVersion>
+		<debian.package>libhibernate-validator-java</debian.package>
+	</properties>
+
+	<name>Hibernate Validator Parent</name>
+	<url>http://validator.hibernate.org</url>
+	<description>Hibernate's Bean Validation (JSR-303) reference implementation.</description>
+	<developers>
+		<developer>
+			<id>epbernard</id>
+			<name>Emmanuel Bernard</name>
+			<email>emmanuel at hibernate.org</email>
+			<organization>JBoss, a division of Red Hat</organization>
+			<url>http://in.relation.to/Bloggers/Emmanuel</url>
+		</developer>
+		<developer>
+			<id>hardy.ferentschik</id>
+			<name>Hardy Ferentschik</name>
+			<email>hferents at redhat.com</email>
+			<organization>JBoss, a division of Red Hat</organization>
+			<url>http://in.relation.to/Bloggers/Hardy</url>
+		</developer>
+	</developers>
+	<mailingLists>
+		<mailingList>
+			<name>hibernate-dev</name>
+			<post>hibernate-dev at lists.jboss.org</post>
+		</mailingList>
+	</mailingLists>
+	<modules>
+		<module>hibernate-validator</module>
+		<module>hibernate-validator-archetype</module>
+		<module>hibernate-validator-legacy</module>
+		<module>hibernate-validator-tck-runner</module>
+	</modules>
+	<dependencyManagement>
+		<dependencies>
+			<dependency>
+				<groupId>javax.validation</groupId>
+				<artifactId>validation-api</artifactId>
+				<version>debian</version>
+			</dependency>
+			<dependency>
+				<groupId>org.slf4j</groupId>
+				<artifactId>slf4j-api</artifactId>
+				<version>debian</version>
+			</dependency>
+			<dependency>
+				<groupId>org.slf4j</groupId>
+				<artifactId>slf4j-log4j12</artifactId>
+				<version>debian</version>
+			</dependency>
+			<dependency>
+				<groupId>org.testng</groupId>
+				<artifactId>testng</artifactId>
+				<version>debian</version>
+				<classifier>jdk15</classifier>
+			</dependency>
+		</dependencies>
+	</dependencyManagement>
+	<issueManagement>
+		<system>JIRA</system>
+		<url>http://opensource.atlassian.com/projects/hibernate/browse/HV</url>
+	</issueManagement>
+	<inceptionYear>2007</inceptionYear>
+	<licenses>
+		<license>
+			<name>Apache License, Version 2.0</name>
+			<url>license.txt</url>
+		</license>
+	</licenses>
+	<scm>
+		<connection>scm:svn:https://svn.jboss.org/repos/hibernate/validator/tags/v4_0_2_GA</connection>
+		<url>http://fisheye.jboss.org/browse/Hibernate/validator/tags/v4_0_2_GA</url>
+	</scm>
+</project>
\ No newline at end of file

Added: trunk/maven-repo-helper/src/test/resources/hibernate-validator.pom
===================================================================
--- trunk/maven-repo-helper/src/test/resources/hibernate-validator.pom	                        (rev 0)
+++ trunk/maven-repo-helper/src/test/resources/hibernate-validator.pom	2010-06-20 19:51:03 UTC (rev 12602)
@@ -0,0 +1,250 @@
+<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>
+    <groupId>org.hibernate</groupId>
+    <artifactId>hibernate-validator-parent</artifactId>
+    <packaging>pom</packaging>
+    <version>4.0.2.GA</version>
+    <name>Hibernate Validator Parent</name>
+    <url>http://validator.hibernate.org</url>
+
+    <description>
+        Hibernate's Bean Validation (JSR-303) reference implementation.
+    </description>
+
+    <developers>
+        <developer>
+            <id>epbernard</id>
+            <name>Emmanuel Bernard</name>
+            <email>emmanuel at hibernate.org</email>
+            <organization>JBoss, a division of Red Hat</organization>
+            <url>http://in.relation.to/Bloggers/Emmanuel</url>
+        </developer>
+        <developer>
+            <id>hardy.ferentschik</id>
+            <name>Hardy Ferentschik</name>
+            <email>hferents at redhat.com</email>
+            <organization>JBoss, a division of Red Hat</organization>
+            <url>http://in.relation.to/Bloggers/Hardy</url>
+        </developer>
+    </developers>
+
+    <mailingLists>
+        <mailingList>
+            <name>hibernate-dev</name>
+            <post>hibernate-dev at lists.jboss.org</post>
+        </mailingList>
+    </mailingLists>
+
+    <modules>
+        <module>hibernate-validator</module>
+        <module>hibernate-validator-archetype</module>
+        <module>hibernate-validator-legacy</module>
+        <module>hibernate-validator-tck-runner</module>
+    </modules>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>javax.validation</groupId>
+                <artifactId>validation-api</artifactId>
+                <version>1.0.0.GA</version>
+            </dependency>
+            <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-api</artifactId>
+                <version>1.5.6</version>
+            </dependency>
+            <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-log4j12</artifactId>
+                <version>1.5.6</version>
+            </dependency>
+            <dependency>
+                <groupId>org.testng</groupId>
+                <artifactId>testng</artifactId>
+                <version>5.8</version>
+                <classifier>jdk15</classifier>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+        <extensions>
+            <extension>
+                <groupId>org.apache.maven.wagon</groupId>
+                <artifactId>wagon-webdav</artifactId>
+                <version>1.0-beta-2</version>
+            </extension>
+        </extensions>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-jar-plugin</artifactId>
+                    <version>2.2</version>
+                    <configuration>
+                        <archive>
+                            <manifestEntries>
+                                <Implementation-Title>${pom.artifactId}</Implementation-Title>
+                                <Implementation-Version>${pom.version}</Implementation-Version>
+                                <Implementation-Vendor>${pom.groupId}</Implementation-Vendor>
+                                <Implementation-Vendor-Id>${pom.groupId}</Implementation-Vendor-Id>
+                                <Implementation-URL>${pom.url}</Implementation-URL>
+                                <Specification-Title>Bean Validation</Specification-Title>
+                            </manifestEntries>
+                        </archive>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>2.0.2</version>
+                    <configuration>
+                        <source>1.5</source>
+                        <target>1.5</target>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <configuration>
+                        <forkMode>always</forkMode>
+                        <redirectTestOutputToFile>true</redirectTestOutputToFile>
+                        <includes>
+                            <include>**/*Test.java</include>
+                        </includes>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-source-plugin</artifactId>
+                    <executions>
+                        <execution>
+                            <id>attach-sources</id>
+                            <goals>
+                                <goal>jar</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+                <plugin>
+                    <artifactId>maven-assembly-plugin</artifactId>
+                    <configuration>
+                        <descriptorRefs>
+                            <descriptorRef>project</descriptorRef>
+                        </descriptorRefs>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-release-plugin</artifactId>
+                    <version>2.0-beta-9</version>
+                    <configuration>
+                        <preparationGoals>clean install</preparationGoals>
+                        <autoVersionSubmodules>true</autoVersionSubmodules>
+                        <allowTimestampedSnapshots>true</allowTimestampedSnapshots>
+                        <remoteTagging>true</remoteTagging>
+                        <goals>package site assembly:assembly deploy</goals>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+
+    <ciManagement>
+        <system>Hudson</system>
+        <url>http://hudson.qa.jboss.com/hudson/job/beanvalidation</url>
+    </ciManagement>
+
+    <issueManagement>
+        <system>JIRA</system>
+        <url>http://opensource.atlassian.com/projects/hibernate/browse/HV</url>
+    </issueManagement>
+
+    <inceptionYear>2007</inceptionYear>
+
+    <licenses>
+        <license>
+            <name>Apache License, Version 2.0</name>
+            <url>license.txt</url>
+        </license>
+    </licenses>
+
+    <scm>
+        <connection>scm:svn:https://svn.jboss.org/repos/hibernate/validator/tags/v4_0_2_GA</connection>
+        <url>http://fisheye.jboss.org/browse/Hibernate/validator/tags/v4_0_2_GA</url>
+    </scm>
+
+    <distributionManagement>
+        <repository>
+            <!-- Copy the dist to the local checkout of the JBoss maven2 repo ${maven.repository.root} -->
+            <!-- It is anticipated that ${maven.repository.root} be set in user's settings.xml -->
+            <!-- todo : replace this with direct svn access once the svnkit providers are available -->
+            <id>repository.jboss.org</id>
+            <url>file://${maven.repository.root}</url>
+        </repository>
+        <snapshotRepository>
+            <id>snapshots.jboss.org</id>
+            <name>JBoss Snapshot Repository</name>
+            <url>dav:https://snapshots.jboss.org/maven2</url>
+        </snapshotRepository>
+    </distributionManagement>
+
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-project-info-reports-plugin</artifactId>
+                <version>2.0.1</version>
+            </plugin>
+            <plugin>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <reportSets>
+                    <reportSet>
+                        <id>html</id>
+                        <configuration>
+                            <tags>
+                                <tag>
+                                    <name>todo</name>
+                                    <placement>a</placement>
+                                    <head>ToDo:</head>
+                                </tag>
+                            </tags>
+                        </configuration>
+                        <reports>
+                            <report>javadoc</report>
+                        </reports>
+                    </reportSet>
+                </reportSets>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>jxr-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <artifactId>maven-clover-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-pmd-plugin</artifactId>
+                <configuration>
+                    <targetJdk>1.5</targetJdk>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>taglist-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>changelog-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>changes-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </reporting>
+</project>
\ No newline at end of file




More information about the pkg-java-commits mailing list