Skip to content
Browse files

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...
1 parent fa32c78 commit b13496263128786a9b7e1195aa3907e085e947e6 @alkemist alkemist committed Apr 18, 2012
View
34 ...trap/src/main/groovy/org/codehaus/groovy/grails/resolve/AbstractIvyDependencyManager.java
@@ -452,6 +452,38 @@ public void registerDependency(String scope, EnhancedDefaultDependencyDescriptor
dependencyDescriptors.add(descriptor);
if (shouldIncludeDependency(descriptor)) {
+ addToModuleDescriptor(scope, descriptor, moduleDescriptor);
+ }
+ }
+
+ private boolean areSameLogicalDependency(ModuleRevisionId lhs, ModuleRevisionId rhs) {
+ return lhs.getModuleId().equals(rhs.getModuleId()) && lhs.getRevision().equals(rhs.getRevision());
+ }
+
+ private void addToModuleDescriptor(String scope, EnhancedDefaultDependencyDescriptor descriptor, DefaultModuleDescriptor moduleDescriptor) {
+ boolean foundDependency = false;
+ for (DependencyDescriptor existingDescriptor : moduleDescriptor.getDependencies()) {
+ if (areSameLogicalDependency(descriptor.getDependencyRevisionId(), existingDescriptor.getDependencyRevisionId())) {
+ foundDependency = true;
+ for (DependencyArtifactDescriptor artifactToAdd : descriptor.getAllDependencyArtifacts()) {
+ boolean foundArtifact = false;
+ for (DependencyArtifactDescriptor existingArtifact : existingDescriptor.getAllDependencyArtifacts()) {
+ if (existingArtifact.equals(artifactToAdd)) {
+ if (existingArtifact.getExtraAttributes().equals(artifactToAdd.getExtraAttributes())) {
+ foundArtifact = true;
+ break;
+ }
+ }
+ }
+ if (!foundArtifact) {
+ ((DefaultDependencyDescriptor)existingDescriptor).addDependencyArtifact(scope, artifactToAdd);
+ }
+ }
+ break;
+ }
+ }
+
+ if (!foundDependency) {
moduleDescriptor.addDependency(descriptor);
}
}
@@ -484,7 +516,7 @@ else if(descriptor.getPlugin() != null && (existing instanceof EnhancedDefaultDe
pluginNameToDescriptorMap.put(name, descriptor);
pluginDependencyDescriptors.add(descriptor);
if (shouldIncludeDependency(descriptor)) {
- moduleDescriptor.addDependency(descriptor);
+ addToModuleDescriptor(scope, descriptor, moduleDescriptor);
}
}

0 comments on commit b134962

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