Gradle [META-INF / persistence.xml] not found

I create a project JPA/ EJBusing gradleand receiving this warning:

$ gradle jar
:compileJava
Note: Creating static metadata factory ...
Note: The persistence xml file [META-INF/persistence.xml] was not found. NO GENERATION will occur!! Please ensure a persistence xml file is available either from the CLASS_OUTPUT directory [META-INF/persistence.xml] or using the eclipselink.persistencexml property to specify its location. 
2 warnings
:processResources UP-TO-DATE
:classes
:jar

My project structure:

   ProjectX
   |-src
   |---main
   |-----java
   |-------domain
   |-------ejb
   |-----resources
   |-------META-INF
   |-----------persistence.xml

The interesting part is that persistence.xml hits the target artifact:

$ jar -tf target/projectx.jar
META-INF/
META-INF/MANIFEST.MF
domain/
domain/Employee.class
ejb/
ejb/EmployeeEJB.class
META-INF/persistence.xml

Why is there a complaint [META-INF/persistence.xml], even if there is one?

Gradle file:

apply plugin: 'java'
project.buildDir = 'target'
sourceSets.all {
    output.resourcesDir = output.classesDir
}
jar{
    destinationDir=project.buildDir
}
repositories {
    mavenCentral()
}
dependencies {
    compile 'org.glassfish:javax.ejb:3.0.1','org.eclipse.persistence:javax.persistence:2.0.0'
}

I quickly checked with maven now and there is no such warning.

+4
source share
3 answers

Compilation required persistence.xml. One way to achieve this:

sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
compileJava.dependsOn(processResources)
+6
source

, @peter-niederwieser , . , , , .

, ,

sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
jar {
    duplicatesStrategy = 'exclude'
}

build.gradle.

+1

META-INF should be at the root of your classpath (/ src / main / java / META-INF)

0
source

All Articles