title: How do I create a 'fatjar' in multi module selenium automation project?
body: <p>I've been at this for days and have tried many things but I can't seem to figure this out. I'm converting a <strong>multi module project</strong> in intellij from maven to gradle and have a structure as follows:</p>
  
  <blockquote>
    <p>com.automation</p>
    
    <ul>
    <li><p>build.gradle</p></li>
    <li><p>api  </p>
    
    <ul>
    <li>src/main/Authorisation.java </li>
    <li>src/test/LoginAuth.java</li>
    <li>build.gradle</li>
    </ul></li>
    <li><p>pageobjects </p>
    
    <ul>
    <li>src/main/LoginPage_Method.java</li>
    <li>build.gradle</li>
    </ul></li>
    <li><p>testclasses </p>
    
    <ul>
    <li>src/test/LoginTests.java</li>
    <li>build.gradle</li>
    </ul></li>
    </ul>
  </blockquote>
  
  <pre><code>task fatJar(type: Jar) {
          archiveBaseName = project.jar_name
          zip64 = true
  
          manifest {
              attributes 'Main-Class': 'My Main Class'
          }
  
          from sourceSets.test.output
          from { configurations.testRuntime.collect { it.isDirectory() ? it : zipTree(it) } }
          with jar
      }
  </code></pre>
  
  <p>In my <code>com.automation &gt; build.gradle</code> file I'm trying to create a fatjar so when I run  <code>java -jar {nameofJar}.jar</code> the jar runs as it should.
  The problem I think is that when I create the jar file the dependencies are not getting created (I know this because when the jar is extracted I'm not seeing the classpath files) so when I try to run the jar file I get an exception:</p>
  
  <pre><code>Error: A JNI error has occurred, please check your installation and try again
  Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/runner/notification/RunListener
          at java.lang.Class.getDeclaredMethods0(Native Method)
          at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
          at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
          at java.lang.Class.getMethod0(Class.java:3018)
          at java.lang.Class.getMethod(Class.java:1784)
          at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
          at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
  Caused by: java.lang.ClassNotFoundException: org.junit.runner.notification.RunListener
          at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          ... 7 more
  </code></pre>
  
  <p>Any help to figure this out is much appreciated.</p>