Gradle uses deploymentDescriptor instead of application.xml in directory specified by [appDirName]/META-INF

I have an ear task that sets appDirName to ‘app’, a directory in the project directory that contains (among other things) META-INF/application.xml. Even with this set, the application.xml file that Gradle includes in the generated ear is not the one in the META-INF directory. How can I make it use mine?

If for some reason that is impossible, how can I use withXml to remove the unneeded tag (library-directory) from the output application.xml? Everything I have tried from reading different forum posts gives me a null return when trying to find that tag, but if I print out the XML as a string inside the withXml hook, it has the library-directory tag in it.