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

Ludovic Claude ludovicc-guest at alioth.debian.org
Sun Dec 4 22:57:43 UTC 2011


Author: ludovicc-guest
Date: 2011-12-04 22:57:43 +0000 (Sun, 04 Dec 2011)
New Revision: 15502

Modified:
   trunk/maven-repo-helper/debian/build.properties
   trunk/maven-repo-helper/debian/changelog
   trunk/maven-repo-helper/pom.xml
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Dependency.java
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DependencyRule.java
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DependencyRuleSet.java
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/ListOfPOMs.java
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMCleaner.java
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMInfo.java
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMReader.java
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMTransformer.java
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Repository.java
   trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Rule.java
   trunk/maven-repo-helper/src/main/share/mh_lib.sh
   trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMReaderTest.java
   trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/RepositoryTest.java
   trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/TestBase.java
Log:
* Build with Java 5, use generics. (Closes: #644260)
* Fix resolution of versions from dependency management

Modified: trunk/maven-repo-helper/debian/build.properties
===================================================================
--- trunk/maven-repo-helper/debian/build.properties	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/debian/build.properties	2011-12-04 22:57:43 UTC (rev 15502)
@@ -6,7 +6,7 @@
 build.directory=build
 build.outputDirectory=build/classes
 build.testOutputDirectory=build/test-classes
-build.javaVersion=1.4
+build.javaVersion=1.5
 javadoc.dir=${build.directory}/javadoc
 classpath.compile=
 classpath.test=/usr/share/java/junit.jar:/usr/share/java/commons-io.jar:/usr/share/java/xmlunit.jar

Modified: trunk/maven-repo-helper/debian/changelog
===================================================================
--- trunk/maven-repo-helper/debian/changelog	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/debian/changelog	2011-12-04 22:57:43 UTC (rev 15502)
@@ -1,3 +1,10 @@
+maven-repo-helper (1.7.1) UNRELEASED; urgency=low
+
+  * Build with Java 5, use generics. (Closes: #644260)
+  * Fix resolution of versions from dependency management
+
+ -- Ludovic Claude <ludovic.claude at laposte.net>  Sun, 13 Nov 2011 23:59:09 +0100
+
 maven-repo-helper (1.7) unstable; urgency=low
 
   * add --site-xml=<location> option to mh_install and in the

Modified: trunk/maven-repo-helper/pom.xml
===================================================================
--- trunk/maven-repo-helper/pom.xml	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/pom.xml	2011-12-04 22:57:43 UTC (rev 15502)
@@ -5,7 +5,7 @@
     <artifactId>maven-repo-helper</artifactId>
     <name>Maven Repo helper</name>
     <packaging>jar</packaging>
-    <version>1.7</version>
+    <version>1.7.1</version>
     <description>Provides support for managing the Maven repository in a Debian distribution.</description>
 
     <inceptionYear>2009</inceptionYear>
@@ -43,8 +43,8 @@
             <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>1.4</source>
-                    <target>1.4</target>
+                    <source>1.5</source>
+                    <target>1.5</target>
                 </configuration>
             </plugin>
             <plugin>

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Dependency.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Dependency.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Dependency.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -19,7 +19,8 @@
 import java.util.*;
 
 /**
- *
+ * Represents a Maven dependency of any type (dependency, plugin, parent POM)
+ * 
  * @author Ludovic Claude <ludovicc at users.sourceforge.net>
  */
 public class Dependency implements Comparable, Cloneable {
@@ -32,13 +33,13 @@
     private String scope;
     private String classifier;
     private String relativePath;
+    private boolean superPom;
 
     public Dependency(String groupId, String artifactId, String type, String version) {
         this.groupId = groupId;
         this.artifactId = artifactId;
         this.type = type;
         this.version = version;
-        this.scope = "runtime";
         this.classifier = "";
     }
 
@@ -63,6 +64,7 @@
         this.optional = dependency.optional;
         this.classifier = dependency.classifier;
         this.relativePath = dependency.relativePath;
+        this.superPom = dependency.superPom;
     }
 
     public String getArtifactId() {
@@ -105,8 +107,12 @@
         this.optional = optional;
     }
 
+    public boolean isScopeDefined() {
+        return (scope != null);
+    }
+    
     public String getScope() {
-        return scope;
+        return scope == null ? "runtime" : scope;
     }
 
     public void setScope(String scope) {
@@ -129,6 +135,14 @@
         this.relativePath = relativePath;
     }
 
+    public void setSuperPom(boolean superPom) {
+        this.superPom = superPom;
+    }
+
+    public boolean isSuperPom() {
+        return superPom;
+    }
+
     public boolean equals(Object obj) {
         if (obj == null) {
             return false;
@@ -150,20 +164,16 @@
             return false;
         }
         // Ignore scope and optional as they are content-free and indicate more the context
-        if ((this.classifier == null) ? (other.classifier != null) : !this.classifier.equals(other.classifier)) {
-            return false;
-        }
-        return true;
+        return !((this.classifier == null) ? (other.classifier != null) : !this.classifier.equals(other.classifier));
     }
 
-    public boolean equalsIgnoreVersion(Object obj) {
-        if (obj == null) {
+    public boolean equalsIgnoreVersion(Dependency other) {
+        if (other == null) {
             return false;
         }
-        if (getClass() != obj.getClass()) {
+        if (getClass() != other.getClass()) {
             return false;
         }
-        final Dependency other = (Dependency) obj;
         if ((this.groupId == null) ? (other.groupId != null) : !this.groupId.equals(other.groupId)) {
             return false;
         }
@@ -174,10 +184,7 @@
             return false;
         }
         // Classifier is still important here as it can influence greatly the contents of the artifact (a source artifact is very different from a normal artifact)
-        if ((this.classifier == null) ? (other.classifier != null) : !this.classifier.equals(other.classifier)) {
-            return false;
-        }
-        return true;
+        return !((this.classifier == null) ? (other.classifier != null) : !this.classifier.equals(other.classifier));
     }
 
     public int hashCode() {
@@ -217,7 +224,7 @@
         return 0;
     }
 
-    public Object clone() {
+    public Object clone() throws CloneNotSupportedException {
         try {
             return super.clone();
         } catch (CloneNotSupportedException e) {
@@ -226,9 +233,8 @@
         }
     }
 
-    public Dependency applyRules(Collection rules) {
-        for (Iterator i = rules.iterator(); i.hasNext();) {
-            DependencyRule rule = (DependencyRule) i.next();
+    public Dependency applyRules(Collection<DependencyRule> rules) {
+        for (DependencyRule rule: rules) {
             if (rule.matches(this)) {
                 return rule.apply(this);
             }
@@ -236,9 +242,8 @@
         return new Dependency(this);
     }
 
-    public DependencyRule findMatchingRule(Collection rules) {
-        for (Iterator i = rules.iterator(); i.hasNext();) {
-            DependencyRule rule = (DependencyRule) i.next();
+    public DependencyRule findMatchingRule(Collection<DependencyRule> rules) {
+        for (DependencyRule rule: rules) {
             if (rule.matches(this)) {
                 return rule;
             }
@@ -246,25 +251,23 @@
         return null;
     }
 
-    public static List applyRules(List dependencies, Collection rules) {
+    public static List<Dependency> applyRules(List<Dependency> dependencies, Collection<DependencyRule> rules) {
         if (dependencies == null) {
             return null;
         }
-        List result = new ArrayList();
-        for (Iterator i = dependencies.iterator(); i.hasNext();) {
-            Dependency dependency = (Dependency) i.next();
+        List<Dependency> result = new ArrayList<Dependency>();
+        for (Dependency dependency: dependencies) {
             result.add(dependency.applyRules(rules));
         }
         return result;
     }
 
-    public static List applyIgnoreRules(List dependencies, Set ignoreRules) {
+    public static List<Dependency> applyIgnoreRules(List<Dependency> dependencies, Set<DependencyRule> ignoreRules) {
         if (dependencies == null) {
             return null;
         }
-        List result = new ArrayList();
-        for (Iterator i = dependencies.iterator(); i.hasNext();) {
-            Dependency dependency = (Dependency) i.next();
+        List<Dependency> result = new ArrayList<Dependency>();
+        for (Dependency dependency: dependencies) {
             if (dependency.findMatchingRule(ignoreRules) == null) {
                 result.add(new Dependency(dependency));
             }

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DependencyRule.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DependencyRule.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DependencyRule.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -22,7 +22,7 @@
  *
  * @author Ludovic Claude <ludovicc at users.sourceforge.net>
  */
-public class DependencyRule implements Comparable {
+public class DependencyRule implements Comparable<DependencyRule> {
 
     public static DependencyRule TO_DEBIAN_VERSION_RULE = new DependencyRule("");
     public static DependencyRule MAVEN_PLUGINS_KEEP_VERSION_RULE = new DependencyRule("* * maven-plugin * * *");
@@ -117,8 +117,7 @@
      * If 2 rules have the same order of genericity, then use an alphabetical
      * sorting of the pattern strings.
      */
-    public int compareTo(Object o) {
-        DependencyRule other = (DependencyRule) o;
+    public int compareTo(DependencyRule other) {
         if (groupRule.isGeneric() && !other.groupRule.isGeneric()) {
             return 1;
         }
@@ -181,10 +180,7 @@
         if (this.classifierRule != other.classifierRule && (this.classifierRule == null || !this.classifierRule.equals(other.classifierRule))) {
             return false;
         }
-        if (this.scopeRule != other.scopeRule && (this.scopeRule == null || !this.scopeRule.equals(other.scopeRule))) {
-            return false;
-        }
-        return true;
+        return !(this.scopeRule != other.scopeRule && (this.scopeRule == null || !this.scopeRule.equals(other.scopeRule)));
     }
 
     public int hashCode() {

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DependencyRuleSet.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DependencyRuleSet.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DependencyRuleSet.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -24,12 +24,12 @@
 /**
  * @author Ludovic Claude <ludovicc at users.sourceforge.net>
  */
-public class DependencyRuleSet {
+public class DependencyRuleSet implements Iterable<DependencyRule> {
 
     private static final Logger log = Logger.getLogger(DependencyRuleSet.class.getName());
 
     private File rulesFile;
-    private Set rules;
+    private Set<DependencyRule> rules;
     private boolean verbose;
     private boolean warnRulesFileNotFound = true;
     private String name;
@@ -55,7 +55,7 @@
         readRules();
     }
 
-    public Set getRules() {
+    public Set<DependencyRule> getRules() {
         if (rules == null) {
             readRules();
         }
@@ -98,7 +98,7 @@
         this.dontDuplicate = dontDuplicate;
     }
 
-    public Iterator iterator() {
+    public Iterator<DependencyRule> iterator() {
         return getRules().iterator();
     }
 
@@ -111,15 +111,13 @@
     }
 
     public void addAll(DependencyRuleSet newRules) {
-        for (Iterator i = newRules.iterator(); i.hasNext();) {
-            DependencyRule rule = (DependencyRule) i.next();
+        for (DependencyRule rule: newRules) {
             add(rule);
         }
     }
 
-    public void addAll(Collection newRules) {
-        for (Iterator i = newRules.iterator(); i.hasNext();) {
-            Object rule = i.next();
+    public void addAll(Collection<?> newRules) {
+        for (Object rule : newRules) {
             if (rule instanceof DependencyRule) {
                 add((DependencyRule) rule);
             } else {
@@ -132,10 +130,9 @@
         getRules().remove(rule);
     }
 
-    public Set findMatchingRules(Dependency dependency) {
-        Set matchingRules = new HashSet();
-        for (Iterator i = rules.iterator(); i.hasNext();) {
-            DependencyRule rule = (DependencyRule) i.next();
+    public Set<DependencyRule> findMatchingRules(Dependency dependency) {
+        Set<DependencyRule> matchingRules = new HashSet<DependencyRule>();
+        for (DependencyRule rule : rules) {
             if (rule.matches(dependency)) {
                 matchingRules.add(rule);
             }
@@ -148,9 +145,11 @@
             PrintWriter out = new PrintWriter(new FileWriter(getRulesFile()));
             out.println(description);
 
-            for (Iterator i = getRules().iterator(); i.hasNext();) {
-                DependencyRule rule = (DependencyRule) i.next();
-                if (dontDuplicate == null || !dontDuplicate.getRules().contains(rule)) {
+            for (DependencyRule rule: getRules()) {
+                if (dontDuplicate == null || !dontDuplicate.getRules().contains(rule)
+                        // Don't save implicit rules
+                        && !DependencyRule.TO_DEBIAN_VERSION_RULE.equals(rule)
+                        && !DependencyRule.MAVEN_PLUGINS_KEEP_VERSION_RULE.equals(rule)) {
                     out.println(rule.toString());
                 }
             }
@@ -164,15 +163,15 @@
     public void dump() {
         if (rules != null) {
             System.out.println(name + ":");
-            for (Iterator i = rules.iterator(); i.hasNext();) {
-                System.out.println("  " + i.next());
+            for (DependencyRule rule : rules) {
+                System.out.println("  " + rule);
             }
             System.out.println("---------");
         }
     }
 
     private void readRules() {
-        rules = new TreeSet();
+        rules = new TreeSet<DependencyRule>();
         if (rulesFile == null) {
             return;
         }

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/ListOfPOMs.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/ListOfPOMs.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/ListOfPOMs.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -31,8 +31,8 @@
     private boolean verbose;
     private File baseDir = new File(".");
     private File poms;
-    private List pomList;
-    private Map pomOptions;
+    private List<String> pomPaths;
+    private Map<String, POMOptions> pomOptions;
 
     public ListOfPOMs() {
     }
@@ -66,21 +66,20 @@
     }
 
     public String getFirstPOM() {
-        if (pomList == null) {
+        if (pomPaths == null) {
             readPomsFile();
         }
-        if (!pomList.isEmpty()) {
-            return (String) pomList.get(0);
+        if (!pomPaths.isEmpty()) {
+            return pomPaths.get(0);
         }
         return null;
     }
 
     public void foreachPoms(POMHandler handler) {
-        if (pomList == null) {
+        if (pomPaths == null) {
             readPomsFile();
         }
-        for (Iterator i = pomList.iterator(); i.hasNext(); ) {
-            String pomPath = (String) i.next();
+        for (String pomPath: pomPaths) {
             POMOptions options = getPOMOptions(pomPath);
             if (options.isIgnore()) {
                 try {
@@ -90,8 +89,7 @@
                 }
             }
         }
-        for (Iterator i = pomList.iterator(); i.hasNext(); ) {
-            String pomPath = (String) i.next();
+        for (String pomPath: pomPaths) {
             POMOptions options = getPOMOptions(pomPath);
             if (!options.isIgnore()) {
                 try {
@@ -113,7 +111,7 @@
     }
 
     public POMOptions getPOMOptions(String pomPath) {
-        return (POMOptions) getPomOptions().get(pomPath);
+        return getPomOptions().get(pomPath);
     }
 
     public POMOptions getOrCreatePOMOptions(File pom) {
@@ -129,7 +127,7 @@
         return options;
     }
 
-    public Map getPomOptions() {
+    public Map<String, POMOptions> getPomOptions() {
         if (pomOptions == null) {
             readPomsFile();
         }
@@ -142,26 +140,23 @@
     }
 
     public POMOptions addPOM(String pomPath) {
-        if (pomList == null) {
+        if (pomPaths == null) {
             readPomsFile();
         }
-        pomList.add(pomPath);
+        pomPaths.add(pomPath);
         POMOptions options = new POMOptions();
         pomOptions.put(pomPath, options);
         return options;
     }
 
     public boolean contains(File pomFile) {
-        if (pomFile.getAbsolutePath().startsWith(baseDir.getAbsolutePath())) {
-            return getPOMOptions(pomFile) != null;
-        }
-        return false;
+        return pomFile.getAbsolutePath().startsWith(baseDir.getAbsolutePath()) && getPOMOptions(pomFile) != null;
     }
 
     private void readPomsFile() {
-        if (pomList == null) {
-            pomList = new ArrayList();
-            pomOptions = new HashMap();
+        if (pomPaths == null) {
+            pomPaths = new ArrayList<String>();
+            pomOptions = new HashMap<String, POMOptions>();
         }
 
         if (poms == null || !poms.exists()) {
@@ -228,7 +223,7 @@
     public void save() {
         if (poms != null) {
             try {
-                if (pomList == null) {
+                if (pomPaths == null) {
                     readPomsFile();
                 }
                 PrintWriter out = new PrintWriter(new FileWriter(poms));
@@ -259,8 +254,7 @@
                 out.println("#   --site-xml=<location>: Optional, the location for site.xml if it needs to be installed.");
                 out.println("#     Empty by default. [mh_install]");
                 out.println("#");
-                for (Iterator i = pomList.iterator(); i.hasNext();) {
-                    String pomPath = (String) i.next();
+                for (String pomPath: pomPaths) {
                     out.println(pomPath + getPOMOptions(pomPath));
                 }
                 out.flush();

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMCleaner.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMCleaner.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMCleaner.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -23,7 +23,6 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
 
 /**
  * Cleans up a POM for inclusion in the /usr/share/maven-repo/ repository.
@@ -35,13 +34,13 @@
 public class POMCleaner extends POMTransformer {
 
     private static final Logger log = Logger.getLogger(POMCleaner.class.getName());
-    private static final List WRITE_IGNORED_ELEMENTS = Arrays.asList(new String[]{"build",
+    private static final List<String> WRITE_IGNORED_ELEMENTS = Arrays.asList("build",
                 "distributionManagement", "profiles", "ciManagement", "prerequisites",
                 "repositories", "pluginRepositories", "reports", "reporting", "modelVersion",
-                "parent"});
+                "parent");
     private boolean keepAllElements = false;
     private boolean isPOM = false;
-    private Collection keepElements = new ArrayList();
+    private Collection<String> keepElements = new ArrayList<String>();
 
     public POMCleaner() {
     }
@@ -85,10 +84,8 @@
 
         } catch (IOException ex) {
             log.log(Level.SEVERE, null, ex);
-            return;
         } catch (XMLStreamException ex) {
             log.log(Level.SEVERE, null, ex);
-            return;
         }
     }
 
@@ -102,7 +99,7 @@
         }
     }
 
-    protected boolean isWriteIgnoredElement(String element, List path, Dependency dependency) {
+    protected boolean isWriteIgnoredElement(String element, List<String> path, Dependency dependency) {
         if ("relativePath".equals(element) && path.size() == 0) {
             return true;
         }
@@ -115,7 +112,7 @@
         }
         if (path.size() > 2 && keepElements.contains(path.get(1))) {
             if ("version".equals(element)) {
-                String parent = (String) path.get(path.size() - 1);
+                String parent = path.get(path.size() - 1);
                 if ("plugin".equals(parent)) {
                     return true;
                 }
@@ -129,17 +126,13 @@
     }
 
     protected boolean acceptDependency(Dependency dependency, POMInfo info) {
-        if (!super.acceptDependency(dependency, info)) {
-            return false;
-        }
-        return "pom".equals(info.getThisPom().getType()) || !"test".equals(dependency.getScope());
+        return super.acceptDependency(dependency, info) &&
+                ("pom".equals(info.getThisPom().getType()) || !"test".equals(dependency.getScope()));
     }
 
     protected void createDebianProperties(POMInfo info, POMInfo original, String debianPackage, int inLevel) throws XMLStreamException {
         super.createDebianProperties(info, original, debianPackage, inLevel);
-        Map dependencyVersions = new TreeMap();
-        for (Iterator i = original.getDependencies().iterator(); i.hasNext(); ) {
-            Dependency dependency = (Dependency) i.next();
+        for (Dependency dependency : original.getDependencies()) {
             if (dependency.getVersion() != null) {
                 String versionProperty = "debian." + dependency.getGroupId() + "." + dependency.getArtifactId() + ".originalVersion";
                 info.getProperties().put(versionProperty, dependency.getVersion());
@@ -271,10 +264,10 @@
         File rulesFile = null;
         File publishedRulesFile = null;
         File mavenRepo = null;
-        List rulesExtra = new ArrayList();
-        List publishedRulesExtra = new ArrayList();
-        List ignoreRulesExtra = new ArrayList();
-        List ignoreRulesFiles = new ArrayList();
+        List<String> rulesExtra = new ArrayList<String>();
+        List<String> publishedRulesExtra = new ArrayList<String>();
+        List<String> ignoreRulesExtra = new ArrayList<String>();
+        List<File> ignoreRulesFiles = new ArrayList<File>();
         while (i < args.length && (args[i].trim().startsWith("-") || args[i].trim().length() == 0)) {
             String arg = args[i].trim();
             if ("--verbose".equals(arg) || "-v".equals(arg)) {
@@ -363,8 +356,8 @@
 
             if (!ignoreRulesFiles.isEmpty()) {
                 boolean firstIgnoreRule = true;
-                for (Iterator irf = ignoreRulesFiles.iterator(); irf.hasNext(); ) {
-                    File ignoreRulesFile = (File) irf.next();
+                for (Iterator<File> irf = ignoreRulesFiles.iterator(); irf.hasNext(); ) {
+                    File ignoreRulesFile = irf.next();
                     if (ignoreRulesFile.exists()) {
                         if (firstIgnoreRule) {
                             cleaner.getIgnoreRules().setRulesFile(ignoreRulesFile);

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMInfo.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMInfo.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMInfo.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -45,22 +45,22 @@
     private Dependency originalPom;
     private Dependency parent;
     private Dependency thisPom;
-    private List modules;
-    private List dependencies;
-    private List dependencyManagement;
-    private List extensions;
-    private List plugins;
-    private List pluginManagement;
-    private List pluginDependencies;
-    private List pluginManagementDependencies;
-    private List reportingPlugins;
-    private List profileDependencies;
-    private List profileDependencyManagement;
-    private List profilePlugins;
-    private List profilePluginDependencies;
-    private List profilePluginManagement;
-    private List profileReportingPlugins;
-    private Map properties;
+    private List<String> modules;
+    private List<Dependency> dependencies;
+    private List<Dependency> dependencyManagement;
+    private List<Dependency> extensions;
+    private List<Dependency> plugins;
+    private List<Dependency> pluginManagement;
+    private List<Dependency> pluginDependencies;
+    private List<Dependency> pluginManagementDependencies;
+    private List<Dependency> reportingPlugins;
+    private List<Dependency> profileDependencies;
+    private List<Dependency> profileDependencyManagement;
+    private List<Dependency> profilePlugins;
+    private List<Dependency> profilePluginDependencies;
+    private List<Dependency> profilePluginManagement;
+    private List<Dependency> profileReportingPlugins;
+    private Map<String, String> properties;
     private POMInfo parentPOM;
 
     public Dependency getOriginalPom() {
@@ -114,156 +114,156 @@
         this.thisPom = thisPom;
     }
 
-    public List getModules() {
+    public List<String> getModules() {
         return modules;
     }
 
-    public void setModules(List modules) {
+    public void setModules(List<String> modules) {
         this.modules = modules;
     }
 
     /**
      * @return the dependencies
      */
-    public List getDependencies() {
+    public List<Dependency> getDependencies() {
         return dependencies;
     }
 
     /**
      * @param dependencies the dependencies to set
      */
-    public void setDependencies(List dependencies) {
+    public void setDependencies(List<Dependency> dependencies) {
         this.dependencies = dependencies;
     }
 
     /**
      * @return the properties
      */
-    public Map getProperties() {
+    public Map<String, String> getProperties() {
         return properties;
     }
 
     /**
      * @param properties the properties to set
      */
-    public void setProperties(Map properties) {
+    public void setProperties(Map<String, String> properties) {
         this.properties = properties;
     }
 
-    public List getDependencyManagement() {
+    public List<Dependency> getDependencyManagement() {
         return dependencyManagement;
     }
 
-    public void setDependencyManagement(List dependencyManagement) {
+    public void setDependencyManagement(List<Dependency> dependencyManagement) {
         this.dependencyManagement = dependencyManagement;
     }
 
-    public List getPlugins() {
+    public List<Dependency> getPlugins() {
         return plugins;
     }
 
-    public void setPlugins(List plugins) {
+    public void setPlugins(List<Dependency> plugins) {
         this.plugins = plugins;
     }
 
-    public List getPluginManagement() {
+    public List<Dependency> getPluginManagement() {
         return pluginManagement;
     }
 
-    public void setPluginManagement(List pluginManagement) {
+    public void setPluginManagement(List<Dependency> pluginManagement) {
         this.pluginManagement = pluginManagement;
     }
 
-    public List getPluginManagementDependencies() {
+    public List<Dependency> getPluginManagementDependencies() {
         return pluginManagementDependencies;
     }
 
-    public void setPluginManagementDependencies(List pluginManagementDependencies) {
+    public void setPluginManagementDependencies(List<Dependency> pluginManagementDependencies) {
         this.pluginManagementDependencies = pluginManagementDependencies;
     }
 
-    public List getProfileDependencies() {
+    public List<Dependency> getProfileDependencies() {
         return profileDependencies;
     }
 
-    public void setProfileDependencies(List profileDependencies) {
+    public void setProfileDependencies(List<Dependency> profileDependencies) {
         this.profileDependencies = profileDependencies;
     }
 
-    public List getProfileDependencyManagement() {
+    public List<Dependency> getProfileDependencyManagement() {
         return profileDependencyManagement;
     }
 
-    public void setProfileDependencyManagement(List profileDependencyManagement) {
+    public void setProfileDependencyManagement(List<Dependency> profileDependencyManagement) {
         this.profileDependencyManagement = profileDependencyManagement;
     }
 
-    public List getExtensions() {
+    public List<Dependency> getExtensions() {
         return extensions;
     }
 
-    public void setExtensions(List extensions) {
+    public void setExtensions(List<Dependency> extensions) {
         this.extensions = extensions;
     }
 
-    public List getPluginDependencies() {
+    public List<Dependency> getPluginDependencies() {
         return pluginDependencies;
     }
 
-    public void setPluginDependencies(List pluginDependencies) {
+    public void setPluginDependencies(List<Dependency> pluginDependencies) {
         this.pluginDependencies = pluginDependencies;
     }
 
-    public List getReportingPlugins() {
+    public List<Dependency> getReportingPlugins() {
         return reportingPlugins;
     }
 
-    public void setReportingPlugins(List reportingPlugins) {
+    public void setReportingPlugins(List<Dependency> reportingPlugins) {
         this.reportingPlugins = reportingPlugins;
     }
 
-    public List getProfilePlugins() {
+    public List<Dependency> getProfilePlugins() {
         return profilePlugins;
     }
 
-    public void setProfilePlugins(List profilePlugins) {
+    public void setProfilePlugins(List<Dependency> profilePlugins) {
         this.profilePlugins = profilePlugins;
     }
 
-    public List getProfilePluginDependencies() {
+    public List<Dependency> getProfilePluginDependencies() {
         return profilePluginDependencies;
     }
 
-    public void setProfilePluginDependencies(List profilePluginDependencies) {
+    public void setProfilePluginDependencies(List<Dependency> profilePluginDependencies) {
         this.profilePluginDependencies = profilePluginDependencies;
     }
 
-    public List getProfilePluginManagement() {
+    public List<Dependency> getProfilePluginManagement() {
         return profilePluginManagement;
     }
 
-    public void setProfilePluginManagement(List profilePluginManagement) {
+    public void setProfilePluginManagement(List<Dependency> profilePluginManagement) {
         this.profilePluginManagement = profilePluginManagement;
     }
 
-    public List getProfileReportingPlugins() {
+    public List<Dependency> getProfileReportingPlugins() {
         return profileReportingPlugins;
     }
 
-    public void setProfileReportingPlugins(List profileReportingPlugins) {
+    public void setProfileReportingPlugins(List<Dependency> profileReportingPlugins) {
         this.profileReportingPlugins = profileReportingPlugins;
     }
 
-    public List getParentAsList() {
-        List parentList = new ArrayList();
+    public List<Dependency> getParentAsList() {
+        List<Dependency> parentList = new ArrayList<Dependency>();
         if (getParent() != null) {
             parentList.add(getParent());
         }
         return parentList;
     }
 
-    public Set getPublishedRules() {
-        Set rules = new TreeSet();
+    public Set<DependencyRule> getPublishedRules() {
+        Set<DependencyRule> rules = new TreeSet<DependencyRule>();
         if (getProperties() == null) {
             return rules;
         }
@@ -283,7 +283,7 @@
      * @param rules The list of rules to apply
      * @see #applyRulesOnParent(java.util.Collection, Repository) 
      */
-    public POMInfo newPOMFromRules(Collection rules, Repository repository) {
+    public POMInfo newPOMFromRules(Collection<DependencyRule> rules, Repository repository) {
         if (rules.isEmpty()) {
             return this;
         }
@@ -306,7 +306,7 @@
         result.setProfileDependencyManagement(Dependency.applyRules(getProfileDependencyManagement(), rules));
         result.setProfileReportingPlugins(Dependency.applyRules(getProfileReportingPlugins(), rules));
 
-        result.setProperties(new TreeMap(getProperties()));
+        result.setProperties(new TreeMap<String, String>(getProperties()));
         result.setModules(getModules());
 
         result.setParent(getParent());
@@ -315,14 +315,14 @@
         return result;
     }
 
-    public void applyRulesOnParent(Collection rules, Repository repository) {
+    public void applyRulesOnParent(Collection<DependencyRule> rules, Repository repository) {
         if (getParent() != null) {
             //System.out.println(this.getThisPom() + ": Apply rules on parent " + getParent() + " using repository " + repository);
             setOriginalParentVersion(getParent().getVersion());
             setParent(getParent().applyRules(rules));
             if (repository != null) {
                 POMInfo newParentPOM = repository.getPOM(getParent());
-                mergeManagement(newParentPOM);
+                setParentPOM(newParentPOM);
             } else {
                 // Always apply rules
                 //System.out.println(this.getThisPom() + ": Parent is not registered in repository, apply rules anyway");
@@ -330,7 +330,7 @@
         }
     }
 
-    public void applyRulesOnDependenciesAndPlugins(Collection rules) {
+    public void applyRulesOnDependenciesAndPlugins(Collection<DependencyRule> rules) {
         setDependencies(Dependency.applyRules(getDependencies(), rules));
         setDependencyManagement(Dependency.applyRules(getDependencyManagement(), rules));
         setExtensions(Dependency.applyRules(getExtensions(), rules));
@@ -347,7 +347,7 @@
         setProfileReportingPlugins(Dependency.applyRules(getProfileReportingPlugins(), rules));
     }
 
-    public void applyIgnoreRulesOnDependenciesAndPlugins(Set rules) {
+    public void applyIgnoreRulesOnDependenciesAndPlugins(Set<DependencyRule> rules) {
         setDependencies(Dependency.applyIgnoreRules(getDependencies(), rules));
         setDependencyManagement(Dependency.applyIgnoreRules(getDependencyManagement(), rules));
         setExtensions(Dependency.applyIgnoreRules(getExtensions(), rules));
@@ -364,9 +364,12 @@
         setProfileReportingPlugins(Dependency.applyIgnoreRules(getProfileReportingPlugins(), rules));
     }
 
-    public void mergeManagement(POMInfo parentPOM) {
+    public void setParentPOM(POMInfo parentPOM) {
         this.parentPOM = parentPOM;
         if (parentPOM != null) {
+            if (this.parent == null) {
+                this.parent = parentPOM.getThisPom();
+            }
             mergeManagement(dependencyManagement, parentPOM.getDependencyManagement());
             mergeManagement(pluginManagement, parentPOM.getPluginManagement());
         }
@@ -379,12 +382,10 @@
         resolveVersions(profilePlugins, profilePluginManagement);
     }
 
-    private void mergeManagement(List target, List management) {
+    private void mergeManagement(List<Dependency> target, List<Dependency> management) {
         resolveVersions(target, management);
-        nextParentDep: for (Iterator i = management.iterator(); i.hasNext();) {
-            Dependency parentDep = (Dependency)i.next();
-            for (Iterator j = target.iterator(); j.hasNext();) {
-                Dependency dependency = (Dependency)j.next();
+        nextParentDep: for (Dependency parentDep: management) {
+            for (Dependency dependency: target) {
                 if (dependency.equalsIgnoreVersion(parentDep)) {
                     continue nextParentDep;
                 }
@@ -394,16 +395,14 @@
     }
 
     public String getVersionFromManagementDependency(Dependency dependency) {
-        List allManagementLists = new ArrayList();
-        allManagementLists.addAll(getDependencyList(DEPENDENCY_MANAGEMENT_LIST));
-        allManagementLists.addAll(getDependencyList(PLUGIN_MANAGEMENT));
-        allManagementLists.addAll(getDependencyList(PLUGIN_MANAGEMENT_DEPENDENCIES));
-        for (Iterator i = allManagementLists.iterator(); i.hasNext();) {
-            Dependency mgtDep = (Dependency)i.next();
-            if (mgtDep.getGroupId().equals(dependency.getGroupId()) &&
-                    mgtDep.getArtifactId().equals(dependency.getArtifactId()) ) {
-                if (mgtDep.getVersion() != null) {
-                    return mgtDep.getVersion();
+        for (String listType: Arrays.asList(DEPENDENCY_MANAGEMENT_LIST, PLUGIN_MANAGEMENT, PLUGIN_MANAGEMENT_DEPENDENCIES)) {
+            for (Dependency mgtDep: getDependencyList(listType)) {
+                if (mgtDep.equalsIgnoreVersion(dependency) ) {
+                    if (mgtDep.getVersion() != null) {
+                        //System.out.println("In " + getThisPom() + " - found version " + mgtDep.getVersion() + " for " +
+                        //  dependency.getGroupId() + ":" + dependency.getArtifactId() + " according to the list of " + listType);
+                        return mgtDep.getVersion();
+                    }
                 }
             }
         }
@@ -414,16 +413,23 @@
         return null;
     }
 
-    private void resolveVersions(List deps, List management) {
-        for (Iterator i = management.iterator(); i.hasNext();) {
-            Dependency parentDep = (Dependency)i.next();
-            for (Iterator j = deps.iterator(); j.hasNext();) {
-                Dependency dependency = (Dependency)j.next();
-                if (dependency.getVersion() == null) {
+    private void resolveVersions(List<Dependency> deps, List<Dependency> management) {
+        for (Dependency parentDep: management) {
+            for (Dependency dependency: deps) {
+                if (dependency.getVersion() == null || !dependency.isScopeDefined()) {
                     if (dependency.getGroupId().equals(parentDep.getGroupId()) &&
                         dependency.getArtifactId().equals(parentDep.getArtifactId()) &&
                         dependency.getType().equals(parentDep.getType())) {
-                        dependency.setVersion(parentDep.getVersion());
+
+                        if (dependency.getVersion() == null) {
+                            //System.out.println("In " + getThisPom() + " - resolve version to " + parentDep.getVersion() + " for " +
+                            //  dependency.getGroupId() + ":" + dependency.getArtifactId() + " according to parent POM");
+                            dependency.setVersion(parentDep.getVersion());
+                        }
+                        if (!dependency.isScopeDefined()) {
+                            dependency.setScope(parentDep.getScope());
+                        }
+
                         break;
                     }
                 }
@@ -431,7 +437,7 @@
         }
     }
 
-    public List getDependencyList(String listSelector) {
+    public List<Dependency> getDependencyList(String listSelector) {
         if (DEPENDENCY_MANAGEMENT_LIST.equals(listSelector)) {
             return getDependencyManagement();
         }
@@ -474,25 +480,22 @@
         if (EXTENSIONS.equals(listSelector)) {
             return getExtensions();
         }
-        if (MODULES.equals(listSelector)) {
-            return getModules();
-        }
         if (PARENT.equals(listSelector)) {
             return getParentAsList();
         }
         return null;
     }
 
-    public List getAllDependencies(String listType) {
-        List allDependencies = new ArrayList(getDependencyList(listType));
+    public List<Dependency> getAllDependencies(String listType) {
+        List<Dependency> allDependencies = new ArrayList<Dependency>(getDependencyList(listType));
         if (getParent() != null) {
-            List parentDependencies = parentPOM.getAllDependencies(listType);
+            List<Dependency> parentDependencies = parentPOM.getAllDependencies(listType);
             allDependencies.addAll(parentDependencies);
         }
         return allDependencies;
     }
 
-    public Object clone() {
+    public Object clone() throws CloneNotSupportedException {
         POMInfo clone = new POMInfo();
         clone.originalParentVersion = originalParentVersion;
         clone.originalPom = originalPom;

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMReader.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMReader.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMReader.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -40,9 +40,9 @@
  */
 public class POMReader {
 
-    private static final List READ_IGNORED_ELEMENTS = Arrays.asList(new String[]{
+    private static final List<String> READ_IGNORED_ELEMENTS = Arrays.asList(
                 "distributionManagement", "ciManagement", "prerequisites", "exclusions",
-                "repositories", "pluginRepositories", "reports", "modelVersion"});
+                "repositories", "pluginRepositories", "reports", "modelVersion");
     protected final XMLInputFactory factory = XMLInputFactory.newInstance();
 
     public POMInfo readPom(File originalPom) throws XMLStreamException, FileNotFoundException {
@@ -54,24 +54,24 @@
 
     public POMInfo readPom(Reader originalPom) throws XMLStreamException {
         XMLStreamReader parser = factory.createXMLStreamReader(new BufferedReader(originalPom));
-        List path = new ArrayList();
-        List dependencies = new ArrayList();
-        List dependencyManagement = new ArrayList();
-        List extensions = new ArrayList();
-        List plugins = new ArrayList();
-        List pluginManagement = new ArrayList();
-        List pluginManagementDependencies = new ArrayList();
-        List pluginDependencies = new ArrayList();
-        List reportingPlugins = new ArrayList();
-        List profileDependencies = new ArrayList();
-        List profileDependencyManagement = new ArrayList();
-        List profilePlugins = new ArrayList();
-        List profilePluginDependencies = new ArrayList();
-        List profilePluginManagement = new ArrayList();
-        List profileReportingPlugins = new ArrayList();
-        List modules = new ArrayList();
+        List<String> path = new ArrayList<String>();
+        List<Dependency> dependencies = new ArrayList<Dependency>();
+        List<Dependency> dependencyManagement = new ArrayList<Dependency>();
+        List<Dependency> extensions = new ArrayList<Dependency>();
+        List<Dependency> plugins = new ArrayList<Dependency>();
+        List<Dependency> pluginManagement = new ArrayList<Dependency>();
+        List<Dependency> pluginManagementDependencies = new ArrayList<Dependency>();
+        List<Dependency> pluginDependencies = new ArrayList<Dependency>();
+        List<Dependency> reportingPlugins = new ArrayList<Dependency>();
+        List<Dependency> profileDependencies = new ArrayList<Dependency>();
+        List<Dependency> profileDependencyManagement = new ArrayList<Dependency>();
+        List<Dependency> profilePlugins = new ArrayList<Dependency>();
+        List<Dependency> profilePluginDependencies = new ArrayList<Dependency>();
+        List<Dependency> profilePluginManagement = new ArrayList<Dependency>();
+        List<Dependency> profileReportingPlugins = new ArrayList<Dependency>();
+        List<String> modules = new ArrayList<String>();
 
-        Map properties = new TreeMap();
+        Map<String, String> properties = new TreeMap<String, String>();
         Dependency thisPom = new Dependency(null, null, "jar", null);
         Dependency parent = null;
         Dependency currentDependency = null;
@@ -104,11 +104,11 @@
                         } else if ("dependency".equals(element)) {
                             inDependency++;
                             currentDependency = new Dependency(null, null, "jar", null);
-                            String parentElement = (String) path.get(path.size() - 2);
-                            String parentParentElement = (String) path.get(path.size() - 3);
+                            String parentElement = path.get(path.size() - 2);
+                            String parentParentElement = path.get(path.size() - 3);
                             if ("dependencies".equals(parentElement)) {
                                 if ("dependencyManagement".equals(parentParentElement)) {
-                                    String p3Element = (String) path.get(path.size() - 4);
+                                    String p3Element = path.get(path.size() - 4);
                                     if ("project".equals(p3Element)) {
                                         dependencyManagement.add(currentDependency);
                                     } else if ("profile".equals(p3Element)) {
@@ -119,7 +119,7 @@
                                 } else if ("profile".equals(parentParentElement)) {
                                     profileDependencies.add(currentDependency);
                                 } else if ("plugin".equals(parentParentElement)) {
-                                    String p5Element = (String) path.get(path.size() - 6);
+                                    String p5Element = path.get(path.size() - 6);
                                     if ("project".equals(p5Element)) {
                                         pluginDependencies.add(currentDependency);
                                     } else if ("build".equals(p5Element)) {
@@ -135,15 +135,15 @@
                             inDependency++;
                         } else if ("plugin".equals(element)) {
                             inPlugin++;
-                            String parentElement = (String) path.get(path.size() - 2);
-                            String parentParentElement = (String) path.get(path.size() - 3);
+                            String parentElement = path.get(path.size() - 2);
+                            String parentParentElement = path.get(path.size() - 3);
                             String parentParentParentElement = null;
                             String p4Element = null;
                             if (path.size() > 4) {
-                                parentParentParentElement = (String) path.get(path.size() - 4);
+                                parentParentParentElement = path.get(path.size() - 4);
                             }
                             if (path.size() > 5) {
-                                p4Element = (String) path.get(path.size() - 5);
+                                p4Element = path.get(path.size() - 5);
                             }
                             currentDependency = new Dependency("org.apache.maven.plugins", null, "maven-plugin", null);
                             if ("plugins".equals(parentElement)) {
@@ -287,7 +287,7 @@
             thisPom.setVersion(parent.getVersion());
         }
 
-        Map inferedProperties = new TreeMap(properties);
+        Map<String, String> inferedProperties = new TreeMap<String, String>(properties);
         
         inferedProperties.put("pom.groupId", thisPom.getGroupId());
         inferedProperties.put("project.groupId", thisPom.getGroupId());
@@ -329,7 +329,7 @@
         if (properties.get("debian.originalVersion") != null) {
             Dependency originalPomDep = new Dependency(thisPom.getGroupId(),
                     thisPom.getArtifactId(), thisPom.getType(),
-                    (String) properties.get("debian.originalVersion"));
+                    properties.get("debian.originalVersion"));
             info.setOriginalPom(originalPomDep);
         }
         info.setThisPom(thisPom);
@@ -357,21 +357,20 @@
         return READ_IGNORED_ELEMENTS.contains(element);
     }
 
-    private void expendProperties(List dependencies, Map inferedProperties) {
-        for (Iterator i = dependencies.iterator(); i.hasNext();) {
-            Dependency dependency = (Dependency) i.next();
+    private void expendProperties(List<Dependency> dependencies, Map<String, String> inferedProperties) {
+        for (Dependency dependency : dependencies) {
             expandProperties(dependency, inferedProperties);
         }
     }
 
-    private void expandProperties(Dependency dependency, Map inferedProperties) {
+    private void expandProperties(Dependency dependency, Map<String, String> inferedProperties) {
         dependency.setGroupId(expandString(dependency.getGroupId(), inferedProperties));
         dependency.setArtifactId(expandString(dependency.getArtifactId(), inferedProperties));
         dependency.setType(expandString(dependency.getType(), inferedProperties));
         dependency.setVersion(expandString(dependency.getVersion(), inferedProperties));
     }
 
-    private String expandString(String str, Map inferedProperties) {
+    private String expandString(String str, Map<String, String> inferedProperties) {
         if (str == null) {
             return null;
         }

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMTransformer.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMTransformer.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMTransformer.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -43,13 +43,13 @@
 public class POMTransformer extends POMReader {
 
     private static final Logger log = Logger.getLogger(POMTransformer.class.getName());
-    private static final List WRITE_IGNORED_ELEMENTS = Arrays.asList(new String[]{
+    private static final List<String> WRITE_IGNORED_ELEMENTS = Arrays.asList(new String[]{
                 "modelVersion", "parent"});
-    private static final List DEBIAN_BUILD_IGNORED_ELEMENTS = Arrays.asList(new String[]{
+    private static final List<String> DEBIAN_BUILD_IGNORED_ELEMENTS = Arrays.asList(new String[]{
                 "distributionManagement", "repositories", "pluginRepositories"});
-    private static final List DEBIAN_DOC_IGNORED_ELEMENTS = Arrays.asList(new String[]{
+    private static final List<String> DEBIAN_DOC_IGNORED_ELEMENTS = Arrays.asList(new String[]{
                 "reports", "reporting", "site"});
-    private static final List INFO_ELEMENTS = Arrays.asList(new String[]{"groupId",
+    private static final List<String> INFO_ELEMENTS = Arrays.asList(new String[]{"groupId",
                 "artifactId", "packaging", "version"});
     private static final Pattern compactDependencyNotationMatcher =
             Pattern.compile("(\\w[a-zA-Z0-9\\-_\\.]*):(\\w[a-zA-Z0-9\\-_]*):(\\d[a-zA-Z0-9\\-_\\.]*)");
@@ -57,12 +57,13 @@
     private DependencyRuleSet automaticRules = new DependencyRuleSet("Automatic rules");
     private DependencyRuleSet publishedRules = new DependencyRuleSet("Published rules", new File("debian/maven.publishedRules"));
     private DependencyRuleSet ignoreRules = new DependencyRuleSet("Ignore rules", new File("debian/maven.ignoreRules"));
-    private Map ignoredModules = new HashMap();
+    private Map<File, Set<String>> ignoredModules = new HashMap<File, Set<String>>();
     private Repository repository;
     private boolean verbose;
     private boolean isDebianBuild;
     private boolean isBuildWithoutDoc;
     private boolean publishUsedRule = true;
+    private boolean fixVersions = true;
     private ListOfPOMs listOfPOMs;
 
     public POMTransformer() {
@@ -108,7 +109,15 @@
     public void setPublishUsedRule(boolean publishUsedRule) {
         this.publishUsedRule = publishUsedRule;
     }
-                                           
+
+    public boolean isFixVersions() {
+        return fixVersions;
+    }
+
+    public void setFixVersions(boolean fixVersions) {
+        this.fixVersions = fixVersions;
+    }
+
     public DependencyRuleSet getRules() {
         return rules;
     }
@@ -127,14 +136,13 @@
 
     public void usePluginVersionsFromRepository() {
         repository.scanOnce();
-        for (Iterator i = repository.resolvedPomsIterator(); i.hasNext();) {
-            POMInfo pom = (POMInfo) i.next();
+        for (Iterator<POMInfo> i = repository.resolvedPomsIterator(); i.hasNext();) {
+            POMInfo pom = i.next();
             if (pom.getThisPom().getType().equals("maven-plugin")) {
-                Set pomRules = pom.getPublishedRules();
+                Set<DependencyRule> pomRules = pom.getPublishedRules();
                 rules.add(DependencyRule.MAVEN_PLUGINS_KEEP_VERSION_RULE);
                 boolean found = false;
-                for (Iterator j = pomRules.iterator(); j.hasNext();) {
-                    DependencyRule rule = (DependencyRule) j.next();
+                for (DependencyRule rule: pomRules) {
                     if (rule.matches(pom.getThisPom()) && rule.apply(pom.getThisPom()).equals(pom.getThisPom())
                             && !rule.getGroupRule().isGeneric() && !rule.getArtifactRule().isGeneric()) {
                         automaticRules.add(rule);
@@ -174,9 +182,9 @@
     }
 
     public void addIgnoreModule(File pomFile, String module) {
-        Set modules = (Set) ignoredModules.get(pomFile);
+        Set<String> modules = ignoredModules.get(pomFile);
         if (modules == null) {
-            modules = new HashSet();
+            modules = new HashSet<String>();
             ignoredModules.put(pomFile, modules);
         }
         modules.add(module);
@@ -300,7 +308,7 @@
 
             transformingPom(original);
 
-            Set allRules = new TreeSet(rules.getRules());
+            Set<DependencyRule> allRules = new TreeSet<DependencyRule>(rules.getRules());
             allRules.addAll(automaticRules.getRules());
             POMInfo info = original.newPOMFromRules(allRules, repository);
             if (hasPackageVersion) {
@@ -334,11 +342,11 @@
             int inLevel = 0;
             int inModule = 0;
             boolean sawVersion = false;
-            List path = new ArrayList();
-            List dependencyList = null;
+            List<String> path = new ArrayList<String>();
+            List<Dependency> dependencyList = null;
             int dependencyIndex = -1;
-            Map dependencyIndexes = new HashMap();
-            Map visitedProperties = new HashMap();
+            Map<String, Integer> dependencyIndexes = new HashMap<String, Integer>();
+            Map<String, String> visitedProperties = new HashMap<String, String>();
             Dependency dependency = null;
             Dependency parentDependency = null;
             String element = null;
@@ -382,13 +390,13 @@
                             if ("dependency".equals(element) || "plugin".equals(element) || "extension".equals(element)) {
                                 dependency = null;
                                 if ("dependency".equals(element)) {
-                                    String parentElement = (String) path.get(path.size() - 2);
-                                    String parentParentElement = (String) path.get(path.size() - 3);
+                                    String parentElement = path.get(path.size() - 2);
+                                    String parentParentElement = path.get(path.size() - 3);
                                     if ("dependencies".equals(parentElement)) {
                                         sawVersion = false;
                                         String listSelector = null;
                                         if ("dependencyManagement".equals(parentParentElement)) {
-                                            String p3Element = (String) path.get(path.size() - 4);
+                                            String p3Element = path.get(path.size() - 4);
                                             if ("project".equals(p3Element)) {
                                                 listSelector = POMInfo.DEPENDENCY_MANAGEMENT_LIST;
                                             } else if ("profile".equals(p3Element)) {
@@ -399,7 +407,7 @@
                                         } else if ("profile".equals(parentParentElement)) {
                                             listSelector = POMInfo.PROFILE_DEPENDENCIES;
                                         } else if ("plugin".equals(parentParentElement)) {
-                                            String p5Element = (String) path.get(path.size() - 6);
+                                            String p5Element = path.get(path.size() - 6);
                                             if ("project".equals(p5Element)) {
                                                 listSelector = POMInfo.PLUGIN_DEPENDENCIES;
                                             } else if ("build".equals(p5Element)) {
@@ -414,19 +422,19 @@
                                             if (dependency != null) {
                                                 parentDependency = dependency;
                                             }
-                                            dependency = (Dependency) dependencyList.get(dependencyIndex);
+                                            dependency = dependencyList.get(dependencyIndex);
                                         }
                                     }
                                 } else if ("plugin".equals(element)) {
-                                    String parentElement = (String) path.get(path.size() - 2);
-                                    String parentParentElement = (String) path.get(path.size() - 3);
+                                    String parentElement = path.get(path.size() - 2);
+                                    String parentParentElement = path.get(path.size() - 3);
                                     String parentParentParentElement = null;
                                     String p4Element = null;
                                     if (path.size() > 4) {
-                                        parentParentParentElement = (String) path.get(path.size() - 4);
+                                        parentParentParentElement = path.get(path.size() - 4);
                                     }
                                     if (path.size() > 5) {
-                                        p4Element = (String) path.get(path.size() - 5);
+                                        p4Element = path.get(path.size() - 5);
                                     }
                                     if ("plugins".equals(parentElement)) {
                                         sawVersion = false;
@@ -448,10 +456,10 @@
                                         }
                                         dependencyIndex = inc(dependencyIndexes, listSelector);
                                         dependencyList = info.getDependencyList(listSelector);
-                                        dependency = (Dependency) dependencyList.get(dependencyIndex);
+                                        dependency = dependencyList.get(dependencyIndex);
                                     }
                                 } else if ("extension".equals(element)) {
-                                    String parentElement = (String) path.get(path.size() - 2);
+                                    String parentElement = path.get(path.size() - 2);
                                     if ("extensions".equals(parentElement)) {
                                         sawVersion = false;
                                         int index = inc(dependencyIndexes, POMInfo.EXTENSIONS);
@@ -468,8 +476,8 @@
                                 }
                             }
                             if ("module".equals(element)) {
-                                String parentElement = (String) path.get(path.size() - 2);
-                                String parentParentElement = (String) path.get(path.size() - 3);
+                                String parentElement = path.get(path.size() - 2);
+                                String parentParentElement = path.get(path.size() - 3);
                                 if ("modules".equals(parentElement) && "project".equals(parentParentElement)) {
                                     int index = inc(dependencyIndexes, POMInfo.MODULES);
                                     String module = (String) info.getModules().get(index);
@@ -529,20 +537,22 @@
                             if (dependency != null && !sawVersion && inCopyOnlyElement == 0) {
                                 if ((inDependency == 1 || inPlugin == 1 || inExtension == 1)
                                         && ((parent == null && repository == null) || (repository != null && info.getVersionFromManagementDependency(dependency) == null))) {
-                                    if (dependency.getVersion() == null) {
+                                    if (dependency.getVersion() == null && fixVersions) {
 
                                         String version = info.getVersionFromManagementDependency(dependency);
                                         if (version == null) {
                                             version = "debian";
                                         }
-                                        dependency.setVersion(version);
+                                        Dependency fixedDependency = new Dependency(dependency);
+                                        fixedDependency.setVersion(version);
                                         
                                         // Give a chance to customize the version
                                         // In maven.rules, you can write:
                                         // myDependencyGroup myDependencyArtifact * s/.*/myVersion/
-                                        dependency = dependency.applyRules(rules.getRules());
-                                        dependency = dependency.applyRules(automaticRules.getRules());
-                                        dependencyList.set(dependencyIndex, dependency);
+                                        fixedDependency = fixedDependency.applyRules(rules.getRules());
+                                        fixedDependency = fixedDependency.applyRules(automaticRules.getRules());
+                                        dependencyList.set(dependencyIndex, fixedDependency);
+                                        dependency = fixedDependency;
                                     }
                                     // If we try to fix the version for a plugin, the fix is valid
                                     // only if a real version (not 'debian') is forced on that plugin and the plugin is not
@@ -715,7 +725,7 @@
             writer.writeStartElement("version");
             writer.writeCharacters(parent.getVersion());
             writer.writeEndElement();
-            if (!isWriteIgnoredElement("relativePath", new ArrayList(), null) && null != parent.getRelativePath()) {
+            if (!isWriteIgnoredElement("relativePath", new ArrayList<String>(), null) && null != parent.getRelativePath()) {
                 indent(writer, inLevel + 1);
                 writer.writeStartElement("relativePath");
                 writer.writeCharacters(parent.getRelativePath());
@@ -728,7 +738,7 @@
         if (original.getProperties().isEmpty()) {
             writer.writeStartElement("properties");
             createDebianProperties(info, original, debianPackage, inLevel);
-            writeMissingProperties(writer, inLevel, info, new HashMap());
+            writeMissingProperties(writer, inLevel, info, new HashMap<String, String>());
             indent(writer, inLevel);
             writer.writeEndElement();
             indent(writer, inLevel);
@@ -774,7 +784,7 @@
         }
     }
 
-    protected boolean isWriteIgnoredElement(String element, List path, Dependency dependency) {
+    protected boolean isWriteIgnoredElement(String element, List<String> path, Dependency dependency) {
 //        if (isDebianBuild() && DEBIAN_BUILD_IGNORED_ELEMENTS.contains(element)) {
 //            System.out.println("Build ignored " + element + " " + printPath(path) + " for " + dependency);
 //        }
@@ -806,8 +816,8 @@
         return dependency.findMatchingRule(ignoreRules.getRules()) == null;
     }
 
-    private int inc(Map dependencyIndexes, String selector) {
-        Integer index = (Integer) dependencyIndexes.get(selector);
+    private int inc(Map<String, Integer> dependencyIndexes, String selector) {
+        Integer index = dependencyIndexes.get(selector);
         if (index == null) {
             index = new Integer(0);
         } else {
@@ -846,12 +856,11 @@
         }
     }
 
-    protected void writeMissingProperties(XMLStreamWriter writer, int inLevel, POMInfo info, Map visitedProperties) throws XMLStreamException {
-        Map sortedProperties = new TreeMap(info.getProperties());
-        for (Iterator i = sortedProperties.entrySet().iterator(); i.hasNext(); ) {
-            Map.Entry entry = (Map.Entry) i.next();
-            String property = (String) entry.getKey();
-            String value = (String) entry.getValue();
+    protected void writeMissingProperties(XMLStreamWriter writer, int inLevel, POMInfo info, Map<String, String> visitedProperties) throws XMLStreamException {
+        Map<String, String> sortedProperties = new TreeMap<String, String>(info.getProperties());
+        for (Map.Entry<String, String> entry: sortedProperties.entrySet()) {
+            String property = entry.getKey();
+            String value = entry.getValue();
             if (!visitedProperties.containsKey(property)) {
                 indent(writer, inLevel + 1);
                 if (value == null || value.isEmpty() || "true".equals(value)) {
@@ -877,7 +886,7 @@
     }
 
     private boolean acceptModule(String module, File pomFile) {
-        Set modulesToSkip = (Set) ignoredModules.get(pomFile);
+        Set<String> modulesToSkip = ignoredModules.get(pomFile);
         return modulesToSkip == null || !modulesToSkip.contains(module);
     }
 
@@ -951,9 +960,9 @@
         File publishedRulesFile = null;
         File ignoreRulesFile = null;
         File mavenRepo = null;
-        ArrayList rulesExtra = new ArrayList();
-        ArrayList publishedRulesExtra = new ArrayList();
-        ArrayList ignoreRulesExtra = new ArrayList();
+        List<String> rulesExtra = new ArrayList<String>();
+        List<String> publishedRulesExtra = new ArrayList<String>();
+        List<String> ignoreRulesExtra = new ArrayList<String>();
 
         while (i < args.length && (args[i].trim().startsWith("-") || args[i].trim().length() == 0)) {
             String arg = args[i].trim();

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Repository.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Repository.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Repository.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -48,11 +48,11 @@
 
     private static final Logger log = Logger.getLogger(Repository.class.getName());
     private File baseDir;
-    private Map unresolvedPoms = new HashMap();
-    private Map dep2info = new HashMap();
-    private Map pomsWithMissingParent = new HashMap();
-    private Map pomsWithMissingVersions = new HashMap();
-    private Map resolvedPoms = new HashMap();
+    private Map<File, POMInfo> unresolvedPoms = new HashMap<File, POMInfo>();
+    private Map<Dependency, POMInfo> dep2info = new HashMap<Dependency, POMInfo>();
+    private Map<File, POMInfo> pomsWithMissingParent = new HashMap<File, POMInfo>();
+    private Map<File, POMInfo> pomsWithMissingVersions = new HashMap<File, POMInfo>();
+    private Map<File, POMInfo> resolvedPoms = new HashMap<File, POMInfo>();
     private POMInfo superPom;
     private POMReader pomReader = new POMReader();
     private boolean scanned = false;
@@ -67,6 +67,7 @@
                 superPom.getThisPom().setGroupId("__super__");
                 superPom.getThisPom().setArtifactId("__pom__");
                 superPom.getThisPom().setType("pom");
+                superPom.getThisPom().setSuperPom(true);
             }
         } catch (XMLStreamException ex) {
             log.log(Level.SEVERE, null, ex);
@@ -82,27 +83,27 @@
     }
 
     public POMInfo getPOM(Dependency dependency) {
-        return (POMInfo) dep2info.get(dependency);
+        return dep2info.get(dependency);
     }
 
-    protected Map getUnresolvedPoms() {
+    protected Map<File, POMInfo> getUnresolvedPoms() {
         return unresolvedPoms;
     }
 
-    protected Map getPomsWithMissingParent() {
+    protected Map<File, POMInfo> getPomsWithMissingParent() {
         return pomsWithMissingParent;
     }
 
-    protected Map getPomsWithMissingVersions() {
+    protected Map<File, POMInfo> getPomsWithMissingVersions() {
         return pomsWithMissingVersions;
     }
 
-    protected Map getResolvedPoms() {
+    protected Map<File, POMInfo> getResolvedPoms() {
         return resolvedPoms;
     }
 
-    protected List getAllPoms() {
-        List allPoms = new ArrayList(resolvedPoms.values());
+    protected List<POMInfo> getAllPoms() {
+        List<POMInfo> allPoms = new ArrayList<POMInfo>(resolvedPoms.values());
         allPoms.addAll(unresolvedPoms.values());
         return allPoms;
     }
@@ -120,15 +121,13 @@
         }
 
         // Map<DependencyRule,POMInfo>
-        Map potentialMatches = new TreeMap();
-        for (Iterator i = getAllPoms().iterator(); i.hasNext();) {
-            POMInfo testPom = (POMInfo) i.next();
-            Set rules = testPom.getPublishedRules();
+        Map<DependencyRule, POMInfo> potentialMatches = new TreeMap<DependencyRule, POMInfo>();
+        for (POMInfo testPom: getAllPoms()) {
+            Set<DependencyRule> rules = testPom.getPublishedRules();
             rules.add(DependencyRule.MAVEN_PLUGINS_KEEP_VERSION_RULE);
             rules.add(DependencyRule.TO_DEBIAN_VERSION_RULE);
             
-            for (Iterator j = rules.iterator(); j.hasNext();) {
-                DependencyRule rule = (DependencyRule) j.next();
+            for (DependencyRule rule: rules) {
                 if (rule.matches(dependency) && rule.apply(dependency).equals(testPom.getThisPom())) {
                     potentialMatches.put(rule, testPom);
                 }
@@ -136,25 +135,25 @@
         }
         if (!potentialMatches.isEmpty()) {
             // Return the best match
-            return (POMInfo) potentialMatches.values().iterator().next();
+            return potentialMatches.values().iterator().next();
         }
         return null;
     }
 
-    public Iterator resolvedPomsIterator() {
+    public Iterator<POMInfo> resolvedPomsIterator() {
         return resolvedPoms.values().iterator();
     }
 
-    public List searchMatchingPOMsIgnoreVersion(Dependency dependency) {
-        List result = new ArrayList();
+    public List<POMInfo> searchMatchingPOMsIgnoreVersion(Dependency dependency) {
+        List<POMInfo> result = new ArrayList<POMInfo>();
         POMInfo pom = searchMatchingPOM(dependency);
         if (pom != null) {
             result.add(pom);
             return result;
         }
 
-        for (Iterator i = resolvedPomsIterator(); i.hasNext();) {
-            POMInfo testPom = (POMInfo) i.next();
+        for (Iterator<POMInfo> i = resolvedPomsIterator(); i.hasNext();) {
+            POMInfo testPom = i.next();
             if (testPom.getThisPom().equalsIgnoreVersion(dependency)) {
                 result.add(testPom);
             }
@@ -200,8 +199,7 @@
     	
         if (pomsWithMissingParent.size() > 0) {
         	writer.printSectionStart("POMs with missing parents");
-            for (Iterator i = pomsWithMissingParent.keySet().iterator(); i.hasNext();) {
-                File pom = (File) i.next();
+            for (File pom: pomsWithMissingParent.keySet()) {
                 writer.printItem(pom.getAbsolutePath());
                 writer.endItem();
             }
@@ -209,20 +207,17 @@
         }
         if (pomsWithMissingVersions.size() > 0) {
         	writer.printSectionStart("POMs with missing versions");
-            for (Iterator i = pomsWithMissingVersions.entrySet().iterator(); i.hasNext();) {
-                Entry entry = (Entry) i.next();
-                File pom = (File) entry.getKey();
-                POMInfo pomInfo = (POMInfo) entry.getValue();
+            for (Entry<File, POMInfo> entry: pomsWithMissingVersions.entrySet()) {
+                File pom = entry.getKey();
+                POMInfo pomInfo = entry.getValue();
                 writer.printItem(pom.getAbsolutePath());
-                for (Iterator j = pomInfo.getDependencies().iterator(); j.hasNext();) {
-                    Dependency dependency = (Dependency) j.next();
+                for (Dependency dependency: pomInfo.getDependencies()) {
                     if (dependency.getVersion() == null || dependency.getVersion().contains("$")) {
                     	writer.printItem(dependency.toString());
                     	writer.endItem();
                     }
                 }
-                for (Iterator j = pomInfo.getPlugins().iterator(); j.hasNext();) {
-                    Dependency dependency = (Dependency) j.next();
+                for (Dependency dependency: pomInfo.getPlugins()) {
                     if (dependency.getVersion() == null || dependency.getVersion().contains("$")) {
                     	writer.printItem(dependency.toString());
                     	writer.endItem();
@@ -233,37 +228,34 @@
             writer.printSectionEnd();
         }
 
-        Set issues = new TreeSet();
-        Map pomsWithIssues = new HashMap();
-        for (Iterator i = resolvedPoms.entrySet().iterator(); i.hasNext();) {
-            Entry entry = (Entry) i.next();
-            File pom = (File) entry.getKey();
-            POMInfo pomInfo = (POMInfo) entry.getValue();
+        Set<String> issues = new TreeSet<String>();
+        Map<File, List<Dependency>> pomsWithIssues = new HashMap<File, List<Dependency>>();
+        for (Entry<File, POMInfo> entry: resolvedPoms.entrySet()) {
+            File pom = entry.getKey();
+            POMInfo pomInfo = entry.getValue();
             if (pomInfo.getThisPom().getVersion() == null) {
                 issues.add("Missing version in " + pom);
             }
             if (pomInfo.getThisPom().getVersion().endsWith("-SNAPSHOT")) {
                 issues.add("Snapshot version in " + pom);
             }
-            for (Iterator j = pomInfo.getDependencies().iterator(); j.hasNext();) {
-                Dependency dependency = (Dependency) j.next();
+            for (Dependency dependency: pomInfo.getDependencies()) {
                 if (!dep2info.containsKey(dependency)) {
                     issues.add("Unpackaged dependency: " + dependency + " in " + pom);
-                    List pomIssues = (List) pomsWithIssues.get(pom);
+                    List<Dependency> pomIssues = pomsWithIssues.get(pom);
                     if (pomIssues == null) {
-                        pomIssues = new ArrayList();
+                        pomIssues = new ArrayList<Dependency>();
                         pomsWithIssues.put(pom, pomIssues);
                     }
                     pomIssues.add(dependency);
                 }
             }
-            for (Iterator j = pomInfo.getPlugins().iterator(); j.hasNext();) {
-                Dependency dependency = (Dependency) j.next();
+            for (Dependency dependency: pomInfo.getPlugins()) {
                 if (!dep2info.containsKey(dependency)) {
                     issues.add("Unpackaged plugin: " + dependency + " in " + pom);
-                    List pomIssues = (List) pomsWithIssues.get(pom);
+                    List<Dependency> pomIssues = pomsWithIssues.get(pom);
                     if (pomIssues == null) {
-                        pomIssues = new ArrayList();
+                        pomIssues = new ArrayList<Dependency>();
                         pomsWithIssues.put(pom, pomIssues);
                     }
                     pomIssues.add(dependency);
@@ -272,38 +264,35 @@
         }
 
         writer.printSectionStart("Errors");
-        for (Iterator i = issues.iterator(); i.hasNext();) {
-            String issue = (String) i.next();
+        for (String issue : issues) {
             writer.printItem(issue);
             writer.endItem();
         }
         writer.printSectionEnd();
 
         // Find the poms with most issues
-        Map pomsWithNumberOfIssues = new TreeMap(Collections.reverseOrder());
-        for (Iterator i = pomsWithIssues.entrySet().iterator(); i.hasNext();) {
-            Entry entry = (Entry) i.next();
-            File pom = (File) entry.getKey();
-            List missingDeps = (List) entry.getValue();
+        Map<Integer, List<File>> pomsWithNumberOfIssues = new TreeMap<Integer, List<File>>(Collections.reverseOrder());
+        for (Entry<File, List<Dependency>> entry : pomsWithIssues.entrySet()) {
+            File pom = entry.getKey();
+            List<Dependency> missingDeps = entry.getValue();
             int count = missingDeps.size();
-            List orderedPoms = (List) pomsWithNumberOfIssues.get(new Integer(count));
+            List<File> orderedPoms = pomsWithNumberOfIssues.get(count);
             if (orderedPoms == null) {
-                orderedPoms = new ArrayList();
-                pomsWithNumberOfIssues.put(new Integer(count), orderedPoms);
+                orderedPoms = new ArrayList<File>();
+                pomsWithNumberOfIssues.put(count, orderedPoms);
             }
             orderedPoms.add(pom);
         }
         if (!pomsWithNumberOfIssues.isEmpty()) {
         	writer.printSectionStart("Top 10 POM files with issues");
             int count = 0;
-            for (Iterator i = pomsWithNumberOfIssues.values().iterator(); i.hasNext() && count < 10;) {
-                List orderedPoms = (List) i.next();
-                for (Iterator j = orderedPoms.iterator(); j.hasNext() && count < 10; count++) {
-                    File pom = (File) j.next();
-                    List missingDeps = (List) pomsWithIssues.get(pom);
+            for (Iterator<List<File>> i = pomsWithNumberOfIssues.values().iterator(); i.hasNext() && count < 10;) {
+                List<File> orderedPoms = i.next();
+                for (Iterator<File> j = orderedPoms.iterator(); j.hasNext() && count < 10; count++) {
+                    File pom = j.next();
+                    List<Dependency> missingDeps = pomsWithIssues.get(pom);
                     writer.printItem("Missing dependencies in " + pom);
-                    for (Iterator k = missingDeps.iterator(); k.hasNext();) {
-                        Dependency dependency = (Dependency) k.next();
+                    for (Dependency dependency : missingDeps) {
                         writer.printItem(dependency.toString());
                         writer.endItem();
                     }
@@ -314,37 +303,33 @@
         }
 
         // Find the dependencies that need packaging most
-        Map missingDependenciesCounts = new HashMap();
-        for (Iterator i = pomsWithIssues.entrySet().iterator(); i.hasNext();) {
-            Entry entry = (Entry) i.next();
-            List missingDeps = (List) entry.getValue();
-            for (Iterator j = missingDeps.iterator(); j.hasNext();) {
-                Dependency missingDependency = (Dependency) j.next();
-                Integer lastCount = (Integer) missingDependenciesCounts.remove(missingDependency);
+        Map<Dependency, Integer> missingDependenciesCounts = new HashMap<Dependency, Integer>();
+        for (Entry<File, List<Dependency>> entry : pomsWithIssues.entrySet()) {
+            List<Dependency> missingDeps = entry.getValue();
+            for (Dependency missingDependency : missingDeps) {
+                Integer lastCount = missingDependenciesCounts.remove(missingDependency);
                 if (lastCount == null) {
-                    lastCount = new Integer(0);
+                    lastCount = 0;
                 }
-                missingDependenciesCounts.put(missingDependency, new Integer(lastCount.intValue() + 1));
+                missingDependenciesCounts.put(missingDependency, lastCount + 1);
             }
         }
-        List missingDependenciesCountList = new ArrayList(missingDependenciesCounts.entrySet());
-        Collections.sort(missingDependenciesCountList, new Comparator() {
+        List<Map.Entry<Dependency, Integer>> missingDependenciesCountList = new ArrayList<Map.Entry<Dependency, Integer>>(missingDependenciesCounts.entrySet());
+        Collections.sort(missingDependenciesCountList, new Comparator<Map.Entry<Dependency, Integer>>() {
 
-            public int compare(Object o, Object o2) {
-                Map.Entry entry1 = (Entry) o;
-                Map.Entry entry2 = (Entry) o2;
-                Integer count1 = (Integer) entry1.getValue();
-                Integer count2 = (Integer) entry2.getValue();
+            public int compare(Map.Entry<Dependency, Integer> entry1, Map.Entry<Dependency, Integer> entry2) {
+                Integer count1 = entry1.getValue();
+                Integer count2 = entry2.getValue();
                 return count2.compareTo(count1);
             }
         });
         if (! missingDependenciesCountList.isEmpty()) {
         	writer.printSectionStart("Top 10 missing dependencies");
             int count = 0;
-            for (Iterator i = missingDependenciesCountList.iterator(); i.hasNext() && count < 10; count++) {
-                Map.Entry entry = (Entry) i.next();
-                Dependency missingDependency = (Dependency) entry.getKey();
-                Integer numberOfTimes = (Integer) entry.getValue();
+            for (Iterator<Map.Entry<Dependency, Integer>> i = missingDependenciesCountList.iterator(); i.hasNext() && count < 10; count++) {
+                Map.Entry<Dependency, Integer> entry = i.next();
+                Dependency missingDependency = entry.getKey();
+                Integer numberOfTimes = entry.getValue();
                 writer.printItem("Missing dependency " + missingDependency + " is needed in " + numberOfTimes + " places");
                 writer.endItem();
             }
@@ -354,13 +339,12 @@
         writer.printEnd();
     }
 
-    private void resolveAll(Map file2pom) {
+    private void resolveAll(Map<File, POMInfo> file2pom) {
         // copy to avoid concurrent modifications
-        Map copy = new HashMap(file2pom);
-        for (Iterator i = copy.entrySet().iterator(); i.hasNext();) {
-            Entry entry = (Entry) i.next();
+        Map<File, POMInfo> copy = new HashMap<File, POMInfo>(file2pom);
+        for (Entry<File, POMInfo> entry : copy.entrySet()) {
             try {
-                registerPom((File) entry.getKey(), (POMInfo) entry.getValue());
+                registerPom(entry.getKey(), entry.getValue());
             } catch (DependencyNotFoundException e) {
                 // Ignore
             }
@@ -371,8 +355,7 @@
         if (files == null) {
             return;
         }
-        for (int i = 0; i < files.length; i++) {
-            File file = files[i];
+        for (File file : files) {
             if (file.isDirectory()) {
                 scan(file.listFiles());
             } else if (file.getName().endsWith(".pom")) {
@@ -396,7 +379,7 @@
 
         POMInfo parentPOM = superPom;
         try {
-            if (pomInfo.getParent() != null) {
+            if (pomInfo.getParent() != null && !pomInfo.getParent().isSuperPom()) {
                 POMInfo foundParent = getPOM(pomInfo.getParent());
                 if (foundParent == null) {
                     pomsWithMissingParent.put(file, pomInfo);
@@ -414,17 +397,15 @@
             // as we can have intermediate situations in the DependenciesSolver where
             // the true parent POM is not known and will be eliminated, yet we need
             // the versions from the super POM.
-            pomInfo.mergeManagement(parentPOM);
+            pomInfo.setParentPOM(parentPOM);
 
             pomsWithMissingVersions.remove(file);
-            for (Iterator i = pomInfo.getDependencies().iterator(); i.hasNext();) {
-                Dependency dependency = (Dependency) i.next();
+            for (Dependency dependency : pomInfo.getDependencies()) {
                 if (dependency.getVersion() == null) {
                     pomsWithMissingVersions.put(file, pomInfo);
                 }
             }
-            for (Iterator i = pomInfo.getPlugins().iterator(); i.hasNext();) {
-                Dependency dependency = (Dependency) i.next();
+            for (Dependency dependency : pomInfo.getPlugins()) {
                 if (dependency.getVersion() == null) {
                     pomsWithMissingVersions.put(file, pomInfo);
                 }
@@ -454,18 +435,20 @@
 
         // Parse parameters
         int i = inc(-1, args);
-        while (i < args.length && (args[i].trim().startsWith("-") || args[i].trim().isEmpty())) {
-            String arg = args[i].trim();
-            if (arg.startsWith("-o")) {
-                format = arg.substring(2).trim();
-            } else if (arg.startsWith("--output=")) {
-                format = arg.substring("--output=".length()).trim();
-            } else if (arg.startsWith("-r")) {
-                repoLocation = new File(arg.substring(2).trim());
-            } else if (arg.startsWith("--repository=")) {
-                repoLocation = new File(arg.substring("--repository=".length()).trim());
+        if (args != null) {
+            while (i < args.length && (args[i].trim().startsWith("-") || args[i].trim().isEmpty())) {
+                String arg = args[i].trim();
+                if (arg.startsWith("-o")) {
+                    format = arg.substring(2).trim();
+                } else if (arg.startsWith("--output=")) {
+                    format = arg.substring("--output=".length()).trim();
+                } else if (arg.startsWith("-r")) {
+                    repoLocation = new File(arg.substring(2).trim());
+                } else if (arg.startsWith("--repository=")) {
+                    repoLocation = new File(arg.substring("--repository=".length()).trim());
+                }
+                i = inc(i, args);
             }
-            i = inc(i, args);
         }
 
         Repository repository = new Repository(repoLocation);

Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Rule.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Rule.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/Rule.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -104,10 +104,7 @@
         if (this.pattern != other.pattern && (this.pattern == null || !this.pattern.pattern().equals(other.pattern.pattern()))) {
             return false;
         }
-        if ((this.replace == null) ? (other.replace != null) : !this.replace.equals(other.replace)) {
-            return false;
-        }
-        return true;
+        return !((this.replace == null) ? (other.replace != null) : !this.replace.equals(other.replace));
     }
 
     public int hashCode() {

Modified: trunk/maven-repo-helper/src/main/share/mh_lib.sh
===================================================================
--- trunk/maven-repo-helper/src/main/share/mh_lib.sh	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/main/share/mh_lib.sh	2011-12-04 22:57:43 UTC (rev 15502)
@@ -4,7 +4,7 @@
 # - package selection
 #
 
-MH_VERSION=${MH_VERSION:-1.7}
+MH_VERSION=${MH_VERSION:-1.7.1}
 CLASSPATH=/usr/share/java/stax-api.jar:/usr/share/java/stax.jar:/usr/share/java/xml-apis.jar:/usr/share/java/maven-repo-helper.jar
 JAVA_OPTIONS="-Djavax.xml.stream.XMLOutputFactory=com.bea.xml.stream.XMLOutputFactoryBase -Djavax.xml.stream.XMLInputFactory=com.bea.xml.stream.MXParserFactory"
 

Modified: trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMReaderTest.java
===================================================================
--- trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMReaderTest.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMReaderTest.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -1,7 +1,5 @@
 package org.debian.maven.repo;
 
-import java.util.Iterator;
-
 /*
  * Copyright 2009 Ludovic Claude.
  *
@@ -39,7 +37,7 @@
         assertEquals("pom", info.getThisPom().getType());
 
         assertEquals(1, info.getDependencies().size());
-        Dependency dependency = (Dependency) info.getDependencies().get(0);
+        Dependency dependency = info.getDependencies().get(0);
         assertEquals("junit", dependency.getGroupId());
         assertEquals("junit", dependency.getArtifactId());
         assertEquals("3.8.1", dependency.getVersion());
@@ -100,7 +98,7 @@
         assertEquals("jar", info.getThisPom().getType());
 
         assertEquals(6, info.getDependencies().size());
-        Dependency dependency = (Dependency) info.getDependencies().get(5);
+        Dependency dependency = info.getDependencies().get(5);
         assertEquals("org.jboss.test-harness", dependency.getGroupId());
         assertEquals("jboss-test-harness-jboss-as-51", dependency.getArtifactId());
         assertEquals("1.0.0", dependency.getVersion());
@@ -144,7 +142,7 @@
         assertEquals("jar", info.getThisPom().getType());
 
         assertEquals(6, info.getDependencies().size());
-        Dependency dependency = (Dependency) info.getDependencies().get(0);
+        Dependency dependency = info.getDependencies().get(0);
         assertEquals("javax.validation", dependency.getGroupId());
         assertEquals("validation-api", dependency.getArtifactId());
         assertEquals(null, dependency.getVersion());
@@ -152,7 +150,7 @@
         assertEquals("runtime", dependency.getScope());
         assertEquals(false, dependency.isOptional());
 
-        dependency = (Dependency) info.getDependencies().get(1);
+        dependency = info.getDependencies().get(1);
         assertEquals("org.slf4j", dependency.getGroupId());
         assertEquals("slf4j-api", dependency.getArtifactId());
         assertEquals(null, dependency.getVersion());
@@ -160,7 +158,7 @@
         assertEquals("runtime", dependency.getScope());
         assertEquals(false, dependency.isOptional());
 
-        dependency = (Dependency) info.getDependencies().get(2);
+        dependency = info.getDependencies().get(2);
         assertEquals("com.googlecode.jtype", dependency.getGroupId());
         assertEquals("jtype", dependency.getArtifactId());
         assertEquals("0.1.0", dependency.getVersion());
@@ -168,7 +166,7 @@
         assertEquals("runtime", dependency.getScope());
         assertEquals(false, dependency.isOptional());
 
-        dependency = (Dependency) info.getDependencies().get(3);
+        dependency = info.getDependencies().get(3);
         assertEquals("org.slf4j", dependency.getGroupId());
         assertEquals("slf4j-log4j12", dependency.getArtifactId());
         assertEquals(null, dependency.getVersion());
@@ -176,7 +174,7 @@
         assertEquals("runtime", dependency.getScope());
         assertEquals(true, dependency.isOptional());
 
-        dependency = (Dependency) info.getDependencies().get(4);
+        dependency = info.getDependencies().get(4);
         assertEquals("org.hibernate.java-persistence", dependency.getGroupId());
         assertEquals("jpa-api", dependency.getArtifactId());
         assertEquals("2.0.Beta-20090815", dependency.getVersion());
@@ -184,7 +182,7 @@
         assertEquals("runtime", dependency.getScope());
         assertEquals(true, dependency.isOptional());
 
-        dependency = (Dependency) info.getDependencies().get(5);
+        dependency = info.getDependencies().get(5);
         assertEquals("org.testng", dependency.getGroupId());
         assertEquals("testng", dependency.getArtifactId());
         assertEquals(null, dependency.getVersion());

Modified: trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/RepositoryTest.java
===================================================================
--- trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/RepositoryTest.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/RepositoryTest.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -20,10 +20,6 @@
 import javax.xml.stream.XMLStreamException;
 import java.io.File;
 import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.Map;
 
 public class RepositoryTest extends TestBase {
 

Modified: trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/TestBase.java
===================================================================
--- trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/TestBase.java	2011-12-04 13:43:43 UTC (rev 15501)
+++ trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/TestBase.java	2011-12-04 22:57:43 UTC (rev 15502)
@@ -38,7 +38,7 @@
 public class TestBase extends XMLTestCase {
 
     protected static File testDir = new File("tmp");
-    private List openedReaders = new ArrayList();
+    private List<Reader> openedReaders = new ArrayList<Reader>();
     protected File pom;
     protected File updatedPom;
 
@@ -56,8 +56,8 @@
         if (updatedPom.exists()) {
             updatedPom.delete();
         }
-        for (Iterator i = openedReaders.iterator(); i.hasNext(); ) {
-            Reader reader = (Reader) i.next();
+        for (Iterator<Reader> i = openedReaders.iterator(); i.hasNext(); ) {
+            Reader reader = i.next();
             try {
                 reader.close();
             } catch (IOException ex) {




More information about the pkg-java-commits mailing list