Created
February 15, 2013 19:00
-
-
Save quidryan/4962525 to your computer and use it in GitHub Desktop.
Revisions
-
quidryan created this gist
Feb 15, 2013 .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,39 @@ apply plugin: "java" repositories { mavenCentral() } dependencies { compile "org.spockframework:spock-core:0.7-groovy-2.0" compile "org.codehaus.groovy:groovy-all:1.8.6" } configurations.all { incoming.resolutionResult.allDependencies { DependencyResult dependencyResult -> if (!SemanticVersion.isMatch(dependencyResult.requested.version) || !SemanticVersion.isMatch(dependencyResult.selected.id.version)) { return } def requested = new SemanticVersion(dependencyResult.requested.version) def selected = new SemanticVersion(dependencyResult.selected.id.version) if (requested.major != selected.major) { throw new Exception("Dependency $dependencyResult has a different selected major version than was requested") } } } class SemanticVersion { int major int minor int patch SemanticVersion(String version) { (major, minor, patch) = version.split("\\.") } static boolean isMatch(String version) { version ==~ /\d+\.\d+\.\d+/ } }