Created
March 13, 2016 16:53
Revisions
-
slavashvets created this gist
Mar 13, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ /** Maven Resolution Strategy ========================= Description: Adds ability to set Maven-like conflict resolution strategy for any configuration | Maven works on the principle of nearest wins strategy while resolving the dependency | conflicts, that means whichever version it finds nearer in the tree, it will take | that version and ignore the other versions. | [http://techidiocy.com/maven-dependency-version-conflict-problem-and-resolution/] Usage: 1. Type `maven()` inside `resolutionStrategy` closure param Example (apply to all configuration): configurations.all.resolutionStrategy { maven() } Example (apply to compile configuration): configuration.compile.resolutionStrategy { maven() } */ project.configurations.all { resolutionStrategy.extensions.add "maven", { def versionMap = new HashMap() resolutionStrategy.eachDependency { DependencyResolveDetails details -> def moduleId = "${details.requested.group}:${details.requested.name}" as String if (!versionMap.containsKey(moduleId)) { versionMap[moduleId] = details.requested.version } else { details.useVersion versionMap[moduleId] } } } }