title: How to configure Gradle to built Java EE project
body: <p>I try to setup a Java EE environment to be built with gradle. In the end I want to have an EAR file containing an EJB-Jar and some kind of application client that can be deployed to Glassfish (probably). The setup will be quite basic.</p>
  
  <p>Currently I am facing two problems:</p>
  
  <p>1) Running the 'ear' task to assemble the EAR archive creates a faulty application.xml file in tmp/ear that looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;application xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6"&gt;
    &lt;display-name&gt;DataViewerEAR&lt;/display-name&gt;
    &lt;library-directory&gt;lib&lt;/library-directory&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>The error message eclipse reports is:</p>
  
  <blockquote>
    <p>cvc-complex-type.2.4.a: Invalid content was found starting with
    element 'library-directory'. One of
    '{"<a href="http://java.sun.com/xml/ns/javaee" rel="nofollow">http://java.sun.com/xml/ns/javaee</a>":display-name,
    "<a href="http://java.sun.com/xml/ns/javaee" rel="nofollow">http://java.sun.com/xml/ns/javaee</a>":icon,
    "<a href="http://java.sun.com/xml/ns/javaee" rel="nofollow">http://java.sun.com/xml/ns/javaee</a>":initialize-in-order,
    "<a href="http://java.sun.com/xml/ns/javaee" rel="nofollow">http://java.sun.com/xml/ns/javaee</a>":module}' is expected.</p>
  </blockquote>
  
  <p>The deployment descriptor file I created with the help of eclipse in earContent/META-INF seems to be ignored:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" version="7"&gt;
    &lt;display-name&gt;DataViewerEAR&lt;/display-name&gt;
    &lt;module&gt;
      &lt;ejb&gt;DataViewerEJB.jar&lt;/ejb&gt;
    &lt;/module&gt;
    &lt;module&gt;
      &lt;java&gt;DataViewerTestClient.jar&lt;/java&gt;
    &lt;/module&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>The content of the asssembled EAR file looks ok.</p>
  
  <p>2) The resulting jar of the EJB build is empty. I think the main problem is that the EJB project's structure does not match the assumed src/main/java etc. and I don't know how to change this. My current build.gradle file for the EJB project looks like this:</p>
  
  <pre><code>apply plugin: 'java'
  
  repositories {
      jcenter()
  }
  
  dependencies {
          compile 'ch.qos.logback:logback-classic:1.1.5'
          testCompile 'junit:junit:4.12'
  }
  </code></pre>
  
  <p>It would also be great If someone could tell me what things you have to pay attention to when configuring the application. Deployment descriptors and other .xml files. Not to forget anything...</p>