How to globally exclude transitive non indy Groovy JARs?

In my project I use groovy-indy jar, but many libraries provides “normal” groovy jars. Gradle threats groovy-2.4.1jar and groovy-2.4.1-indy.jar as two separate packages (and that’s can be explained as in some cases it is useful to have multiple jars with different classifiers, e.g. jar with test infrastructure as a test dependency). Unfortunately I end up with two groovy jars on a classpath (and packaged into a WAR archive) which breaks the build (my code requires -indy package to run).

I can exclude Groovy transitive dependency from particular dependencies, but it is error prone when new dependencies are added to a project. I tried to exclude -indy jars with ‘resolution strategy’ mechanism, but there is no access to classifiers. Without that it is very hard to use groovy-indy (in a build tool claiming to have excellent support for Groovy-based projects).

Question. How can I globally exclude a dependency based on its classifier?

1 Like