Skip to content

Commit

Permalink
fix for GRAILS-11055 "Dependency exclusion does not work with 'aether…
Browse files Browse the repository at this point in the history
…' dependency manager"
  • Loading branch information
graemerocher committed Feb 11, 2014
1 parent 6ec30ca commit 9fec9a1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DependencyConfiguration {

void exclude(Map<String,String> exc) {
List<Exclusion> exclusions = getExclusionList()
exclusions << new Exclusion(exc.group, exc.name, exc.classifier, exc.extension)
exclusions << new Exclusion(exc.group ?: WILD_CARD, exc.name ?: WILD_CARD, exc.classifier ?: WILD_CARD, exc.extension ?: WILD_CARD)
dependency = dependency.setExclusions(exclusions)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,31 @@ import spock.lang.Specification
*/
class AetherDependencyManagerSpec extends Specification {

@Issue('GRAILS-11055')
void "Test that a transitive dependency excluded with the map syntax is actually excluded"() {
given:"A dependency with an exclusion"
def dependencyManager = new AetherDependencyManager()
dependencyManager.parseDependencies {
repositories {
grailsCentral()
}
plugins {
compile(":jasper:1.7.0") {
excludes([group: 'org.apache.poi', name: 'poi'])
}
}
}

when:"The dependency is resolved"
def report = dependencyManager.resolve('compile')
then:"The transitive dependency is excluded"
report.pluginZips.any { File f -> f.name.contains('jasper')}
!report.jarFiles.any { File f -> f.name.contains('poi')}
}

@Issue('GRAILS-10638')
void "Test that a dependency included in both compile and test scopes ends up in both scopes"() {
given:"A dependency manager with a dependency that contains exclusions"
given:"A dependency manager with a dependency that contains the dependency in both scopes"
def dependencyManager = new AetherDependencyManager()
dependencyManager.parseDependencies {
repositories {
Expand All @@ -43,11 +65,11 @@ class AetherDependencyManagerSpec extends Specification {
test 'mysql:mysql-connector-java:5.1.24'
}
}
when:"The grails dependencies are obtained"
when:"The compile and test scopes are obtained"
def compileFiles = dependencyManager.resolve('compile').allArtifacts
def testFiles = dependencyManager.resolve('test').allArtifacts

then:"The exclusions are present"
then:"The dependency is present in both scopes"
compileFiles.size() == 1
testFiles.size() == 1

Expand All @@ -69,7 +91,7 @@ class AetherDependencyManagerSpec extends Specification {
compile 'org.grails:grails-test:2.3.2'
}
}
when:"The grails dependencies are obtained"
when:"The compile and test scopes are obtained"
def compileFiles = dependencyManager.resolve('compile').allArtifacts
def testFiles = dependencyManager.resolve('test').allArtifacts

Expand Down Expand Up @@ -171,7 +193,7 @@ class AetherDependencyManagerSpec extends Specification {
}

void "Test customize repository policy"() {
given:"A dependency manager with a dependency that contains exclusions"
given:"A dependency manager with a custom repository policy"
def dependencyManager = new AetherDependencyManager()
dependencyManager.parseDependencies {
repositories {
Expand All @@ -193,7 +215,7 @@ class AetherDependencyManagerSpec extends Specification {
}

void "Test grails dependency transitive setting"() {
given:"A dependency manager with a dependency that contains exclusions"
given:"A dependency manager with a dependency that has transitive resolves disabled"
def dependencyManager = new AetherDependencyManager()
dependencyManager.parseDependencies {
dependencies {
Expand Down

0 comments on commit 9fec9a1

Please sign in to comment.