Exclude groovy dependency from compile but not from testCompile


(Hans Marggraff) #1

I am using groovy for testing, but not for the main classes. So I tried a build file like this:

apply plugin 'groovy'
  dependencies {
    groovy 'org.codehaus.groovy:groovy-all:2.0.5'
}

Listing the dependencies I now find grovy as a dependency in all configurations. So I tried adding

configurations { compile.exclude module:'groovy-all' }

and added:

testCompile 'org.codehaus.groovy:groovy-all:2.0.5'

to the dependencies. Now groovy is gone from all configurations, and I cannot compile my tests. How is this done right?


How to exclude a dependency from compile but not from testCompile without reshuffling configuration structure
(Luke Daley) #2

You need to reshuffle the configuration inheritance…

configurations {

compile.extendsFrom = []

testCompile.extendsFrom groovy

}


(Hans Marggraff) #3

Ahh, thanks. Did the job.