[pkg-java] r12812 - in trunk/maven-debian-helper: . bin debian maven-build-nodocs maven-debian-helper maven-debian-plugin maven-debian-plugin/src/main/java/org/debian/maven/plugin maven-packager-utils maven-packager-utils/src/main/java/org/debian/maven/packager maven-packager-utils/src/main/resources maven-packager-utils/src/test/java/org/debian/maven/packager maven-packager-utils/src/test/resources share/cdbs/1/class

Ludovic Claude ludovicc-guest at alioth.debian.org
Sun Jul 25 20:43:01 UTC 2010


Author: ludovicc-guest
Date: 2010-07-25 20:42:58 +0000 (Sun, 25 Jul 2010)
New Revision: 12812

Added:
   trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.cleanIgnoreRules.description
   trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.ignoreRules.description
   trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.publishedRules.description
   trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.rules.description
Modified:
   trunk/maven-debian-helper/bin/mh_make
   trunk/maven-debian-helper/debian/changelog
   trunk/maven-debian-helper/debian/control
   trunk/maven-debian-helper/debian/install
   trunk/maven-debian-helper/debian/rules
   trunk/maven-debian-helper/maven-build-nodocs/pom.xml
   trunk/maven-debian-helper/maven-debian-helper/pom.xml
   trunk/maven-debian-helper/maven-debian-plugin/pom.xml
   trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallDocMojo.java
   trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java
   trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
   trunk/maven-debian-helper/maven-packager-utils/pom.xml
   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/test/java/org/debian/maven/packager/DependenciesSolverTest.java
   trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.rules
   trunk/maven-debian-helper/pom.xml
   trunk/maven-debian-helper/share/cdbs/1/class/maven.mk
Log:
* debian/control: Update Standards-Version to 3.9.0, no changes
* Fix compilation issues with gcj
* mh_make: 
    - update generated control to use Standards-Version 3.9.0
    - improve useability and recognize more plugins and extensions
    - read existing maven rules in debian folder, don't ask twice the
      same questions.
* Support installing build artifacts in different packages with the
  --package option in the <package>.poms file
* Add mvn-build to phony rules to avoid creating a file called
  mvn-build during the build (Closes: #589635)

Modified: trunk/maven-debian-helper/bin/mh_make
===================================================================
--- trunk/maven-debian-helper/bin/mh_make	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/bin/mh_make	2010-07-25 20:42:58 UTC (rev 12812)
@@ -74,6 +74,7 @@
 	if [ -n "$FROM_SVN" ]; then
 		PACKAGE=$(basename ${FROM_SVN%%/tags/*} | sed 's/-[0-9\.].*//' )
 	fi
+	echo
     echo "Enter the name of the new Debian source package. If empty, it will defaults to $PACKAGE"
     read -p ">" USER_PACKAGE
     if [ -n "$USER_PACKAGE" ]; then
@@ -82,7 +83,13 @@
 fi
 
 if [ -z "$BIN_PACKAGE" ]; then
-    BIN_PACKAGE="lib${PACKAGE}-java"
+    PKG=$PACKAGE
+    if [ -z "${PKG##lib*-java}" ]; then
+        BIN_PACKAGE="${PACKAGE}"
+    else
+        BIN_PACKAGE="lib${PACKAGE}-java"
+    fi
+	echo
     echo "Enter the name of the binary package. If empty, it will defaults to $BIN_PACKAGE"
     read -p ">" USER_PACKAGE
     if [ -n "$USER_PACKAGE" ]; then
@@ -91,18 +98,22 @@
 fi
 
 if [ -z "$RUN_TESTS" ]; then
-    echo "Enter y (yes) or n (no) to run tests while building the package. Defaults to no"
-    read -p ">" RUN
-    if [ "$RUN" == "y" ]; then
-        RUN_TESTS="true"
+	echo
+    echo "Run tests while building the package?"
+    read -p "[y]/n > " RUN
+    RUN_TESTS="true"
+    if [ "$RUN" == "n" ]; then
+        RUN_TESTS="false"
     fi
 fi
 
 if [ -z "$GEN_JAVADOC" ]; then
-    echo "Enter y (yes) or n (no) to generate the Javadoc while building the package. Defaults to no"
-    read -p ">" GEN
-    if [ "$GEN" == "y" ]; then
-        GEN_JAVADOC="true"
+	echo
+    echo "Generate the Javadoc while building the package?"
+    read -p "[y]/n > " GEN
+    GEN_JAVADOC="true"
+    if [ "$GEN" == "n" ]; then
+        GEN_JAVADOC="false"
     fi
 fi
 
@@ -122,8 +133,12 @@
 
 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
+if [ $? != 0 ]; then
+    return
+fi
 
+mh_patchpoms -p$BIN_PACKAGE --debian-build -rdebian/maven.rules -idebian/maven.ignoreRules --keep-pom-version --maven-repo=debian/maven-repo
+
 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
@@ -137,3 +152,4 @@
     dch --create --newversion=${version}-1 --package=$PACKAGE "Initial release (Closes: #nnnn)  <nnnn is the bug number of your ITP>"
 fi
 
+mh_unpatchpoms -p$BIN_PACKAGE

Modified: trunk/maven-debian-helper/debian/changelog
===================================================================
--- trunk/maven-debian-helper/debian/changelog	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/debian/changelog	2010-07-25 20:42:58 UTC (rev 12812)
@@ -1,3 +1,19 @@
+maven-debian-helper (1.1) unstable; urgency=low
+
+  * debian/control: Update Standards-Version to 3.9.0, no changes
+  * Fix compilation issues with gcj
+  * mh_make: 
+      - update generated control to use Standards-Version 3.9.0
+      - improve useability and recognize more plugins and extensions
+      - read existing maven rules in debian folder, don't ask twice the
+        same questions.
+  * Support installing build artifacts in different packages with the
+    --package option in the <package>.poms file
+  * Add mvn-build to phony rules to avoid creating a file called
+    mvn-build during the build (Closes: #589635)
+
+ -- Ludovic Claude <ludovic.claude at laposte.net>  Mon, 28 Jun 2010 23:10:50 +0200
+
 maven-debian-helper (1.0) unstable; urgency=low
 
   * debian/control:

Modified: trunk/maven-debian-helper/debian/control
===================================================================
--- trunk/maven-debian-helper/debian/control	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/debian/control	2010-07-25 20:42:58 UTC (rev 12812)
@@ -5,17 +5,17 @@
 Uploaders: Torsten Werner <twerner at debian.org>, Ludovic Claude <ludovic.claude at laposte.net>,
  Michael Koch <konqueror at gmx.de>, Damien Raude-Morvan <drazzib at debian.org>
 Build-Depends: cdbs, debhelper (>= 7), default-jdk, maven-ant-helper (>> 4), ant-optional, help2man
-Build-Depends-Indep: maven-repo-helper (>> 0.5),
+Build-Depends-Indep: maven-repo-helper (>= 1.2),
  junit, testng, libmaven-plugin-tools-java, libplexus-velocity-java, velocity,
  libmaven2-core-java
-Standards-Version: 3.8.4
+Standards-Version: 3.9.0
 Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/maven-debian-helper
 Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/maven-debian-helper/
 Homepage: http://wiki.debian.org/Java/MavenBuilder
 
 Package: maven-debian-helper
 Architecture: all
-Depends: ${misc:Depends}, default-jdk, maven-repo-helper (>= 1.1), maven2 (>= 2.2.1-5),
+Depends: ${misc:Depends}, default-jdk, maven-repo-helper (>= 1.2), maven2 (>= 2.2.1-5),
  libmaven-clean-plugin-java, libmaven-resources-plugin-java,
  libmaven-compiler-plugin-java, libmaven-jar-plugin-java, libmaven-site-plugin-java,
  libsurefire-java, velocity, libplexus-velocity-java

Modified: trunk/maven-debian-helper/debian/install
===================================================================
--- trunk/maven-debian-helper/debian/install	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/debian/install	2010-07-25 20:42:58 UTC (rev 12812)
@@ -4,4 +4,3 @@
 etc/*.xml			/etc/maven2/
 share/cdbs/1/class/*.mk		/usr/share/cdbs/1/class
 share/maven-debian-helper/*.sh	/usr/share/maven-debian-helper
-

Modified: trunk/maven-debian-helper/debian/rules
===================================================================
--- trunk/maven-debian-helper/debian/rules	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/debian/rules	2010-07-25 20:42:58 UTC (rev 12812)
@@ -57,4 +57,3 @@
 	-$(RM) man/mvn-debian.1
 	mh_unpatchpoms -p$(PACKAGE)
 	mh_clean
-

Modified: trunk/maven-debian-helper/maven-build-nodocs/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-build-nodocs/pom.xml	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-build-nodocs/pom.xml	2010-07-25 20:42:58 UTC (rev 12812)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.debian.maven</groupId>
     <artifactId>maven-debian</artifactId>
-    <version>1.0</version>
+    <version>1.1</version>
   </parent>
 
   <artifactId>maven-build-nodocs</artifactId>

Modified: trunk/maven-debian-helper/maven-debian-helper/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-debian-helper/pom.xml	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-debian-helper/pom.xml	2010-07-25 20:42:58 UTC (rev 12812)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.debian.maven</groupId>
     <artifactId>maven-debian</artifactId>
-    <version>1.0</version>
+    <version>1.1</version>
   </parent>
 
   <artifactId>maven-debian-helper</artifactId>

Modified: trunk/maven-debian-helper/maven-debian-plugin/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/pom.xml	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-debian-plugin/pom.xml	2010-07-25 20:42:58 UTC (rev 12812)
@@ -5,7 +5,7 @@
   <parent>
     <artifactId>maven-debian</artifactId>
     <groupId>org.debian.maven</groupId>
-    <version>1.0</version>
+    <version>1.1</version>
   </parent>
   
   <artifactId>maven-debian-plugin</artifactId>

Modified: trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallDocMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallDocMojo.java	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallDocMojo.java	2010-07-25 20:42:58 UTC (rev 12812)
@@ -42,7 +42,7 @@
       if (useMavenRepoLocal) {
           return mavenRepoLocal.getAbsolutePath();
       } else {
-          return getDebianDir() + "/" + getDebianPackage();
+          return getDebianDir() + "/" + getDestPackage();
       }
   }
 

Modified: trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java	2010-07-25 20:42:58 UTC (rev 12812)
@@ -40,7 +40,7 @@
     if (useMavenRepoLocal) {
         return mavenRepoLocal.getAbsolutePath();
     } else {
-        return getDebianDir() + "/" + getDebianPackage();
+        return getDebianDir() + "/" + getDestPackage();
     }
   }
 

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-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java	2010-07-25 20:42:58 UTC (rev 12812)
@@ -10,6 +10,7 @@
 import org.codehaus.plexus.util.FileUtils;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.debian.maven.repo.ListOfPOMs;
 import org.debian.maven.repo.POMCleaner;
 import org.debian.maven.repo.POMTransformer;
 
@@ -105,6 +106,7 @@
    * @parameter expression="${debian.package}"
    */
   private String debianPackage;
+  private String destPackage;
 
   /**
    * @parameter expression="${maven.rules}" default-value="maven.rules"
@@ -177,6 +179,11 @@
       return debianPackage;
   }
 
+  protected String getDestPackage()
+  {
+      return destPackage;    
+  }
+
   /**
    * optional destination prefix, empty by default
    */
@@ -402,34 +409,51 @@
   private void cleanPom()
   {
     File pomOptionsFile = new File(debianDir, debianPackage + ".poms");
-    Map pomOptions = POMTransformer.getPomOptions(pomOptionsFile);
+    ListOfPOMs listOfPOMs = new ListOfPOMs(pomOptionsFile);
+
     // Use the saved pom before cleaning as it was untouched by the transform operation
-    File pom = new File(pomSrcPath() + ".save");
-    File originalPom = new File(pomSrcPath()).getAbsoluteFile();
-    if (! pom.exists())
+    String pomPath = pomSrcPath() + ".save";
+    File pomFile = new File(pomPath);
+    String originalPomPath = pomSrcPath();
+    File originalPom = new File(originalPomPath);
+    if (! pomFile.exists())
     {
-        pom = originalPom;
+        pomFile = originalPom;
+        pomPath = originalPomPath;
     }
 
-    String pomOption = (String) pomOptions.get(originalPom);
+    String relativePomPath = originalPom.getAbsolutePath();
+    relativePomPath = relativePomPath.substring(debianDir.getParentFile().getAbsolutePath().length() + 1);
 
+    ListOfPOMs.POMOptions pomOption = listOfPOMs.getPOMOptions(relativePomPath);
+
+    if (pomOption != null && pomOption.isIgnore()) {
+        throw new RuntimeException("POM file " + pomFile + " should be ignored");
+    }
+
+    destPackage = debianPackage;
+    if (pomOption != null && pomOption.getDestPackage() != null) {
+      destPackage = pomOption.getDestPackage();
+    }
+
     List params = new ArrayList();
     params.add("--keep-pom-version");
-    params.add("--package=" + debianPackage);
+      
+    params.add("--package=" + destPackage);
     String mavenRulesPath = new File(debianDir, mavenRules).getAbsolutePath();
     params.add("--rules=" + mavenRulesPath);
 
-    System.out.println("Cleaning pom file: " + pom + " with options:");
-    System.out.println("\t--keep-pom-version --package=" + debianPackage);
+    System.out.println("Cleaning pom file: " + pomFile + " with options:");
+    System.out.println("\t--keep-pom-version --package=" + destPackage);
     System.out.println("\t--rules=" + mavenRulesPath);
 
     // add optional --no-parent option
-    if (pomOption != null && !pomOption.isEmpty()) {
-        params.add(pomOption);
-        System.out.println("\t" + pomOption);
+    if (pomOption != null && pomOption.isNoParent()) {
+        params.add("--no-parent");
+        System.out.println("\t--no-parent");
     }
     
-    params.add(pom.getAbsolutePath());
+    params.add(pomFile.getAbsolutePath());
     params.add(cleanedPomSrcPath());
     params.add(cleanedPomPropertiesSrcPath());
 

Modified: trunk/maven-debian-helper/maven-packager-utils/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/pom.xml	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-packager-utils/pom.xml	2010-07-25 20:42:58 UTC (rev 12812)
@@ -5,7 +5,7 @@
     <parent>
       <artifactId>maven-debian</artifactId>
       <groupId>org.debian.maven</groupId>
-      <version>1.0</version>
+      <version>1.1</version>
     </parent>
 
     <artifactId>maven-packager-utils</artifactId>
@@ -47,7 +47,7 @@
         <dependency>
             <groupId>org.debian.maven</groupId>
             <artifactId>maven-repo-helper</artifactId>
-            <version>1.1</version>
+            <version>1.2</version>
         </dependency>
         <dependency>
             <groupId>commons-io</groupId>

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-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesMojo.java	2010-07-25 20:42:58 UTC (rev 12812)
@@ -113,9 +113,7 @@
         solver.setPackageName(packageName);
         solver.setPackageType(packageType);
         solver.setNonInteractive(nonInteractive);
-        if (listOfPoms != null) {
-            solver.setListOfPoms(listOfPoms);
-        }
+        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-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java	2010-07-25 20:42:58 UTC (rev 12812)
@@ -15,19 +15,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
+import java.io.*;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.xml.stream.XMLStreamException;
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -42,11 +34,9 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
-import org.debian.maven.repo.Dependency;
-import org.debian.maven.repo.POMInfo;
-import org.debian.maven.repo.POMReader;
-import org.debian.maven.repo.Repository;
 
+import org.debian.maven.repo.*;
+
 /**
  * Analyze the Maven dependencies and extract the Maven rules to use
  * as well as the list of dependent packages.
@@ -55,11 +45,14 @@
  */
 public class DependenciesSolver {
 
+    private static final Logger log = Logger.getLogger(DependenciesSolver.class.getName());
+
     // 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", "changelog-maven-plugin"},
         {"org.apache.maven.plugins", "maven-deploy-plugin"},
         {"org.apache.maven.plugins", "maven-release-plugin"},
         {"org.apache.maven.plugins", "maven-remote-resources-plugin"},
@@ -68,6 +61,8 @@
         {"org.apache.maven.plugins", "maven-stage-plugin"},
         {"org.apache.maven.plugins", "maven-eclipse-plugin"},
         {"org.apache.maven.plugins", "maven-idea-plugin"},
+        {"org.apache.maven.plugins", "maven-source-plugin"},
+        {"org.codehaus.mojo", "changelog-maven-plugin"},
         {"org.codehaus.mojo", "netbeans-freeform-maven-plugin"},
         {"org.codehaus.mojo", "nbm-maven-plugin"},
         {"org.codehaus.mojo", "ideauidesigner-maven-plugin"},
@@ -86,6 +81,7 @@
         {"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-clover-plugin"},
         {"org.apache.maven.plugins", "maven-docck-plugin"},
         {"org.apache.maven.plugins", "maven-javadoc-plugin"},
         {"org.apache.maven.plugins", "maven-jxr-plugin"},
@@ -94,6 +90,7 @@
         {"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", "changes-maven-plugin"},
         {"org.codehaus.mojo", "clirr-maven-plugin"},
         {"org.codehaus.mojo", "cobertura-maven-plugin"},
         {"org.codehaus.mojo", "taglist-maven-plugin"},
@@ -101,9 +98,12 @@
         {"org.codehaus.mojo", "docbook-maven-plugin"},
         {"org.codehaus.mojo", "javancss-maven-plugin"},
         {"org.codehaus.mojo", "jdepend-maven-plugin"},
+        {"org.codehaus.mojo", "jxr-maven-plugin"},
         {"org.codehaus.mojo", "dashboard-maven-plugin"},
         {"org.codehaus.mojo", "emma-maven-plugin"},
-        {"org.codehaus.mojo", "sonar-maven-plugin"},};
+        {"org.codehaus.mojo", "sonar-maven-plugin"},
+        {"org.jboss.maven.plugins", "maven-jdocbook-plugin"},
+    };
     private static final String[][] TEST_PLUGINS = {
         {"org.apache.maven.plugins", "maven-failsafe-plugin"},
         {"org.apache.maven.plugins", "maven-surefire-plugin"},
@@ -120,10 +120,13 @@
         {"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"},};
+        {"org.apache.maven.wagon", "wagon-scm"},
+        {"org.apache.maven.wagon", "wagon-webdav"},
+        {"org.jvnet.wagon-svn", "wagon-svn"},
+    };
 
     protected File baseDir;
-    protected File listOfPoms;
+    protected POMTransformer pomTransformer = new POMTransformer();
     protected File outputDirectory;
     protected String packageName;
     protected String packageType;
@@ -132,17 +135,16 @@
     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 knownProjectDependencies = new HashSet();
+    private Set ignoredDependencies = new TreeSet();
     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 DependencyRuleSet cleanIgnoreRules = new DependencyRuleSet("Ignore rules to be applied during the Maven clean phase",
+            new File("debian/maven.cleanIgnoreRules"));
     private boolean checkedAptFile;
     private boolean runTests;
     private boolean generateJavadoc;
@@ -150,6 +152,31 @@
     private boolean askedToFilterModules = false;
     private boolean filterModules = false;
 
+    public DependenciesSolver() {
+        pomTransformer.setVerbose(true);
+        pomTransformer.getRules().setDescription(readResource("maven.rules.description"));
+        pomTransformer.getIgnoreRules().setDescription(readResource("maven.ignoreRules.description"));
+        pomTransformer.getPublishedRules().setDescription(readResource("maven.publishedRules.description"));
+        cleanIgnoreRules.setDescription(readResource("maven.cleanIgnoreRules.description"));
+    }
+
+    private static String readResource(String resource) {
+        StringBuffer sb = new StringBuffer();
+        try {
+            InputStream is = DependenciesSolver.class.getResourceAsStream("/" + resource);
+            LineNumberReader r = new LineNumberReader(new InputStreamReader(is));
+            String line;
+            while ((line = r.readLine()) != null) {
+                sb.append(line);
+                sb.append("\n");
+            }
+            r.close();
+        } catch (IOException e) {
+            log.log(Level.SEVERE, "Cannot read resource " + resource, e);
+        }
+        return sb.toString();
+    }
+
     public void setRunTests(boolean b) {
         this.runTests = b;
     }
@@ -170,7 +197,7 @@
         return false;
     }
 
-    private boolean isJavadocPlugin(Dependency dependency) {
+    private boolean isDocumentationOrReportPlugin(Dependency dependency) {
         return containsPlugin(DOC_PLUGINS, dependency);
     }
 
@@ -179,8 +206,8 @@
     }
 
     private boolean isDefaultMavenPlugin(Dependency dependency) {
-        if (repository != null && repository.getSuperPOM() != null) {
-            for (Iterator i = repository.getSuperPOM().getPluginManagement().iterator(); i.hasNext();) {
+        if (getRepository() != null && getRepository().getSuperPOM() != null) {
+            for (Iterator i = getRepository().getSuperPOM().getPluginManagement().iterator(); i.hasNext();) {
                 Dependency defaultPlugin = (Dependency) i.next();
                 if (defaultPlugin.equalsIgnoreVersion(dependency)) {
                     return true;
@@ -202,18 +229,29 @@
         return containsPlugin(PLUGINS_THAT_CAN_BE_IGNORED, dependency);
     }
 
-    private boolean askIgnoreDependency(Dependency dependency, String message) {
+    private boolean askIgnoreDependency(String sourcePomLoc, Dependency dependency, String message) {
+        return askIgnoreDependency(sourcePomLoc, dependency, message, true);
+    }
+
+    private boolean askIgnoreDependency(String sourcePomLoc, Dependency dependency, String message, boolean defaultToIgnore) {
         if (nonInteractive) {
             return false;
         }
+        System.out.println();
+        System.out.println("In " + sourcePomLoc + ":");
         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;
+        if (defaultToIgnore) {
+            System.out.print("[y]/n > ");
+        } else {
+            System.out.print("y/[n] > ");
         }
-        return true;
+        String s = readLine().trim().toLowerCase();
+        if (defaultToIgnore) {
+            return !s.startsWith("n");
+        } else {
+            return s.startsWith("y");
+        }
     }
 
     public void setNonInteractive(boolean nonInteractive) {
@@ -223,21 +261,25 @@
     private class ToResolve {
 
         private final File sourcePom;
-        private final Collection poms;
+        private final String listType;
         private final boolean buildTime;
         private final boolean mavenExtension;
         private final boolean management;
 
-        private ToResolve(File sourcePom, Collection poms, boolean buildTime, boolean mavenExtension, boolean management) {
+        private ToResolve(File sourcePom, String listType, boolean buildTime, boolean mavenExtension, boolean management) {
             this.sourcePom = sourcePom;
-            this.poms = poms;
+            this.listType = listType;
             this.buildTime = buildTime;
             this.mavenExtension = mavenExtension;
             this.management = management;
         }
 
         public void resolve() {
-            resolveDependencies(sourcePom, poms, buildTime, mavenExtension, management);
+            try {
+                resolveDependencies(sourcePom, listType, buildTime, mavenExtension, management);
+            } catch (Exception e) {
+                log.log(Level.SEVERE, "Cannot resolve dependencies on " + sourcePom, e);
+            }
         }
     }
 
@@ -245,169 +287,24 @@
         return baseDir;
     }
 
-    public File getListOfPoms() {
-        return listOfPoms;
-    }
-
-    public void setListOfPoms(File listOfPoms) {
-        this.listOfPoms = listOfPoms;
-    }
-
     public void saveListOfPoms() {
-        if (listOfPoms != null && !listOfPoms.exists()) {
-            try {
-                PrintWriter out = new PrintWriter(new FileWriter(listOfPoms));
-                out.println("# List of POM files for the package");
-                out.println("# Format of this file is:");
-                out.println("# <path to pom file> [option]");
-                out.println("# where option can be:");
-                out.println("#   --ignore: ignore this POM or");
-                out.println("#   --no-parent: remove the <parent> tag from the POM");
-                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);
-            }
-        }
+        pomTransformer.getListOfPOMs().save();
     }
 
     public void saveMavenRules() {
-        File mavenRules = new File(outputDirectory, "maven.rules");
-        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);
-            }
-        }
+        pomTransformer.getRules().save();
     }
 
     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);
-            }
-        }
+        pomTransformer.getPublishedRules().save();
     }
 
     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);
-            }
-        }
+        pomTransformer.getIgnoreRules().save();
     }
 
     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);
-            }
-        }
+        cleanIgnoreRules.save();
     }
 
     public void saveSubstvars() {
@@ -417,7 +314,7 @@
             try {
                 depVars.load(new FileReader(dependencies));
             } catch (IOException ex) {
-                Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+                log.log(Level.SEVERE, "Error while reading file " + dependencies, ex);
             }
         }
         depVars.put("maven.CompileDepends", toString(compileDepends));
@@ -436,9 +333,9 @@
         depVars.put("maven.DocDepends", toString(docRuntimeDepends));
         depVars.put("maven.DocOptionalDepends", toString(docOptionalDepends));
         try {
-            depVars.store(new FileWriter(dependencies), "List of dependencies for " + packageName + ", generated for use by debian/control");
+            depVars.store(new FileOutputStream(dependencies), "List of dependencies for " + packageName + ", generated for use by debian/control");
         } catch (IOException ex) {
-            Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+            log.log(Level.SEVERE, "Error while saving file " + dependencies, ex);
         }
     }
 
@@ -446,6 +343,14 @@
         this.baseDir = baseDir;
     }
 
+    public void setListOfPoms(File listOfPoms) {
+        if (pomTransformer.getListOfPOMs() == null) {
+            pomTransformer.setListOfPOMs(new ListOfPOMs(listOfPoms));
+        } else {
+            pomTransformer.getListOfPOMs().setListOfPOMsFile(listOfPoms);
+        }
+    }
+
     public boolean isExploreProjects() {
         return exploreProjects;
     }
@@ -468,6 +373,10 @@
 
     public void setOutputDirectory(File outputDirectory) {
         this.outputDirectory = outputDirectory;
+        pomTransformer.getRules().setRulesFile(new File(outputDirectory, "maven.rules"));
+        pomTransformer.getIgnoreRules().setRulesFile(new File(outputDirectory, "maven.ignoreRules"));
+        pomTransformer.getPublishedRules().setRulesFile(new File(outputDirectory, "maven.publishedRules"));
+        cleanIgnoreRules.setRulesFile(new File(outputDirectory, "maven.cleanIgnoreRules"));
     }
 
     public String getPackageName() {
@@ -498,15 +407,23 @@
         return issues;
     }
 
+    private Repository getRepository() {
+        if (repository == null && mavenRepo != null) {
+            repository = new Repository(mavenRepo);
+            repository.scan();
+        }
+        return repository;
+    }
+
     public void solveDependencies() {
+        pomTransformer.setRepository(getRepository());
+        pomTransformer.usePluginVersionsFromRepository();
+
         File f = outputDirectory;
         if (!f.exists()) {
             f.mkdirs();
         }
 
-        repository = new Repository((mavenRepo));
-        repository.scan();
-
         if (exploreProjects) {
             File pom = new File(baseDir, "pom.xml");
             if (pom.exists()) {
@@ -531,7 +448,7 @@
         resolveDependenciesNow();
 
         if (!issues.isEmpty()) {
-            System.err.println("WARNING:");
+            System.err.println("ERROR:");
             for (Iterator i = issues.iterator(); i.hasNext();) {
                 String issue = (String) i.next();
                 System.err.println(issue);
@@ -541,67 +458,82 @@
     }
 
     private void resolveDependencies(File projectPom) {
-        POMReader reader = new POMReader();
         String pomRelPath = projectPom.getAbsolutePath().substring(baseDir.getAbsolutePath().length() + 1);
+        boolean noParent = false;
+
         try {
-            POMInfo pom = reader.readPom(projectPom);
+            POMInfo pom = getPOM(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);
+            try {
+                getRepository().registerPom(projectPom, pom);
+            } catch (DependencyNotFoundException e) {
+                System.out.println("Cannot find parent dependency " + e.getDependency());
+                if (!nonInteractive) {
+                    noParent = askIgnoreDependency(pomRelPath, pom.getParent(), "Ignore the parent POM for this POM?");
+                    if (noParent) {
+                        pom.setParent(null);
+                        try {
+                            getRepository().registerPom(projectPom, pom);
+                        } catch (DependencyNotFoundException e1) {
+                            // ignore
+                        }
+                    }
+                }
+            }
 
+            knownProjectDependencies.add(pom.getThisPom());
+
             if (filterModules) {
                 System.out.println("Include the module " + pomRelPath + " ?");
                 System.out.print("[y]/n > ");
-                String s = System.console().readLine().trim().toLowerCase();
+                String s = readLine().trim().toLowerCase();
                 boolean includeModule = !s.startsWith("n");
                 if (!includeModule) {
-                    pomsConfig.add(pomRelPath + " --ignore");
+                    ListOfPOMs.POMOptions options = pomTransformer.getListOfPOMs().getOrCreatePOMOptions(pomRelPath);
+                    options.setIgnore(true);
                     String type = "*";
                     if (pom.getThisPom().getType() != null) {
                         type = pom.getThisPom().getType();
                     }
-                    ignoreRules.add(pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
-                            + " " + type + " *");
+                    String rule = pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
+                            + " " + type + " *";
+                    pomTransformer.getIgnoreRules().add(new DependencyRule(rule));
                     return;
                 }
             }
 
-            boolean noParent = false;
             if (pom.getParent() != null) {
-                POMInfo parentPom = repository.searchMatchingPOM(pom.getParent());
-                if (parentPom == null || parentPom.equals(repository.getSuperPOM())) {
+                POMInfo parentPom = getRepository().searchMatchingPOM(pom.getParent());
+                if (parentPom == null || parentPom.equals(getRepository().getSuperPOM())) {
                     noParent = true;
                 }
                 if (!baseDir.equals(projectPom.getParentFile())) {
 //                    System.out.println("Checking the parent dependency in the sub project " + projectPom);
-                    Set parentDependencies = new TreeSet();
-                    parentDependencies.add(pom.getParent());
-                    resolveDependenciesLater(projectPom, parentDependencies, false, false, false);
+                    resolveDependenciesLater(projectPom, POMInfo.PARENT, false, false, false);
                 }
             }
 
             projectPoms.add(pom.getThisPom());
-            if (noParent) {
-                pomsConfig.add(pomRelPath + " --no-parent");
-            } else {
-                pomsConfig.add(pomRelPath);
-            }
+            pomTransformer.getListOfPOMs().getOrCreatePOMOptions(pomRelPath).setNoParent(noParent);
 
-            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);
+            resolveDependenciesLater(projectPom, POMInfo.DEPENDENCIES, false, false, false);
+            resolveDependenciesLater(projectPom, POMInfo.DEPENDENCY_MANAGEMENT_LIST, false, false, true);
+            resolveDependenciesLater(projectPom, POMInfo.PLUGINS, true, true, false);
+            resolveDependenciesLater(projectPom, POMInfo.PLUGIN_DEPENDENCIES, true, true, false);
+            resolveDependenciesLater(projectPom, POMInfo.PLUGIN_MANAGEMENT, true, true, true);
+            resolveDependenciesLater(projectPom, POMInfo.REPORTING_PLUGINS, true, true, false);
+            resolveDependenciesLater(projectPom, POMInfo.EXTENSIONS, true, true, false);
 
             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();
+                    String s = readLine().trim().toLowerCase();
                     filterModules = s.startsWith("n");
+                    askedToFilterModules = true;
                 }
                 for (Iterator i = pom.getModules().iterator(); i.hasNext();) {
                     String module = (String) i.next();
@@ -609,13 +541,27 @@
                     resolveDependencies(modulePom);
                 }
             }
-        } catch (XMLStreamException ex) {
-            Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
-        } catch (FileNotFoundException ex) {
-            Logger.getLogger(DependenciesSolver.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (Exception ex) {
+            log.log(Level.SEVERE, "Error while resolving " + projectPom, ex);
         }
     }
 
+    private POMInfo getPOM(File projectPom) throws XMLStreamException, IOException {
+        File tmpDest = File.createTempFile("pom", ".tmp");
+        tmpDest.deleteOnExit();
+        return pomTransformer.transformPom(projectPom, tmpDest);
+    }
+
+    private String readLine() {
+        LineNumberReader consoleReader = new LineNumberReader(new InputStreamReader(System.in));
+        try {
+            return consoleReader.readLine();
+        } catch (IOException e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+
     private void resolveDependenciesNow() {
         for (Iterator i = toResolve.iterator(); i.hasNext();) {
             ToResolve tr = (ToResolve) i.next();
@@ -624,49 +570,63 @@
         }
     }
 
-    private void resolveDependenciesLater(File sourcePom, Collection poms, boolean buildTime, boolean mavenExtension, boolean management) {
-        toResolve.add(new ToResolve(sourcePom, poms, buildTime, mavenExtension, management));
+    private void resolveDependenciesLater(File sourcePom, String listType, boolean buildTime, boolean mavenExtension, boolean management) {
+        toResolve.add(new ToResolve(sourcePom, listType, buildTime, mavenExtension, management));
     }
 
-    private void resolveDependencies(File sourcePom, Collection poms, boolean buildTime, boolean mavenExtension, boolean management) {
+    private void resolveDependencies(File sourcePom, String listType, boolean buildTime, boolean mavenExtension, boolean management) throws Exception {
         String sourcePomLoc = sourcePom.getAbsolutePath();
         String baseDirPath = baseDir.getAbsolutePath();
         sourcePomLoc = sourcePomLoc.substring(baseDirPath.length() + 1, sourcePomLoc.length());
 
+        List poms = getPOM(sourcePom).getDependencyList(listType);
+
         nextDependency:
         for (Iterator i = poms.iterator(); i.hasNext();) {
             Dependency dependency = (Dependency) i.next();
             if (containsDependencyIgnoreVersion(ignoredDependencies, dependency) ||
+                containsDependencyIgnoreVersion(knownProjectDependencies, 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?");
+                ignoreDependency = askIgnoreDependency(sourcePomLoc, 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?");
+                ignoreDependency = askIgnoreDependency(sourcePomLoc, 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?");
+                ignoreDependency = askIgnoreDependency(sourcePomLoc, 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?");
+                    ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "Tests are turned off. Ignore this test dependency?");
                 } else if (isTestPlugin(dependency)) {
-                    ignoreDependency = askIgnoreDependency(dependency, "Tests are turned off. Ignore this test plugin?");
+                    ignoreDependency = askIgnoreDependency(sourcePomLoc, 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?");
+            } else if (!generateJavadoc && isDocumentationOrReportPlugin(dependency)) {
+                ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "Documentation is turned off. Ignore this documentation plugin?");
             }
 
             if (ignoreDependency) {
                 ignoredDependencies.add(dependency);
-                ignoreRules.add(dependency.getGroupId() + " " + dependency.getArtifactId() + " * *");
+                String ruleDef = dependency.getGroupId() + " " + dependency.getArtifactId() + " * *";
+                pomTransformer.getIgnoreRules().add(new DependencyRule(ruleDef));
                 continue;
             }
 
-            POMInfo pom = repository.searchMatchingPOM(dependency);
+            POMInfo pom = getRepository().searchMatchingPOM(dependency);
+            if (pom == null && dependency.getVersion() == null) {
+                // Set a dummy version and try again
+                for (int version = 0; version < 10; version++) {
+                    dependency.setVersion(version + ".0");
+                    pom = getRepository().searchMatchingPOM(dependency);
+                    if (pom != null) {
+                        break;
+                    }
+                }
+            }
             if (pom == null && "maven-plugin".equals(dependency.getType())) {
-                List matchingPoms = repository.searchMatchingPOMsIgnoreVersion(dependency);
+                List matchingPoms = getRepository().searchMatchingPOMsIgnoreVersion(dependency);
                 if (matchingPoms.size() > 1) {
                     issues.add(sourcePomLoc + ": More than one version matches the plugin " + dependency.getGroupId() + ":"
                             + dependency.getArtifactId() + ":" + dependency.getVersion());
@@ -679,12 +639,28 @@
             }
             if (pom == null) {
                 if (!management) {
-                    issues.add(sourcePomLoc + ": Dependency is not packaged in the Maven repository for Debian: " + dependency.getGroupId() + ":"
-                            + dependency.getArtifactId() + ":" + dependency.getVersion());
-                    ignoreDependency = askIgnoreDependency(dependency, "This dependency cannot be found in the Debian Maven repository. Ignore this dependency?");
+                    if ("maven-plugin".equals(dependency.getType()) && packageType.equals("ant")) {
+                        ignoreDependency = true;
+                    }
+                    if (!ignoreDependency && isDocumentationOrReportPlugin(dependency)) {
+                        ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency,
+                                "This documentation or report plugin cannot be found in the Maven repository for Debian. Ignore this plugin?");
+                    }
+                    if (!ignoreDependency) {
+                        if ("maven-plugin".equals(dependency.getType())) {
+                            issues.add(sourcePomLoc + ": Plugin is not packaged in the Maven repository for Debian: " + dependency.getGroupId() + ":"
+                                    + dependency.getArtifactId() + ":" + dependency.getVersion());
+                            ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This plugin cannot be found in the Debian Maven repository. Ignore this plugin?", false);
+                        } else {
+                            issues.add(sourcePomLoc + ": Dependency is not packaged in the Maven repository for Debian: " + dependency.getGroupId() + ":"
+                                    + dependency.getArtifactId() + ":" + dependency.getVersion());
+                            ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This dependency cannot be found in the Debian Maven repository. Ignore this dependency?", false);
+                        }
+                    }
                     if (ignoreDependency) {
                         ignoredDependencies.add(dependency);
-                        ignoreRules.add(dependency.getGroupId() + " " + dependency.getArtifactId() + " * *");
+                        String ruleDef = dependency.getGroupId() + " " + dependency.getArtifactId() + " * *";
+                        pomTransformer.getIgnoreRules().add(new DependencyRule(ruleDef));
                         continue;
                     }
                 }
@@ -696,7 +672,8 @@
             // 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 *");
+                String ruleDef = dependency.getGroupId() + " " + dependency.getArtifactId() + " maven-plugin *";
+                cleanIgnoreRules.add(new DependencyRule(ruleDef));
             }
 
             // Discover the library to import for the dependency
@@ -739,7 +716,8 @@
             if (mavenRules != null) {
                 StringTokenizer st = new StringTokenizer(mavenRules, ",");
                 while (st.hasMoreTokens()) {
-                    rules.add(st.nextToken().trim());
+                    String ruleDef = st.nextToken().trim();
+                    pomTransformer.getRules().add(new DependencyRule(ruleDef));
                 }
             }
         }
@@ -874,7 +852,7 @@
         public String getResult() {
             return result;
         }
-    };
+    }
 
     public static void main(String[] args) {
         if (args.length == 0 || "-h".equals(args[0]) || "--help".equals(args[0])) {
@@ -885,10 +863,10 @@
             System.out.println("  -v, --verbose: be extra verbose");
             System.out.println("  -p<package>, --package=<package>: name of the Debian package containing");
             System.out.println("    this library");
-            System.out.println("  -r<rules>, --rules=<rules>: path to the file containing the");
-            System.out.println("    extra rules to apply when cleaning the POM");
-            System.out.println("  -i<rules>, --published-rules=<rules>: path to the file containing the");
-            System.out.println("    extra rules to publish in the property debian.mavenRules in the cleaned POM");
+//            System.out.println("  -r<rules>, --rules=<rules>: path to the file containing the");
+//            System.out.println("    extra rules to apply when cleaning the POM");
+//            System.out.println("  -i<rules>, --published-rules=<rules>: path to the file containing the");
+//            System.out.println("    extra rules to publish in the property debian.mavenRules in the cleaned POM");
             System.out.println("  --ant: use ant for the packaging");
             System.out.println("  --run-tests: run the unit tests");
             System.out.println("  --generate-javadoc: generate Javadoc");
@@ -943,6 +921,10 @@
         solver.saveMavenCleanIgnoreRules();
         solver.saveMavenPublishedRules();
         solver.saveSubstvars();
+
+        if (!solver.getIssues().isEmpty()) {
+            System.exit(1);
+        }
     }
 
     private static int inc(int i, String[] args) {

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-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm	2010-07-25 20:42:58 UTC (rev 12812)
@@ -21,7 +21,7 @@
 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.3
+Standards-Version: 3.9.0
 Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/${package}
 Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}
 Homepage:#if(${project.Url}) ${project.Url} #else TODO #end

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-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm	2010-07-25 20:42:58 UTC (rev 12812)
@@ -20,7 +20,7 @@
 Uploaders: ${packager} <${packagerEmail}>
 Build-Depends: debhelper (>= 7), cdbs, default-jdk, maven-debian-helper
 Build-Depends-Indep:#printDependencies($compileDependencies)$space
-Standards-Version: 3.8.4
+Standards-Version: 3.9.0
 Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/${package}
 Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}
 Homepage:#if(${project.Url}) ${project.Url} #else TODO #end

Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.cleanIgnoreRules.description
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.cleanIgnoreRules.description	                        (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.cleanIgnoreRules.description	2010-07-25 20:42:58 UTC (rev 12812)
@@ -0,0 +1,16 @@
+# Maven clean ignore rules - ignore some Maven dependencies and plugins
+# during the clean phase of a Maven build
+# Format of this file is:
+# [group] [artifact] [type] [version] [classifier] [scope]
+# where each element can be either
+# - the exact string, for example org.apache for the group, or 3.1
+#   for the version. In this case, the element is simply matched
+#   and left as it is
+# - * (the star character, alone). In this case, anything will
+#   match and be left as it is. For example, using * on the
+#  position of the artifact field will match any artifact id
+# All elements much match before a rule can be applied
+# Example rule: match jar with groupid= junit, artifactid= junit
+# and version starting with 3., this dependency is then removed
+# from the POM before mvn clean is called
+#   junit junit jar s/3\\..*/3.x/

Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.ignoreRules.description
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.ignoreRules.description	                        (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.ignoreRules.description	2010-07-25 20:42:58 UTC (rev 12812)
@@ -0,0 +1,15 @@
+# Maven ignore rules - ignore some Maven dependencies and plugins
+# Format of this file is:
+# [group] [artifact] [type] [version] [classifier] [scope]
+# where each element can be either
+# - the exact string, for example org.apache for the group, or 3.1
+#   for the version. In this case, the element is simply matched
+#   and left as it is
+# - * (the star character, alone). In this case, anything will
+#   match and be left as it is. For example, using * on the
+#  position of the artifact field will match any artifact id
+# All elements much match before a rule can be applied
+# Example rule: match jar with groupid= junit, artifactid= junit
+# and version starting with 3., this dependency is then removed
+# from the POM
+#   junit junit jar s/3\\..*/3.x/

Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.publishedRules.description
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.publishedRules.description	                        (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.publishedRules.description	2010-07-25 20:42:58 UTC (rev 12812)
@@ -0,0 +1,18 @@
+# Maven published rules - additional rules to publish, to help
+# the packaging work of Debian maintainers using mh_make
+# Format of this file is:
+# [group] [artifact] [type] [version] [classifier] [scope]
+# where each element can be either
+# - the exact string, for example org.apache for the group, or 3.1
+#   for the version. In this case, the element is simply matched
+#   and left as it is
+# - * (the star character, alone). In this case, anything will
+#   match and be left as it is. For example, using * on the
+#  position of the artifact field will match any artifact id
+# - a regular expression of the form s/match/replace/
+#   in this case, elements that match are transformed using
+#   the regex rule.
+# All elements much match before a rule can be applied
+# Example rule: match jar with groupid= junit, artifactid= junit
+# and version starting with 3., replacing the version with 3.x
+#   junit junit jar s/3\\..*/3.x/

Added: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.rules.description
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.rules.description	                        (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/maven.rules.description	2010-07-25 20:42:58 UTC (rev 12812)
@@ -0,0 +1,17 @@
+# Maven rules - transform Maven dependencies and plugins
+# Format of this file is:
+# [group] [artifact] [type] [version] [classifier] [scope]
+# where each element can be either
+# - the exact string, for example org.apache for the group, or 3.1
+#   for the version. In this case, the element is simply matched
+#   and left as it is
+# - * (the star character, alone). In this case, anything will
+#   match and be left as it is. For example, using * on the
+#  position of the artifact field will match any artifact id
+# - a regular expression of the form s/match/replace/
+#   in this case, elements that match are transformed using
+#   the regex rule.
+# All elements much match before a rule can be applied
+# Example rule: match jar with groupid= junit, artifactid= junit
+# and version starting with 3., replacing the version with 3.x
+#   junit junit jar s/3\\..*/3.x/

Modified: trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java	2010-07-25 20:42:58 UTC (rev 12812)
@@ -89,7 +89,7 @@
             if (!skipReadTest) {
                 test = fileReader.readLine();
 
-                if (test != null && test.startsWith("#")) {
+                if (test != null && (test.startsWith("#") || test.trim().isEmpty())) {
                     continue;
                 }
             }
@@ -99,11 +99,11 @@
             if (ref == null) {
                 return;
             }
-            if (ref.startsWith("#")) {
+            if (ref.startsWith("#") || ref.trim().isEmpty()) {
                 skipReadTest = true;
                 continue;
             }
-            assertEquals("Error in " + fileName, ref, test);
+            assertEquals("Error in " + fileName, ref.trim(), test.trim());
         }
     }
 

Modified: trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.rules
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.rules	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-active-collections-java.rules	2010-07-25 20:42:58 UTC (rev 12812)
@@ -1 +1 @@
-junit junit jar s/3\..*/3.x/ *
+junit junit jar s/3\..*/3.x/ * *

Modified: trunk/maven-debian-helper/pom.xml
===================================================================
--- trunk/maven-debian-helper/pom.xml	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/pom.xml	2010-07-25 20:42:58 UTC (rev 12812)
@@ -4,7 +4,7 @@
 
   <groupId>org.debian.maven</groupId>
   <artifactId>maven-debian</artifactId>
-  <version>1.0</version>
+  <version>1.1</version>
   <packaging>pom</packaging>
   <name>helper tools for using Maven to build Debian packages</name>
 

Modified: trunk/maven-debian-helper/share/cdbs/1/class/maven.mk
===================================================================
--- trunk/maven-debian-helper/share/cdbs/1/class/maven.mk	2010-07-25 19:01:24 UTC (rev 12811)
+++ trunk/maven-debian-helper/share/cdbs/1/class/maven.mk	2010-07-25 20:42:58 UTC (rev 12812)
@@ -35,7 +35,7 @@
 JAVA_OPTS = \
   $(shell test -n "$(DEB_MAVEN_PROPERTYFILE)" && echo -Dproperties.file.manual=$(DEB_MAVEN_PROPERTYFILE))
 
-DEB_PHONY_RULES += maven-sanity-check
+DEB_PHONY_RULES += maven-sanity-check before-mvn-build mvn-build after-mvn-build patch-poms unpatch-poms
 
 cdbs_use_maven_substvars := $(shell grep -q "{maven:\w*Depends}" debian/control && echo yes)
 cdbs_new_poms_file := $(shell test ! -f debian/$(DEB_JAR_PACKAGE).poms && echo yes)
@@ -80,9 +80,14 @@
 clean:: unpatch-poms
 	mh_clean
 
-common-build-arch common-build-indep:: debian/stamp-maven-build maven-sanity-check
+common-build-arch common-build-indep:: maven-sanity-check debian/stamp-maven-build
 debian/stamp-maven-build: debian/maven-repo before-mvn-build mvn-build after-mvn-build
 mvn-build:
+	# before-build target may be used to unpatch the pom files, so we need to check if
+	# patching the pom files is needed here, normally not
+	if [ ! -f pom.xml.save ]; then \
+		$(MAKE) -f debian/rules patch-poms; \
+	fi
 	$(DEB_MAVEN_INVOKE) $(DEB_MAVEN_BUILD_TARGET)
 	touch $@
 # Placeholders to insert custom processing before and after a Maven build
@@ -122,6 +127,9 @@
 
 common-build-arch common-build-indep:: debian/stamp-maven-doc
 debian/stamp-maven-doc: debian/stamp-maven-build
+	if [ ! -f pom.xml.save ]; then \
+		$(MAKE) -f debian/rules patch-poms; \
+	fi
 	$(if $(DEB_MAVEN_DOC_TARGET),$(DEB_MAVEN_INVOKE) $(PLUGIN_DOC_ARGS) $(DEB_MAVEN_DOC_TARGET), at echo "DEB_MAVEN_DOC_TARGET unset, not generating documentation")
 	$(if $(DEB_MAVEN_DOC_TARGET),touch $@)
 




More information about the pkg-java-commits mailing list