Alter the classpath during tests


(David Tiselius) #1

This is probably an easy thing to do, although googling for the solution for almost a whole day makes me a bit suspisiuos…

What I need to do is to replace some reseources from the runtime classpath when running my tests. There is both a settings.groovy and a logback.groovy that I want to be replaced by equivalents made for tests.

How do I get the test task not to include the src/main/resources? (but let the src/test/resources remain)?


(Peter Niederwieser) #2

This should do the job:

sourceSets.test.runtimeClasspath -= files(sourceSets.main.output.resourcesDir)

(David Tiselius) #3

Wow thanks!!