Ear build with specific appDirName path

Hello, I have some problems with the ear plugin, especially the ear task. The project directory contains only the application source directory META-INF with the application descriptor application.xml. I have tried to set appDirName to the application source directory. This result in an infinite loop. The project folder looks like this:

–projectDir: ----META-INF ------application.xml

and my ear task looks like this:

ear {

excludes = [’…’]

appDirName ‘.’ }

I have also tried to set appDirName to ‘/’ and project.projectDir. My gradle version is 1.11 (Java 1.7u51)

Hello Nikolay, you should be able to point the ear task to this existing application.xml. try:

ear {
    deploymentDescriptor {

cheers, René

Hi Nikolay/Rene,

I have a question in creating ear file. I have a requirement to add the war file under ear file and few other folder/files along with it. I verified few articles, posting and Gradle guide which says to add the below command under dependencies

deploy project(path: ‘:war’, configuration: ‘archives’)

But when I try this then I am getting an exception. Could you please guide me on how to add war file under ear.

Thanks Pavan

This is a great conversation that’s separate from the main topic, so I created a new topic to continue the discussion. Please reference the new topic here: question about adding war archive to ear archive

Hi Rene,

it doesn’t work. If I move the META-INF folder into a new created path “src/main/application”, then gradle creates my ear zip with the “origin” application.xml (the file under src/main/application/META-INF/). But if I take your suggestion, then gradle creates a new application.xml and ignores the other one. In addition all other files in the META-INF directory are also ignored and they arent copy into the ear zip?

Thanks Nikolay

so have you moved your META-INF into src/main/application?

Another approach might be to copy the META-INF folder in projectDir/META-INF directly into your ear:


cheers, rené

Hi Rene,

the new approach works. I have moved the META-INF into src/main/application to test whether gradle creates my ear zip properly. Here’s my solution:

ear {
   into("META-INF") {
     from("META-INF") {
        exclude 'application.xml'
1 Like