Skip to content

Commit

Permalink
Copy over only Kotlin external dependencies from super configurations
Browse files Browse the repository at this point in the history
This avoids project resolution failures or variant failures from
capabilities conflicts. As Kotlin stashes its stdlib magically as an
implicit dependency that appears at runtime (versus a default dependency
as per Gradle's idioms), we have to special case its inclusion for those
projects.
  • Loading branch information
ben-manes committed Sep 13, 2020
1 parent a23c555 commit 0a290fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -23,7 +23,7 @@ apply plugin: 'nexus'
apply plugin: 'codenarc'

group = 'com.github.ben-manes'
version = '0.32.0'
version = '0.33.0'

sourceCompatibility = '1.8'

Expand Down
Expand Up @@ -131,9 +131,13 @@ class Resolver {
copy.setCanBeResolved(true)
}

// Resolve using the latest version of explicitly declaired dependencies and retains those
// inherited from the super configurations (which may be required for variant resolution).
Set<Dependency> inherited = (configuration.allDependencies - configuration.dependencies)
// Resolve using the latest version of explicitly declaired dependencies and retains Kotlin's
// inherited stdlib dependencies from the super configurations. This is required for variant
// resolution, but the full set can break consumer capability matching.
Set<Dependency> inherited = configuration.allDependencies.findAll { dependency ->
(dependency instanceof ExternalDependency) && (dependency.group == 'org.jetbrains.kotlin')
}.minus(configuration.dependencies)

copy.dependencies.clear()
copy.dependencies.addAll(latest)
copy.dependencies.addAll(inherited)
Expand Down

0 comments on commit 0a290fb

Please sign in to comment.