Where do I put META-INF in Gradle?
Asked Answered
C

2

7

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?

Clarey answered 3/4, 2015 at 12:13 Comment(1)
possible duplicate of Where do gradle unit tests for Google app engine expect persistence.xml?Basinger
C
16

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.

Clarey answered 3/4, 2015 at 12:13 Comment(0)
L
4

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"]
Labionasal answered 5/4, 2015 at 22:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.