Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I put META-INF in Gradle?

I'm following the Appsrox tutorial on how to Create an Instant Messaging app using Google Cloud Messaging (GCM). The differences are that I use Android Studio instead of Eclipse, and Gradle for build automation. I've tried to put META-INF inside 'src/main' folder but I got a warning from Google App Engine:

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

EntityManager crashes during the initialization process, cause it can't find 'persistence.xml'.

I'm looking for a simple answer to what should be a simple issue: where do I put META-INF folder?

like image 314
naXa Avatar asked Apr 03 '15 12:04

naXa


2 Answers

In Gradle based project place the META-INF folder containing 'persistence.xml' in '/src/main/resources'. (The same is true for a Maven based project)

Find more about Standard Directory Layout here.

like image 101
naXa Avatar answered Sep 20 '22 14:09

naXa


As @naXa suggested, '/src/main/resources' is the default location, and you should normally put it there. But if for some reason that's not practical, you can place it anywhere you want as long as you tell Gradle about it. For example, if you wanted to place the META-INF directory in 'src/main/java', you could write:

// Allow resources to live in same directory as source code
sourceSets.main.resources.srcDirs += ["src/main/java"]
sourceSets.test.resources.srcDirs += ["src/test/java"]
like image 32
dnault Avatar answered Sep 22 '22 14:09

dnault