Groovy runtime unintentionally getting on the projects compile classpath

(Russ Egan) #1

The groovy plugin makes the ‘compile’ configuration extend the ‘groovy’ configuration. This is what you’d want for projects using either all groovy source code, or using mixed source code.

But we have a pattern here where groovy is only used to write unit tests. In those cases, we don’t want the groovy jars to get pulled into the transitive runtime classpath. We end up accidentally shipping the groovy jars with our product.

I’m not sure what the clean solution to this is. Maybe a second plugin, like ‘groovyTests’ that just has testCompile.extendsFrom groovy?

My workaround is to apply the GroovyBasePlugin, then explicitly have testCompile.extendsFrom groovy.

(Luke Daley) #2

You can just remove the link between compile and groovy configurations:

configurations {
  compile.extendsFrom = compile.extendsFrom.findAll { it != groovy }
  testCompile.extendsFrom groovy