Skip to content

Commit

Permalink
metaclass
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga committed Oct 10, 2019
1 parent 2ef7a28 commit c926953
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,10 @@ class Resolver {
}

// Common use case for dependency constraints is a java-platform BOM project.
try {
if (supportsConstraints(configuration)) {
configuration.dependencyConstraints.each { dependency ->
latest.add(createQueryDependency(dependency, revision))
}
} catch (MissingPropertyException e) {
// Skip if constraints not supported
}

Configuration copy = configuration.copyRecursive().setTransitive(false)
Expand Down Expand Up @@ -239,13 +237,11 @@ class Resolver {
coordinates.put(coordinate.key, declared.get(coordinate.key))
}

try {
if (supportsConstraints(copy)) {
for (DependencyConstraint constraint : copy.dependencyConstraints) {
Coordinate coordinate = Coordinate.from(constraint)
coordinates.put(coordinate.key, declared.get(coordinate.key))
}
} catch (MissingPropertyException e) {
// Skip if constraints not supported
}

// Ignore undeclared (hidden) dependencies that appear when resolving a configuration
Expand Down Expand Up @@ -364,19 +360,21 @@ class Resolver {
return null
}

private static boolean supportsConstraints(Configuration configuration) {
return configuration.metaClass.respondsTo(configuration, "getDependencyConstraints");
}

private static List<Coordinate> getResolvableDependencies(Configuration configuration) {
List<Coordinate> coordinates = configuration.dependencies.findAll { dependency ->
dependency instanceof ExternalDependency
}.collect { dependency ->
Coordinate.from(dependency)
}

try {
if (supportsConstraints(configuration)) {
configuration.dependencyConstraints.each {
coordinates.add(Coordinate.from(it))
}
} catch (MissingPropertyException e) {
// Skip
}

return coordinates
Expand Down

0 comments on commit c926953

Please sign in to comment.