vendredi 30 octobre 2015

test spring jpa in gradle

I am moving from maven to gradle. I have some database tests. I can run them in maven but I want run them in gradle. By default these tests fail (BeanCreationException and stuff). I found that in order to run them successfully I have to place such configuration in build.gradle

sourceSets.main.output.classesDir = sourceSets.test.output.classesDir
sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
sourceSets.test.output.resourcesDir = sourceSets.test.output.classesDir

My build.gradle contains also dependencies and description. That is all. Pretty simple.

I would like to solve that with proper classpath. However, when I list the content of sourceSets.test.runtimeClasspath I get (omitted outside of project jars)

project/build/classes/test
project/build/resources/test
project/build/classes/main
project/build/resources/main

All the tests need is in these directories. I cannot figure out why classpath is insufficient. How can I make it sufficient? Why do I have to place all files in same dir?

I use only spring-data-jpa from spring. There are no other transitive spring dependencies.

Aucun commentaire:

Enregistrer un commentaire