title: IntelliJ Idea 2019.2 gradle jar missing IntelliJ GUI form data
body: <p>I'm developing a Java Swing application built on Gradle and I'm also using the IntelliJ GUI Form built-in Swing designer. I've decided to test if the executable jar created by Gradle works properly and the built application doesn't see the Swing components created by IntelliJ designer.</p>
  
  <p>I've tried suggestions from: <a href="https://stackoverflow.com/questions/24185378/intellij-idea-13-ui-designer-and-automatic-gradle-building">Intellij Idea 13 UI Designer and automatic Gradle building</a> , but the jar still doesn't see those Swing components. I'm using IntelliJ Idea 2019.2. I've copied the 'forms_rt.jar' from my IntelliJ lib folder and linked it in the build.gradle file.
  I've also set IntelliJ GUI generation to Java code instead of binary code in the settings.</p>
  
  <p>I created a 'lib' directory in my project and copied the 'forms_rt' jar there and renamed it to 'forms_rt-13.1.1.jar'. (I didn't change the version number for testing sake, although it should be 19.2 I think)</p>
  
  <pre><code>repositories {
      mavenCentral()
      flatDir dirs: "${rootDir}/lib"
  }
  
  jar {
      manifest {
          attributes 'Main-Class': 'aghwen.Main'
      }
  }
  
  dependencies {
      compile name: 'forms_rt', version: '13.1.1'
      testCompile group: 'junit', name: 'junit', version: '4.12'
      compile group: 'org.json', name: 'json', version: '20180813'
      compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1'
  }
  
  </code></pre>
  
  <p>I also added the jar to dependencies so it can properly link.
  In IntelliJ settings in <code>Build, Execution, Deployment -&gt; Build tools -&gt; Gradle</code> "Build and run using" and "Run tests using" are set to IntelliJ IDEA otherwise Java code would not be generated, but binary instead.</p>
  
  <p>After testing every suggestion I've found on Stack and JetBrains forum I still can't make it run properly.</p>
  
  <pre><code>"C:\Program Files\Java\jdk1.8.0_211\bin\java.exe" -Dfile.encoding=windows-1252 -jar C:\Projects\Java\aghwen\build\libs\aghwen-5.0.jar
  Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/intellij/uiDesigner/core/GridLayoutManager
      at aghwen.ChoiceWindowForm.$$$setupUI$$$(ChoiceWindowForm.java:57)
      at aghwen.ChoiceWindowForm.&lt;init&gt;(ChoiceWindowForm.java:45)
      at aghwen.Main.lambda$main$0(Main.java:8)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
      at java.awt.EventQueue.access$500(EventQueue.java:97)
      at java.awt.EventQueue$3.run(EventQueue.java:709)
      at java.awt.EventQueue$3.run(EventQueue.java:703)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
  Caused by: java.lang.ClassNotFoundException: com.intellij.uiDesigner.core.GridLayoutManager
      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)
      ... 17 more
  </code></pre>
  
  <p>The jar doesn't have or doesn't see the generated Swing GUI and throws errors. What is interesting, if I remove the 'flatDir dirs: "${rootDir}/lib"' and 'compile name: 'forms_rt', version: '13.1.1' lines from build.gradle the jar won't be created as Gradle doesn't see the GUI components. That means Gradle knows about the forms library understands it, but it somehow doesn't link it in the jar created.</p>
  
  <h1><strong>Answered:</strong></h1>
  
  <p>I've found the answer here: <a href="https://stackoverflow.com/questions/30791016/intellij-build-jar-artifact-containing-gradle-dependencies">intellij build jar artifact containing gradle dependencies</a>
  Looks like my jar didn't include the forms_rt.jar needed to run created Swing components and the 'fatJar' task copied from above link made it all work fine.</p>