Copying Files from META-INF to jar using gradle jar plugin

I have a META-INF folder where the persitence.xml and orm.xml are located. When I build a jar file with following gradle those files are not getting included in the jar. How can i copy those files to the jar ?

Project structure

src
| - main(java/classes)

  • MET-INF(peristenc.xml, orm.xml)

Jar file code

jar {
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
{
exclude “license/*.txt”
}
}
Any help would be great

Tell gradle where your resources files are via sourceSets{} block.

sourceSets {
    main {
        java {
            srcDir 'src/java'
        }
        resources {
            srcDir 'src'
            exclude 'src/java/**/*'
        }
    }
}
1 Like

Thanks, Instead of defining it in source sets I moved my meta-inf folder to the resources directory.

I think it is the best way :smiley:.