[pkg-java] r11451 - in trunk/maven-debian-helper: . bin debian etc maven-build-nodocs maven-build-nodocs/src maven-build-nodocs/src/main maven-build-nodocs/src/main/resources maven-build-nodocs/src/main/resources/META-INF maven-build-nodocs/src/main/resources/META-INF/plexus maven-debian-plugin/src/main/java/org/debian/maven/plugin maven-packager-utils/src/main/java/org/debian/maven/packager maven-packager-utils/src/main/resources share/cdbs/1/class

Ludovic Claude ludovicc-guest at alioth.debian.org
Sun Jan 31 00:14:57 UTC 2010


Author: ludovicc-guest
Date: 2010-01-31 00:14:53 +0000 (Sun, 31 Jan 2010)
New Revision: 11451

Added:
   trunk/maven-debian-helper/etc/m2-debian-nodocs.conf
   trunk/maven-debian-helper/maven-build-nodocs/
   trunk/maven-debian-helper/maven-build-nodocs/pom.xml
   trunk/maven-debian-helper/maven-build-nodocs/src/
   trunk/maven-debian-helper/maven-build-nodocs/src/main/
   trunk/maven-debian-helper/maven-build-nodocs/src/main/resources/
   trunk/maven-debian-helper/maven-build-nodocs/src/main/resources/META-INF/
   trunk/maven-debian-helper/maven-build-nodocs/src/main/resources/META-INF/plexus/
   trunk/maven-debian-helper/maven-build-nodocs/src/main/resources/META-INF/plexus/components.xml
Removed:
   trunk/maven-debian-helper/debian/maven-settings.xml
Modified:
   trunk/maven-debian-helper/bin/mh_make
   trunk/maven-debian-helper/bin/mh_resolve_dependencies
   trunk/maven-debian-helper/debian/build.xml
   trunk/maven-debian-helper/debian/changelog
   trunk/maven-debian-helper/debian/maven-debian-helper.poms
   trunk/maven-debian-helper/debian/rules
   trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
   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/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/maven.properties.vm
   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
Log:
* mh_make handles better multi projects
* mh_make generates projects following the Debian 3.8.3 policy
* Documentation improvements
* maven.mk: unpatch the poms in cleanbuilddir, to have a good
  clean sequence when maven.mk is used with a patch system -
  clean target -> mvn clean -> rm tmp files -> unpatch pom files
   -> unpatch files with patch system
* Read rules from the Maven repository to force the version of
  Maven plugins to be the same as in the repository
* maven.mk removes some elements from the POM files when their
  use is against the Debian policy (<repositories> as they
  imply downloading artifacts from the Internet, 
  <distributionManagement> as it implies publishing on the net
  or in a location not controlled by Debian) or when they are
  not needed and risk pulling out unwanted dependencies
  (<reports> which is not used if a documentation package is
  not generated)
* maven.mk adds a patch to Maven to disable using the
  maven-site-plugin when no documentation package is generated.
  This helps to reduce the amount of build dependencies

Modified: trunk/maven-debian-helper/bin/mh_make
===================================================================
--- trunk/maven-debian-helper/bin/mh_make	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/bin/mh_make	2010-01-31 00:14:53 UTC (rev 11451)
@@ -23,6 +23,18 @@
    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"
+   echo -e ""
+   echo -e "To have mh_make working properly, you need first to install on your system"
+   echo -e "as many dependencies for your project as possible. Those dependencies should"
+   echo -e "also contain the required Maven metadata (POM files and jars in the"
+   echo -e "/usr/share/maven-repo repository)"
+   echo -e ""
+   echo -e "Environment variables:"
+   echo -e "\tDEBFULLNAME - your full name, e.g. John Doe"
+   echo -e "\tDEBEMAIL - your packager email address"
+   echo -e "\tDEBLICENSE - the license for the files under the debian/ directory"
+   echo -e "\t  must be one of GPL2, GPL3, LGPL2.1, Apache-2.0, BSD or any license"
+   echo -e "\t  short name defined in http://dep.debian.net/deps/dep5/"
    exit 1
 }
 
@@ -58,9 +70,9 @@
 FROM_SVN=$(getarg s from-svn)
 
 if [ -z "$PACKAGE" ]; then
-    PACKAGE="$(basename $(pwd))"
+    PACKAGE="$(basename $(pwd) | sed 's/-[0-9\.].*//')"
 	if [ -n "$FROM_SVN" ]; then
-		PACKAGE=$(basename $FROM_SVN | sed 's/-[0-9].*//' )
+		PACKAGE=$(basename $FROM_SVN | sed 's/-[0-9\.].*//' )
 	fi
     echo "Enter the name of the new Debian source package. If empty, it will defaults to $PACKAGE"
     read -p ">" USER_PACKAGE
@@ -79,7 +91,6 @@
 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
@@ -88,7 +99,6 @@
 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
@@ -101,23 +111,21 @@
 	cd $PACKAGE
 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 pom.xml.save ]; then
 	mh_unpatchpoms -p$BIN_PACKAGE
 fi
- 
-mh_patchpoms -p$BIN_PACKAGE --keep-pom-version
 
+java -cp /usr/share/java/maven-project.jar:/usr/share/java/maven-repo-helper.jar:/usr/share/java/maven-packager-utils.jar:/usr/share/maven2/lib/maven-debian-uber.jar org.debian.maven.packager.DependenciesSolver --package="$BIN_PACKAGE" ${ANT:+--ant} ${GEN_JAVADOC:+--generate-javadoc} ${RUN_TESTS:+--run-tests} --maven-repo=/usr/share/maven-repo
+
+mh_patchpoms -p$BIN_PACKAGE -rdebian/maven.rules -idebian/maven.ignoreRules --keep-pom-version
+
 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} ${FROM_SVN:+-DdownloadUrl=scm:svn:$FROM_SVN} --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
+    mh_cleanpom -p$PACKAGE pom.xml.save 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/')

Modified: trunk/maven-debian-helper/bin/mh_resolve_dependencies
===================================================================
--- trunk/maven-debian-helper/bin/mh_resolve_dependencies	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/bin/mh_resolve_dependencies	2010-01-31 00:14:53 UTC (rev 11451)
@@ -18,6 +18,7 @@
    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-n --non-interactive: non interactive mode, don't ask questions"
    echo -e "\t-v --verbose: show more information while running"
    echo -e ""
    echo -e "Description:"
@@ -34,10 +35,11 @@
    exit 1
 }
 
-ARGS="p package a ant v verbose" parseargs "$@"
+ARGS="p package a ant v verbose n non-interactive" parseargs "$@"
 
 PACKAGE=$(getarg p package)
 ANT=$(getarg a ant)
+NON_INTERACTIVE=$(getarg n non-interactive)
 
 if [ -z "$PACKAGE" ]; then
     if [ "$ARGC" -gt "0" ]; then
@@ -60,6 +62,6 @@
     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
+mvn org.debian.maven:maven-packager-utils:$MH_VERSION:dependencies -Dpackage="$PACKAGE" ${ANT:+-DpackageType=ant} -Dmaven.repo.local=/usr/share/maven-repo ${NON_INTERACTIVE:+-DnonInteractive=true} --offline
 
 perl -p -i -e 's/maven\./maven:/' debian/${PACKAGE}.substvars

Modified: trunk/maven-debian-helper/debian/build.xml
===================================================================
--- trunk/maven-debian-helper/debian/build.xml	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/debian/build.xml	2010-01-31 00:14:53 UTC (rev 11451)
@@ -44,12 +44,14 @@
         <cleanmodule dir=""/>
         <cleanmodule dir="maven-debian-helper"/>
         <cleanmodule dir="maven-debian-plugin"/>
+        <cleanmodule dir="maven-build-nodocs"/>
         <cleanmodule dir="maven-packager-utils"/>
     </target>
 
     <target name="package">
         <packagemodule dir=""/>
         <packagemodule dir="maven-debian-helper"/>
+        <packagemodule dir="maven-build-nodocs"/>
         <package-plugin-module dir="maven-debian-plugin"/>
         <package-plugin-module dir="maven-packager-utils"/>
     </target>

Modified: trunk/maven-debian-helper/debian/changelog
===================================================================
--- trunk/maven-debian-helper/debian/changelog	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/debian/changelog	2010-01-31 00:14:53 UTC (rev 11451)
@@ -1,6 +1,26 @@
-maven-debian-helper (0.8) UNRELEASED; urgency=low
+maven-debian-helper (0.8) unstable; urgency=low
 
   * mh_make falls back on EMAIL when DEBEMAIL is not set
+  * mh_make handles better multi projects
+  * mh_make generates projects following the Debian 3.8.3 policy
+  * Documentation improvements
+  * maven.mk: unpatch the poms in cleanbuilddir, to have a good
+    clean sequence when maven.mk is used with a patch system -
+    clean target -> mvn clean -> rm tmp files -> unpatch pom files
+     -> unpatch files with patch system
+  * Read rules from the Maven repository to force the version of
+    Maven plugins to be the same as in the repository
+  * maven.mk removes some elements from the POM files when their
+    use is against the Debian policy (<repositories> as they
+    imply downloading artifacts from the Internet, 
+    <distributionManagement> as it implies publishing on the net
+    or in a location not controlled by Debian) or when they are
+    not needed and risk pulling out unwanted dependencies
+    (<reports> which is not used if a documentation package is
+    not generated)
+  * maven.mk adds a patch to Maven to disable using the
+    maven-site-plugin when no documentation package is generated.
+    This helps to reduce the amount of build dependencies
 
  -- Ludovic Claude <ludovic.claude at laposte.net>  Mon, 04 Jan 2010 23:13:29 +0100
 

Modified: trunk/maven-debian-helper/debian/maven-debian-helper.poms
===================================================================
--- trunk/maven-debian-helper/debian/maven-debian-helper.poms	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/debian/maven-debian-helper.poms	2010-01-31 00:14:53 UTC (rev 11451)
@@ -1,4 +1,5 @@
 pom.xml --no-parent
 maven-debian-helper/pom.xml
 maven-debian-plugin/pom.xml
+maven-build-nodocs/pom.xml
 maven-packager-utils/pom.xml

Deleted: trunk/maven-debian-helper/debian/maven-settings.xml
===================================================================
--- trunk/maven-debian-helper/debian/maven-settings.xml	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/debian/maven-settings.xml	2010-01-31 00:14:53 UTC (rev 11451)
@@ -1,9 +0,0 @@
-<!--
-  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>

Modified: trunk/maven-debian-helper/debian/rules
===================================================================
--- trunk/maven-debian-helper/debian/rules	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/debian/rules	2010-01-31 00:14:53 UTC (rev 11451)
@@ -45,6 +45,7 @@
 	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-build-nodocs/pom.xml maven-build-nodocs/target/maven-build-nodocs-$(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) \

Added: trunk/maven-debian-helper/etc/m2-debian-nodocs.conf
===================================================================
--- trunk/maven-debian-helper/etc/m2-debian-nodocs.conf	                        (rev 0)
+++ trunk/maven-debian-helper/etc/m2-debian-nodocs.conf	2010-01-31 00:14:53 UTC (rev 11451)
@@ -0,0 +1,8 @@
+main is org.debian.maven.Wrapper from debian
+
+set maven.home default /usr/share/maven2
+
+[debian]
+load /usr/share/java/maven-debian-helper.jar
+load /usr/share/java/maven-build-nodocs.jar
+load ${maven.home}/lib/*.jar

Added: trunk/maven-debian-helper/maven-build-nodocs/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-build-nodocs/pom.xml	                        (rev 0)
+++ trunk/maven-debian-helper/maven-build-nodocs/pom.xml	2010-01-31 00:14:53 UTC (rev 11451)
@@ -0,0 +1,20 @@
+<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>
+    <groupId>org.debian.maven</groupId>
+    <artifactId>maven-debian</artifactId>
+    <version>0.6</version>
+  </parent>
+
+  <artifactId>maven-build-nodocs</artifactId>
+  <packaging>jar</packaging>
+  <name>build with no docs patch for Maven</name>
+
+  <description>
+	Patch to prevent Maven from calling maven-site-plugin when
+    we run a build that does not need to produce any documentation
+  </description>
+
+</project>

Added: trunk/maven-debian-helper/maven-build-nodocs/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- trunk/maven-debian-helper/maven-build-nodocs/src/main/resources/META-INF/plexus/components.xml	                        (rev 0)
+++ trunk/maven-debian-helper/maven-build-nodocs/src/main/resources/META-INF/plexus/components.xml	2010-01-31 00:14:53 UTC (rev 11451)
@@ -0,0 +1,48 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<component-set>
+  <components>
+
+    <component>
+      <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+      <role-hint>pom</role-hint>
+      <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+      <configuration>
+        <lifecycles>
+          <lifecycle>
+            <id>default</id>
+            <!-- START SNIPPET: pom-lifecycle -->
+            <phases>
+              <package></package>
+              <install>org.apache.maven.plugins:maven-install-plugin:install</install>
+              <deploy></deploy>
+            </phases>
+            <!--optional-mojos>
+              <optional-mojo>org.apache.maven.plugins:maven-site-plugin:attach-descriptor</optional-mojo>
+            </optional-mojos-->
+            <!-- END SNIPPET: pom-lifecycle -->
+          </lifecycle>
+        </lifecycles>
+      </configuration>
+    </component>
+
+  </components>
+
+</component-set>

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	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java	2010-01-31 00:14:53 UTC (rev 11451)
@@ -96,6 +96,14 @@
    */
   private String mavenRules;
 
+  /**
+   * root directory of the Maven repository
+   *
+   * @parameter expression="${basedir}"
+   * @readonly
+   */
+  private File repoDir;
+
   // ----------------------------------------------------------------------
   // Public methods
   // ----------------------------------------------------------------------
@@ -432,6 +440,10 @@
     {
       debianPackage = System.getProperty("debian.package");
     }
+    if (repoDir == null)
+    {
+      repoDir = new File(System.getProperty("maven.repo.local"));
+    }
   }
 
   /**

Modified: 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	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesMojo.java	2010-01-31 00:14:53 UTC (rev 11451)
@@ -70,11 +70,22 @@
      */
     protected String packageType;
     /**
+     * Location for the list of POMs file.
+     * @required
+     * @parameter expression="debian/${package}.poms"
+     */
+    protected File listOfPoms;
+    /**
      * Location of the Maven repository
      *
-     * @parameter default-value="/usr/share/maven-repo"
+     * @parameter expression="${maven.repo.local}" default-value="/usr/share/maven-repo"
      */
     protected File mavenRepo;
+    /**
+     * Type of the package (e.g. 'maven' or 'ant')
+     * @parameter expression="${nonInteractive}" default-value="false"
+     */
+    protected boolean nonInteractive;
 
     public void execute()
             throws MojoExecutionException {
@@ -101,6 +112,10 @@
         solver.setOutputDirectory(outputDirectory);
         solver.setPackageName(packageName);
         solver.setPackageType(packageType);
+        solver.setNonInteractive(nonInteractive);
+        if (listOfPoms != null) {
+            solver.setListOfPoms(listOfPoms);
+        }
 
         solver.solveDependencies();
 

Modified: 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	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java	2010-01-31 00:14:53 UTC (rev 11451)
@@ -30,6 +30,8 @@
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
@@ -53,37 +55,213 @@
  */
 public class DependenciesSolver {
 
+    // Plugins not useful for the build or whose use is against the
+    // Debian policy
+    private static final String[][] PLUGINS_TO_IGNORE = {
+        {"org.apache.maven.plugins", "maven-ant-plugin"},
+        {"org.apache.maven.plugins", "maven-archetype-plugin"},
+        {"org.apache.maven.plugins", "maven-deploy-plugin"},
+        {"org.apache.maven.plugins", "maven-release-plugin"},
+        {"org.apache.maven.plugins", "maven-remote-resources-plugin"},
+        {"org.apache.maven.plugins", "maven-repository-plugin"},
+        {"org.apache.maven.plugins", "maven-scm-plugin"},
+        {"org.apache.maven.plugins", "maven-stage-plugin"},
+        {"org.apache.maven.plugins", "maven-eclipse-plugin"},
+        {"org.apache.maven.plugins", "maven-idea-plugin"},
+        {"org.codehaus.mojo", "netbeans-freeform-maven-plugin"},
+        {"org.codehaus.mojo", "nbm-maven-plugin"},
+        {"org.codehaus.mojo", "ideauidesigner-maven-plugin"},
+        {"org.codehaus.mojo", "scmchangelog-maven-plugin"},};
+    private static final String[][] PLUGINS_THAT_CAN_BE_IGNORED = {
+        {"org.apache.maven.plugins", "maven-assembly-plugin"},
+        {"org.codehaus.mojo", "buildnumber-maven-plugin"},
+        {"org.apache.maven.plugins", "maven-verifier-plugin"},
+        {"org.codehaus.mojo", "findbugs-maven-plugin"},
+        {"org.codehaus.mojo", "fitnesse-maven-plugin"},
+        {"org.codehaus.mojo", "selenium-maven-plugin"},
+        {"org.codehaus.mojo", "dbunit-maven-plugin"},
+        {"org.codehaus.mojo", "failsafe-maven-plugin"},
+        {"org.codehaus.mojo", "shitty-maven-plugin"},};
+    private static final String[][] DOC_PLUGINS = {
+        {"org.apache.maven.plugins", "maven-changelog-plugin"},
+        {"org.apache.maven.plugins", "maven-changes-plugin"},
+        {"org.apache.maven.plugins", "maven-checkstyle-plugin"},
+        {"org.apache.maven.plugins", "maven-docck-plugin"},
+        {"org.apache.maven.plugins", "maven-javadoc-plugin"},
+        {"org.apache.maven.plugins", "maven-jxr-plugin"},
+        {"org.apache.maven.plugins", "maven-pmd-plugin"},
+        {"org.apache.maven.plugins", "maven-project-info-reports-plugin"},
+        {"org.apache.maven.plugins", "maven-surefire-report-plugin"},
+        {"org.apache.maven.plugins", "maven-pdf-plugin"},
+        {"org.apache.maven.plugins", "maven-site-plugin"},
+        {"org.codehaus.mojo", "clirr-maven-plugin"},
+        {"org.codehaus.mojo", "cobertura-maven-plugin"},
+        {"org.codehaus.mojo", "taglist-maven-plugin"},
+        {"org.codehaus.mojo", "dita-maven-plugin"},
+        {"org.codehaus.mojo", "docbook-maven-plugin"},
+        {"org.codehaus.mojo", "javancss-maven-plugin"},
+        {"org.codehaus.mojo", "jdepend-maven-plugin"},
+        {"org.codehaus.mojo", "dashboard-maven-plugin"},
+        {"org.codehaus.mojo", "emma-maven-plugin"},
+        {"org.codehaus.mojo", "sonar-maven-plugin"},};
+    private static final String[][] TEST_PLUGINS = {
+        {"org.apache.maven.plugins", "maven-failsafe-plugin"},
+        {"org.apache.maven.plugins", "maven-surefire-plugin"},
+        {"org.apache.maven.plugins", "maven-verifier-plugin"},
+        {"org.codehaus.mojo", "findbugs-maven-plugin"},
+        {"org.codehaus.mojo", "fitnesse-maven-plugin"},
+        {"org.codehaus.mojo", "selenium-maven-plugin"},
+        {"org.codehaus.mojo", "dbunit-maven-plugin"},
+        {"org.codehaus.mojo", "failsafe-maven-plugin"},
+        {"org.codehaus.mojo", "shitty-maven-plugin"},};
+    private static final String[][] EXTENSIONS_TO_IGNORE = {
+        {"org.apache.maven.wagon", "wagon-ssh"},
+        {"org.apache.maven.wagon", "wagon-ssh-external"},
+        {"org.apache.maven.wagon", "wagon-ftp"},
+        {"org.apache.maven.wagon", "wagon-http"},
+        {"org.apache.maven.wagon", "wagon-http-lightweight"},
+        {"org.apache.maven.wagon", "wagon-scm"},};
+
     protected File baseDir;
+    protected File listOfPoms;
     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 List projectPoms = new ArrayList();
+    private List toResolve = 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 Set ignoreRules = new TreeSet();
+    private Set cleanIgnoreRules = new TreeSet();
+    private Set ignoredDependencies = new HashSet();
     private boolean checkedAptFile;
+    private boolean runTests;
+    private boolean generateJavadoc;
+    private boolean nonInteractive;
+    private boolean askedToFilterModules = false;
+    private boolean filterModules = false;
 
+    public void setRunTests(boolean b) {
+        this.runTests = b;
+    }
+
+    private void setGenerateJavadoc(boolean b) {
+        this.generateJavadoc = b;
+    }
+
+    private boolean containsPlugin(String[][] pluginDefinitions, Dependency plugin) {
+        for (int i = 0; i < pluginDefinitions.length; i++) {
+            if (!plugin.getGroupId().equals(pluginDefinitions[i][0])) {
+                continue;
+            }
+            if (plugin.getArtifactId().equals(pluginDefinitions[i][1])) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private boolean isJavadocPlugin(Dependency dependency) {
+        return containsPlugin(DOC_PLUGINS, dependency);
+    }
+
+    private boolean isTestPlugin(Dependency dependency) {
+        return containsPlugin(TEST_PLUGINS, dependency);
+    }
+
+    private boolean isDefaultMavenPlugin(Dependency dependency) {
+        if (repository != null && repository.getSuperPOM() != null) {
+            for (Iterator i = repository.getSuperPOM().getPluginManagement().iterator(); i.hasNext();) {
+                Dependency defaultPlugin = (Dependency) i.next();
+                if (defaultPlugin.equalsIgnoreVersion(dependency)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private boolean canIgnorePlugin(Dependency dependency) {
+        return containsPlugin(PLUGINS_TO_IGNORE, dependency);
+    }
+
+    private boolean canIgnoreExtension(Dependency dependency) {
+        return containsPlugin(EXTENSIONS_TO_IGNORE, dependency);
+    }
+
+    private boolean canBeIgnoredPlugin(Dependency dependency) {
+        return containsPlugin(PLUGINS_THAT_CAN_BE_IGNORED, dependency);
+    }
+
+    private boolean askIgnoreDependency(Dependency dependency, String message) {
+        if (nonInteractive) {
+            return false;
+        }
+        System.out.println(message);
+        System.out.println("  " + dependency);
+        System.out.print("[y]/n > ");
+        String s = System.console().readLine().trim().toLowerCase();
+        if (s.startsWith("n")) {
+            return false;
+        }
+        return true;
+    }
+
+    public void setNonInteractive(boolean nonInteractive) {
+        this.nonInteractive = nonInteractive;
+    }
+
+    private class ToResolve {
+
+        private final File sourcePom;
+        private final Collection poms;
+        private final boolean buildTime;
+        private final boolean mavenExtension;
+        private final boolean management;
+
+        private ToResolve(File sourcePom, Collection poms, boolean buildTime, boolean mavenExtension, boolean management) {
+            this.sourcePom = sourcePom;
+            this.poms = poms;
+            this.buildTime = buildTime;
+            this.mavenExtension = mavenExtension;
+            this.management = management;
+        }
+
+        public void resolve() {
+            resolveDependencies(sourcePom, poms, buildTime, mavenExtension, management);
+        }
+    }
+
     public File getBaseDir() {
         return baseDir;
     }
 
+    public File getListOfPoms() {
+        return listOfPoms;
+    }
+
+    public void setListOfPoms(File listOfPoms) {
+        this.listOfPoms = listOfPoms;
+    }
+
     public void saveListOfPoms() {
-        File listPoms = new File(outputDirectory, packageName + ".poms");
-        if (!listPoms.exists()) {
+        if (listOfPoms != null && !listOfPoms.exists()) {
             try {
-                PrintWriter out = new PrintWriter(new FileWriter(listPoms));
+                PrintWriter out = new PrintWriter(new FileWriter(listOfPoms));
                 for (Iterator i = pomsConfig.iterator(); i.hasNext();) {
                     String config = (String) i.next();
                     out.println(config);
                 }
+                out.flush();
                 out.close();
             } catch (Exception ex) {
                 Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
@@ -96,10 +274,29 @@
         if (!mavenRules.exists()) {
             try {
                 PrintWriter out = new PrintWriter(new FileWriter(mavenRules));
+                out.println("# Maven rules - transform Maven dependencies and plugins");
+                out.println("# Format of this file is:");
+                out.println("# [group] [artifact] [type] [version]");
+                out.println("# where each element can be either");
+                out.println("# - the exact string, for example org.apache for the group, or 3.1");
+                out.println("#   for the version. In this case, the element is simply matched");
+                out.println("#   and left as it is");
+                out.println("# - * (the star character, alone). In this case, anything will");
+                out.println("#   match and be left as it is. For example, using * on the");
+                out.println("#  position of the artifact field will match any artifact id");
+                out.println("# - a regular expression of the form s/match/replace/");
+                out.println("#   in this case, elements that match are transformed using");
+                out.println("#   the regex rule.");
+                out.println("# All elements much match before a rule can be applied");
+                out.println("# Example rule: match jar with groupid= junit, artifactid= junit");
+                out.println("# and version starting with 3., replacing the version with 3.x");
+                out.println("#   junit junit jar s/3\\..*/3.x/");
+
                 for (Iterator i = rules.iterator(); i.hasNext();) {
                     String rule = (String) i.next();
                     out.println(rule);
                 }
+                out.flush();
                 out.close();
             } catch (IOException ex) {
                 Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
@@ -107,6 +304,106 @@
         }
     }
 
+    public void saveMavenPublishedRules() {
+        File mavenRules = new File(outputDirectory, "maven.publishedRules");
+        if (!mavenRules.exists()) {
+            try {
+                PrintWriter out = new PrintWriter(new FileWriter(mavenRules));
+                out.println("# Maven published rules - additional rules to publish, to help");
+                out.println("# the packaging work of Debian maintainers using mh_make");
+                out.println("# Format of this file is:");
+                out.println("# [group] [artifact] [type] [version]");
+                out.println("# where each element can be either");
+                out.println("# - the exact string, for example org.apache for the group, or 3.1");
+                out.println("#   for the version. In this case, the element is simply matched");
+                out.println("#   and left as it is");
+                out.println("# - * (the star character, alone). In this case, anything will");
+                out.println("#   match and be left as it is. For example, using * on the");
+                out.println("#  position of the artifact field will match any artifact id");
+                out.println("# - a regular expression of the form s/match/replace/");
+                out.println("#   in this case, elements that match are transformed using");
+                out.println("#   the regex rule.");
+                out.println("# All elements much match before a rule can be applied");
+                out.println("# Example rule: match any dependency whose group is ant,");
+                out.println("# replacing it with org.apache.ant");
+                out.println("#   s/ant/org.apache.ant/ * * s/.*/debian/");
+
+                out.flush();
+                out.close();
+            } catch (IOException ex) {
+                Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    public void saveMavenIgnoreRules() {
+        File mavenRules = new File(outputDirectory, "maven.ignoreRules");
+        if (!mavenRules.exists()) {
+            try {
+                PrintWriter out = new PrintWriter(new FileWriter(mavenRules));
+                out.println("# Maven ignore rules - ignore some Maven dependencies and plugins");
+                out.println("# Format of this file is:");
+                out.println("# [group] [artifact] [type] [version]");
+                out.println("# where each element can be either");
+                out.println("# - the exact string, for example org.apache for the group, or 3.1");
+                out.println("#   for the version. In this case, the element is simply matched");
+                out.println("#   and left as it is");
+                out.println("# - * (the star character, alone). In this case, anything will");
+                out.println("#   match and be left as it is. For example, using * on the");
+                out.println("#  position of the artifact field will match any artifact id");
+                out.println("# All elements much match before a rule can be applied");
+                out.println("# Example rule: match jar with groupid= junit, artifactid= junit");
+                out.println("# and version starting with 3., this dependency is then removed");
+                out.println("# from the POM");
+                out.println("#   junit junit jar s/3\\..*/3.x/");
+
+                for (Iterator i = ignoreRules.iterator(); i.hasNext();) {
+                    String rule = (String) i.next();
+                    out.println(rule);
+                }
+
+                out.flush();
+                out.close();
+            } catch (IOException ex) {
+                Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    public void saveMavenCleanIgnoreRules() {
+        File mavenRules = new File(outputDirectory, "maven.cleanIgnoreRules");
+        if (!mavenRules.exists()) {
+            try {
+                PrintWriter out = new PrintWriter(new FileWriter(mavenRules));
+                out.println("# Maven clean ignore rules - ignore some Maven dependencies and plugins during the clean phase");
+                out.println("# Format of this file is:");
+                out.println("# [group] [artifact] [type] [version]");
+                out.println("# where each element can be either");
+                out.println("# - the exact string, for example org.apache for the group, or 3.1");
+                out.println("#   for the version. In this case, the element is simply matched");
+                out.println("#   and left as it is");
+                out.println("# - * (the star character, alone). In this case, anything will");
+                out.println("#   match and be left as it is. For example, using * on the");
+                out.println("#  position of the artifact field will match any artifact id");
+                out.println("# All elements much match before a rule can be applied");
+                out.println("# Example rule: match jar with groupid= junit, artifactid= junit");
+                out.println("# and version starting with 3., this dependency is then removed");
+                out.println("# from the POM");
+                out.println("#   junit junit jar s/3\\..*/3.x/");
+
+                for (Iterator i = cleanIgnoreRules.iterator(); i.hasNext();) {
+                    String rule = (String) i.next();
+                    out.println(rule);
+                }
+
+                out.flush();
+                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();
@@ -122,7 +419,7 @@
         depVars.put("maven.Depends", toString(runtimeDepends));
         depVars.put("maven.OptionalDepends", toString(optionalDepends));
         Set docRuntimeDepends = new TreeSet();
-        docRuntimeDepends.add("openjdk-6-doc | classpath-doc");
+        docRuntimeDepends.add("default-jdk-doc");
         for (Iterator i = runtimeDepends.iterator(); i.hasNext();) {
             docRuntimeDepends.add(i.next() + "-doc");
         }
@@ -225,9 +522,15 @@
             }
         }
 
-        for (Iterator i = issues.iterator(); i.hasNext();) {
-            String issue = (String) i.next();
-            System.err.println(issue);
+        resolveDependenciesNow();
+
+        if (!issues.isEmpty()) {
+            System.err.println("WARNING:");
+            for (Iterator i = issues.iterator(); i.hasNext();) {
+                String issue = (String) i.next();
+                System.err.println(issue);
+            }
+            System.err.println("--------");
         }
     }
 
@@ -236,34 +539,64 @@
         String pomRelPath = projectPom.getAbsolutePath().substring(baseDir.getAbsolutePath().length() + 1);
         try {
             POMInfo pom = reader.readPom(projectPom);
+            pom.setProperties(new HashMap());
+            pom.getProperties().put("debian.package", getPackageName());
+//            System.out.println("Register POM " + pom.getThisPom().getGroupId() + ":" + pom.getThisPom().getArtifactId()
+//                    + ":" + pom.getThisPom().getVersion());
             repository.registerPom(projectPom, pom);
 
+            if (filterModules) {
+                System.out.println("Include the module " + pomRelPath + " ?");
+                System.out.print("[y]/n > ");
+                String s = System.console().readLine().trim().toLowerCase();
+                boolean includeModule = !s.startsWith("n");
+                if (!includeModule) {
+                    pomsConfig.add(pomRelPath + " --ignore");
+                    String type = "*";
+                    if (pom.getThisPom().getType() != null) {
+                        type = pom.getThisPom().getType();
+                    }
+                    ignoreRules.add(pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
+                            + " " + type + " *");
+                    return;
+                }
+            }
+
             boolean noParent = false;
             if (pom.getParent() != null) {
                 POMInfo parentPom = repository.searchMatchingPOM(pom.getParent());
-                if (parentPom == null) {
+                if (parentPom == null || parentPom.equals(repository.getSuperPOM())) {
                     noParent = true;
                 }
                 if (!baseDir.equals(projectPom.getParentFile())) {
-                    System.out.println("Check the parent dependency in the sub project " + projectPom);
+//                    System.out.println("Checking the parent dependency in the sub project " + projectPom);
                     Set parentDependencies = new TreeSet();
                     parentDependencies.add(pom.getParent());
-                    resolveDependencies(parentDependencies, false, false);
+                    resolveDependenciesLater(projectPom, parentDependencies, false, false, false);
                 }
             }
 
+            projectPoms.add(pom.getThisPom());
             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);
+            resolveDependenciesLater(projectPom, pom.getDependencies(), false, false, false);
+            resolveDependenciesLater(projectPom, pom.getDependencyManagement(), false, false, true);
+            resolveDependenciesLater(projectPom, pom.getPlugins(), true, true, false);
+            resolveDependenciesLater(projectPom, pom.getPluginDependencies(), true, true, false);
+            resolveDependenciesLater(projectPom, pom.getPluginManagement(), true, true, true);
+            resolveDependenciesLater(projectPom, pom.getExtensions(), true, true, false);
 
-            if (exploreProjects) {
+            if (exploreProjects && !pom.getModules().isEmpty()) {
+                if (!nonInteractive && !askedToFilterModules) {
+                    System.out.println("This project contains modules. Include all modules?");
+                    System.out.print("[y]/n > ");
+                    String s = System.console().readLine().trim().toLowerCase();
+                    filterModules = s.startsWith("n");
+                }
                 for (Iterator i = pom.getModules().iterator(); i.hasNext();) {
                     String module = (String) i.next();
                     File modulePom = new File(projectPom.getParent(), module + "/pom.xml");
@@ -277,39 +610,94 @@
         }
     }
 
-    private void resolveDependencies(Collection poms, boolean buildTime, boolean mavenExtension) {
+    private void resolveDependenciesNow() {
+        for (Iterator i = toResolve.iterator(); i.hasNext();) {
+            ToResolve tr = (ToResolve) i.next();
+            tr.resolve();
+            i.remove();
+        }
+    }
+
+    private void resolveDependenciesLater(File sourcePom, Collection poms, boolean buildTime, boolean mavenExtension, boolean management) {
+        toResolve.add(new ToResolve(sourcePom, poms, buildTime, mavenExtension, management));
+    }
+
+    private void resolveDependencies(File sourcePom, Collection poms, boolean buildTime, boolean mavenExtension, boolean management) {
+        String sourcePomLoc = sourcePom.getAbsolutePath();
+        String baseDirPath = baseDir.getAbsolutePath();
+        sourcePomLoc = sourcePomLoc.substring(baseDirPath.length() + 1, sourcePomLoc.length());
+
+        nextDependency:
         for (Iterator i = poms.iterator(); i.hasNext();) {
             Dependency dependency = (Dependency) i.next();
+            if (containsDependencyIgnoreVersion(ignoredDependencies, dependency) ||
+                    (management && isDefaultMavenPlugin(dependency))) {
+                continue;
+            }
+
+            boolean ignoreDependency = false;
+            if (canIgnorePlugin(dependency)) {
+                ignoreDependency = askIgnoreDependency(dependency, "This plugin is not useful for the build or its use is against Debian policies. Ignore this plugin?");
+            } else if (canIgnoreExtension(dependency)) {
+                ignoreDependency = askIgnoreDependency(dependency, "This extension is not useful for the build or its use is against Debian policies. Ignore this extension?");
+            } else if (canBeIgnoredPlugin(dependency)) {
+                ignoreDependency = askIgnoreDependency(dependency, "This plugin may be ignored in some cases. Ignore this plugin?");
+            } else if (!runTests) {
+                if ("test".equals(dependency.getScope())) {
+                    ignoreDependency = askIgnoreDependency(dependency, "Tests are turned off. Ignore this test dependency?");
+                } else if (isTestPlugin(dependency)) {
+                    ignoreDependency = askIgnoreDependency(dependency, "Tests are turned off. Ignore this test plugin?");
+                }
+            } else if (!generateJavadoc && isJavadocPlugin(dependency)) {
+                ignoreDependency = askIgnoreDependency(dependency, "Documentation is turned off. Ignore this documentation plugin?");
+            }
+
+            if (ignoreDependency) {
+                ignoredDependencies.add(dependency);
+                ignoreRules.add(dependency.getGroupId() + " " + dependency.getArtifactId() + " maven-plugin *");
+                continue;
+            }
+
             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());
+                    issues.add(sourcePomLoc + ": 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() + "/");
+                    // Don't add a rule to force the version of a Maven plugin, it's now done
+                    // automatically at build time
                 }
             }
             if (pom == null) {
-                issues.add("Dependency is not packaged in the Maven repository for Debian: " + dependency.getGroupId() + ":" +
-                        dependency.getArtifactId() + ":" + dependency.getVersion());
+                if (!management) {
+                    issues.add(sourcePomLoc + ": Dependency is not packaged in the Maven repository for Debian: " + dependency.getGroupId() + ":"
+                            + dependency.getArtifactId() + ":" + dependency.getVersion());
+                }
                 return;
             }
+
+            // Handle the case of Maven plugins built and used in a multi-module build:
+            // they need to be added to maven.cleanIgnoreRules to avoid errors during
+            // a mvn clean
+            if ("maven-plugin".equals(dependency.getType()) && containsDependencyIgnoreVersion(projectPoms, dependency)) {
+                cleanIgnoreRules.add(dependency.getGroupId() + " " + dependency.getArtifactId() + " maven-plugin *");
+            }
+
+            // Discover the library to import for the dependency
             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());
+                issues.add(sourcePomLoc + ": 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 (library != null && !library.equals(getPackageName())) {
                 if (buildTime) {
                     if ("test".equals(dependency.getScope())) {
                         testDepends.add(library);
@@ -346,6 +734,16 @@
         }
     }
 
+    private boolean containsDependencyIgnoreVersion(Collection dependencies, Dependency dependency) {
+        for (Iterator j = dependencies.iterator(); j.hasNext();) {
+            Dependency ignoredDependency = (Dependency) j.next();
+            if (ignoredDependency.equalsIgnoreVersion(dependency)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     private String searchPkg(File pomFile) {
         GetPackageResult packageResult = new GetPackageResult();
         executeProcess(new String[]{"dpkg", "--search", pomFile.getAbsolutePath()}, packageResult);
@@ -481,6 +879,8 @@
             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");
+            System.out.println("  --run-tests: run the unit tests");
+            System.out.println("  --generate-javadoc: generate Javadoc");
             return;
         }
         DependenciesSolver solver = new DependenciesSolver();
@@ -501,15 +901,21 @@
                 debianPackage = arg.substring(2);
             } else if (arg.startsWith("--package=")) {
                 debianPackage = arg.substring("--package=".length());
-            } else if (arg.startsWith("--ant")) {
+            } else if (arg.equals("--ant")) {
                 packageType = "ant";
+            } else if (arg.equals("--run-tests")) {
+                solver.setRunTests(true);
+            } else if (arg.equals("--generate-javadoc")) {
+                solver.setGenerateJavadoc(true);
             }
             i = inc(i, args);
         }
+        File poms = new File(solver.getOutputDirectory(), debianPackage + ".poms");
 
         solver.setPackageName(debianPackage);
         solver.setPackageType(packageType);
         solver.setExploreProjects(true);
+        solver.setListOfPoms(poms);
 
         if (verbose) {
             System.out.println("Solving dependencies for package " + debianPackage);
@@ -519,6 +925,9 @@
 
         solver.saveListOfPoms();
         solver.saveMavenRules();
+        solver.saveMavenIgnoreRules();
+        solver.saveMavenCleanIgnoreRules();
+        solver.saveMavenPublishedRules();
         solver.saveSubstvars();
     }
 
@@ -528,5 +937,4 @@
         } while (i < args.length && args[i].isEmpty());
         return i;
     }
-
 }

Modified: 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	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm	2010-01-31 00:14:53 UTC (rev 11451)
@@ -21,9 +21,9 @@
 Build-Depends: debhelper (>= 7), cdbs, default-jdk, ant-optional, maven-ant-helper (>> 4)
 Build-Depends-Indep: maven-repo-helper,
 #printDependencies($compileDependencies)$space
-Standards-Version: 3.8.2
+Standards-Version: 3.8.3
 Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/${package}
-Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}/
+Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}
 Homepage:#if(${project.Url}) ${project.Url} #else TODO #end
 
 

Modified: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm	2010-01-31 00:14:53 UTC (rev 11451)
@@ -20,9 +20,9 @@
 Uploaders: ${packager} <${packagerEmail}>
 Build-Depends: debhelper (>= 7), cdbs, default-jdk, maven-debian-helper
 Build-Depends-Indep:#printDependencies($compileDependencies)$space
-Standards-Version: 3.8.2
+Standards-Version: 3.8.3
 Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/${package}
-Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}/
+Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}
 Homepage:#if(${project.Url}) ${project.Url} #else TODO #end
 
 

Modified: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm	2010-01-31 00:14:53 UTC (rev 11451)
@@ -62,7 +62,7 @@
 
 
 Files: debian/*
-Copyright: Copyright ${currentYear}, ${packager} <${packagerEmail}>
+Copyright: ${currentYear}, ${packager} <${packagerEmail}>
 License: ${packagerLicense}
 #set ($license = "${packagerLicense}")
 #set ($license = $license.replace("+",""))

Modified: 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	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.properties.vm	2010-01-31 00:14:53 UTC (rev 11451)
@@ -1,3 +1,8 @@
+#set( $H = '#' )
+$H Include here properties to pass to Maven during the build.
+$H For example:
+$H maven.test.skip=true
+
 #if(!$runTests)
 maven.test.skip=true
 #end

Modified: trunk/maven-debian-helper/pom.xml
===================================================================
--- trunk/maven-debian-helper/pom.xml	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/pom.xml	2010-01-31 00:14:53 UTC (rev 11451)
@@ -11,6 +11,7 @@
   <modules>
     <module>maven-debian-helper</module>
     <module>maven-debian-plugin</module>
+    <module>maven-build-no-docs</module>
     <module>maven-packager-utils</module>
   </modules>
   
@@ -31,4 +32,4 @@
       <version>1.5.8</version>
     </dependency>
   </dependencies>
-</project>
\ No newline at end of file
+</project>

Modified: trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk
===================================================================
--- trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk	2010-01-31 00:14:53 UTC (rev 11451)
@@ -28,13 +28,14 @@
 
 # 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)
+CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), maven-debian-helper (>> 0.7)
 
 # Maven home directory.  Doesn't need to be changed except when using
 # nonstandard Maven installations.
 MAVEN_HOME = /usr/share/maven2
 
 MAVEN_DEBIAN_VERSION = $(shell ls /usr/share/maven-repo/org/debian/maven/maven-packager-utils/ | sed 's|/||')
+MAVEN_CLASSCONF = /etc/maven2/m2-debian.conf
 
 # 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
@@ -66,6 +67,14 @@
 # Extra arguments for the mh_patchpoms command line
 DEB_PATCHPOMS_ARGS=
 
+# The name of the binary package that gets the jar files installed. The
+# 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 = $(firstword $(shell dh_listpackages | grep -v $(DEB_JAR_PACKAGE) | grep "-doc"))
+
 # Property file for Maven, defaults to debian/maven.properties if it exists.
 # You may define additional properties. Please note that command-line
 # arguments in MAVEN_ARGS (see below) override the settings in pom.xml and
@@ -76,20 +85,12 @@
 # command-line arguments in MAVEN_ARGS. You can additionally define
 # MAVEN_ARGS_<package> for each individual package.
 DEB_MAVEN_INVOKE = cd $(DEB_BUILDDIR) && $(JAVACMD) -noverify -cp $(DEB_CLASSPATH) \
-		 $(JAVA_OPTS) -Dclassworlds.conf=/etc/maven2/m2-debian.conf \
+		 $(JAVA_OPTS) -Dclassworlds.conf=$(MAVEN_CLASSCONF) \
 		 org.codehaus.classworlds.Launcher $(DEB_MAVEN_ARGS) \
 		 -s/etc/maven2/settings-debian.xml \
 		 -Dmaven.repo.local=$(DEB_MAVEN_REPO) \
 		 $(if $(MAVEN_ARGS_$(cdbs_curpkg)),$(MAVEN_ARGS_$(cdbs_curpkg)),$(MAVEN_ARGS))
 
-# The name of the binary package that gets the jar files installed. The
-# 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

Modified: trunk/maven-debian-helper/share/cdbs/1/class/maven.mk
===================================================================
--- trunk/maven-debian-helper/share/cdbs/1/class/maven.mk	2010-01-30 23:59:12 UTC (rev 11450)
+++ trunk/maven-debian-helper/share/cdbs/1/class/maven.mk	2010-01-31 00:14:53 UTC (rev 11451)
@@ -57,8 +57,13 @@
 debian/maven.rules:
 	mh_lspoms -p$(DEB_JAR_PACKAGE) --force
 
-debian/stamp-poms-patched:
-	mh_patchpoms -p$(DEB_JAR_PACKAGE) --keep-pom-version $(DEB_PATCHPOMS_ARGS)
+ifeq (, $(DEB_DOC_PACKAGE))
+DEB_PATCHPOMS_ARGS += --build-no-docs
+debian/stamp-maven-build: override MAVEN_CLASSCONF = /etc/maven2/m2-debian-nodocs.conf
+endif
+
+debian/stamp-poms-patched: debian/maven-repo
+	mh_patchpoms -p$(DEB_JAR_PACKAGE) --debian-build --keep-pom-version --maven-repo=$(DEB_MAVEN_REPO) $(DEB_PATCHPOMS_ARGS)
 	touch debian/stamp-poms-patched
 
 patch-poms: debian/$(DEB_JAR_PACKAGE).poms debian/maven.rules debian/stamp-poms-patched
@@ -79,20 +84,22 @@
 	$(DEB_MAVEN_INVOKE) $(DEB_MAVEN_BUILD_TARGET)
 	touch $@
 
+cleanbuilddir:: DEB_PATCHPOMS_ARGS += --clean-ignore-rules=debian/maven.cleanIgnoreRules
 cleanbuilddir:: maven-sanity-check post-patches debian/maven-repo
 	-$(DEB_MAVEN_INVOKE) $(DEB_MAVEN_CLEAN_TARGET)
 	$(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)
 	$(if $(cdbs_use_maven_substvars), $(RM) debian/*.substvars)
+	$(MAKE) -f debian/rules unpatch-poms
 
 # extra arguments for the installation step
-PLUGIN_ARGS = -Ddebian.dir=$(CURDIR)/debian -Ddebian.package=$(DEB_JAR_PACKAGE)
+PLUGIN_ARGS = -Ddebian.dir=$(CURDIR)/debian -Ddebian.package=$(DEB_JAR_PACKAGE) -Dmaven.repo.local=$(DEB_MAVEN_REPO)
 
 common-install-arch common-install-indep:: common-install-impl
 common-install-impl::
 	$(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))
+	$(if $(cdbs_use_maven_substvars), mh_resolve_dependencies --non-interactive -p$(DEB_JAR_PACKAGE))
 
 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
 common-build-arch common-build-indep:: debian/stamp-maven-check




More information about the pkg-java-commits mailing list