AppDirName not working for type Ear

Hello I have some problems with the ear plugin. In one project I generate 2 different Ears which a defined that way:

import org.gradle.plugins.ear.*
task earApplication(type: Ear, dependsOn: createEjb)
  earApplication {
   appDirName 'Implementation/resources/application'
   baseName += '-app'

This leads to the following exception: [Fatal Error] :1:1: Content is not allowed in prolog.

Deactivating the appDirName works fine.

Thanks, Heiko

It’s probably due to the implementation of the EarPluginConvention.setAppDirName method:

public void setAppDirName(String appDirName) {
 this.appDirName = appDirName
 if (deploymentDescriptor) {
  deploymentDescriptor.readFrom new File(appDirName, "META-INF/" + deploymentDescriptor.fileName)

Above will always attempt to read a ‘META-INF/application.xml’ file from the specified ‘appDirName’ directory if it exists. Do you have such file under ‘Implementation/resources/application’? If so, probably it is not a valid XML file. Could you paste the full stack trace?

Hi Detelin You are right. I have an application.xml under

. Which produced this problem. Good hint. After that I understood also, that I can overwrite automatically generated entries in the deploymentDescriptor. This wasn’t clear to me.

Finally I removed the application.xml and added an webModule entry to the deploymentDescriptor. Thanks again for your help. Heiko