Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do gradle unit tests for Google app engine expect persistence.xml?

I have created a Google app engine project using an maven archetype project with the Datanucleus JPA provider, essentially following the Google app engine documentation.

Everything works fine when running the maven goal "test".

Now I had to integrate the project into Android studio and wanted to migrate the build script to gradle. I copied all dependencies from the pom.xml to the build.gradle and the project builds fine. However, all tests that access the Google datastore fail.

During test output I get the following message:

Warning:No META-INF/persistence.xml files were found in the CLASSPATH of the current thread!

I checked the build folder which is created during the build and no folder contains the persistence.xml from src/main/webapp/WEB-INF/classes/META-INF

Using maven, however, it is correctly put in the target/myapp-1.0-SNAPSHOT/WEB-INF/classes/META-INF folder.

I have tried copying the persistence.xml using a gradle copy task into various locations, such as build/classes/META-INF build/classes/webapp/WEB-INF/classes/META-INF and so on, but nothing worked.

like image 400
itchee Avatar asked Mar 24 '15 11:03

itchee


1 Answers

Just because the file is placed in a directory doesn't automatically mean it's in the CLASSPATH.

Place the META-INF folder containing persistence.xml in /src/main/resources.

like image 161
skullkid Avatar answered Oct 12 '22 23:10

skullkid