Exclude dependency from compile but not runtime


#1

How can I exclude a transitive dependency from compile but not runtime? For example I would like to prevent commons logging from being used in our code, but some transitive dependencies (such as Spring Framework) require it.

I tried using
configurations { compile.exclude group: 'commons-logging', module: 'commons-logging' }
but that excludes it from runtime also.


(Stefan Oehme) #2

You can exlude them from the compileClasspath configuration. Compilation will fail if they are used, but runtime will still work.


#3

That worked nicely.

Thanks!