Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

GRAILS-6147 - take two at better maven classifier support.

The solution is to merge all dependencies that are for the same module, but have different classifiers into one dependency with an artifact for each.

Inspired from: http://stackoverflow.com/questions/7804253/how-to-dowload-multiple-maven-dependencies-in-ivy-with-different-classifiers
  • Loading branch information...
commit b13496263128786a9b7e1195aa3907e085e947e6 1 parent fa32c78
Luke Daley authored April 18, 2012
34  grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/AbstractIvyDependencyManager.java
@@ -452,6 +452,38 @@ public void registerDependency(String scope, EnhancedDefaultDependencyDescriptor
452 452
 
453 453
         dependencyDescriptors.add(descriptor);
454 454
         if (shouldIncludeDependency(descriptor)) {
  455
+            addToModuleDescriptor(scope, descriptor, moduleDescriptor);
  456
+        }
  457
+    }
  458
+
  459
+    private boolean areSameLogicalDependency(ModuleRevisionId lhs, ModuleRevisionId rhs) {
  460
+        return lhs.getModuleId().equals(rhs.getModuleId()) && lhs.getRevision().equals(rhs.getRevision());
  461
+    }
  462
+
  463
+    private void addToModuleDescriptor(String scope, EnhancedDefaultDependencyDescriptor descriptor, DefaultModuleDescriptor moduleDescriptor) {
  464
+        boolean foundDependency = false;
  465
+        for (DependencyDescriptor existingDescriptor : moduleDescriptor.getDependencies()) {
  466
+            if (areSameLogicalDependency(descriptor.getDependencyRevisionId(), existingDescriptor.getDependencyRevisionId())) {
  467
+                foundDependency = true;
  468
+                for (DependencyArtifactDescriptor artifactToAdd : descriptor.getAllDependencyArtifacts()) {
  469
+                    boolean foundArtifact = false;
  470
+                    for (DependencyArtifactDescriptor existingArtifact : existingDescriptor.getAllDependencyArtifacts()) {
  471
+                        if (existingArtifact.equals(artifactToAdd)) {
  472
+                            if (existingArtifact.getExtraAttributes().equals(artifactToAdd.getExtraAttributes())) {
  473
+                                foundArtifact = true;
  474
+                                break;
  475
+                            }
  476
+                        }
  477
+                    }
  478
+                    if (!foundArtifact) {
  479
+                        ((DefaultDependencyDescriptor)existingDescriptor).addDependencyArtifact(scope, artifactToAdd);
  480
+                    }
  481
+                }
  482
+                break;
  483
+            }
  484
+        }
  485
+
  486
+        if (!foundDependency) {
455 487
             moduleDescriptor.addDependency(descriptor);
456 488
         }
457 489
     }
@@ -484,7 +516,7 @@ else if(descriptor.getPlugin() != null && (existing instanceof EnhancedDefaultDe
484 516
         pluginNameToDescriptorMap.put(name, descriptor);
485 517
         pluginDependencyDescriptors.add(descriptor);
486 518
         if (shouldIncludeDependency(descriptor)) {
487  
-            moduleDescriptor.addDependency(descriptor);
  519
+            addToModuleDescriptor(scope, descriptor, moduleDescriptor);
488 520
         }
489 521
     }
490 522
 

0 notes on commit b134962

Please sign in to comment.
Something went wrong with that request. Please try again.