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

**URL:** <https://discuss.gradle.org/t/copying-files-from-meta-inf-to-jar-using-gradle-jar-plugin/11253>\
**Category:** Help/Discuss\
**Tags:** plugins\
**Created:** [August 19, 2015, 11:04pm UTC](https://discuss.gradle.org/t/copying-files-from-meta-inf-to-jar-using-gradle-jar-plugin/11253 "2015-08-19T23:04:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandeeprao](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sandeeprao](https://discuss.gradle.org/u/sandeeprao)\
**Post date:** [August 19, 2015, 11:04pm UTC](https://discuss.gradle.org/t/copying-files-from-meta-inf-to-jar-using-gradle-jar-plugin/11253/1 "2015-08-19T23:04:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Shinya\_Mochida](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/shinya_mochida/32/2393_2.png) [@Shinya\_Mochida](https://discuss.gradle.org/u/Shinya_Mochida)\
**Post date:** [August 20, 2015, 1:34am UTC](https://discuss.gradle.org/t/copying-files-from-meta-inf-to-jar-using-gradle-jar-plugin/11253/2 "2015-08-20T01:34:29Z")

</div>

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

```groovy
sourceSets {
    main {
        java {
            srcDir 'src/java'
        }
        resources {
            srcDir 'src'
            exclude 'src/java/**/*'
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![sandeeprao](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sandeeprao](https://discuss.gradle.org/u/sandeeprao)\
**Post date:** [August 20, 2015, 2:10pm UTC](https://discuss.gradle.org/t/copying-files-from-meta-inf-to-jar-using-gradle-jar-plugin/11253/3 "2015-08-20T14:10:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Shinya\_Mochida](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/shinya_mochida/32/2393_2.png) [@Shinya\_Mochida](https://discuss.gradle.org/u/Shinya_Mochida)\
**Post date:** [August 20, 2015, 2:13pm UTC](https://discuss.gradle.org/t/copying-files-from-meta-inf-to-jar-using-gradle-jar-plugin/11253/4 "2015-08-20T14:13:21Z")

</div>

I think it is the best way 😃.
