title: ClassNotFoundException when running main class in Intellij gradle project
body: <p>When I try to run <code>main</code> method in my gradle project using run configuration from IDEA Intellij option I'm getting exception as follows:</p>
  
  <pre class="lang-java prettyprint-override"><code>15:12:03: Executing external task 'run'...
  :compileJava UP-TO-DATE
  :processResources UP-TO-DATE
  :classes UP-TO-DATE
  Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/GsonBuilder
      at pl.edu.agh.flowshop.utils.ConfigReader.getMachinesConfig(ConfigReader.java:46)
      at pl.edu.agh.flowshop.utils.ConfigReader.createModel(ConfigReader.java:30)
      at pl.edu.agh.flowshop.Experiment.main(Experiment.java:25)
  Caused by: java.lang.ClassNotFoundException: com.google.gson.GsonBuilder
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      ... 3 more
  </code></pre>
  
  <p>It bothers me because if I just create runnable jar from same configuration everything works fine. I've tried refrehing gradle project as well as 'Invalidate Caches/Restart' option but none of them helped.</p>
  
  <p>My build.gradle file: </p>
  
  
  
  <pre><code>group 'pl.edu.agh'
  version '1.0-SNAPSHOT'
  
  apply plugin: 'java'
  apply plugin: 'application'
  
  sourceCompatibility = 1.7
  [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
  sourceSets.main.java.srcDirs = ['src/main/java']
  mainClassName = 'pl.edu.agh.flowshop.Experiment'
  
  repositories {
      mavenCentral()
      flatDir {
          dirs 'libs'
      }
  }
  
  dependencies {
      testCompile group: 'junit', name: 'junit', version: '4.11'
      compile group: 'nz.ac.waikato.cms.weka', name: 'weka-stable', version: '3.6.6'
      compile group: 'commons-io', name: 'commons-io', version: '2.4'
      compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
      compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6'
      compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5'
      compile group: 'com.google.guava', name: 'guava', version: '19.0'
      compile group: 'com.google.code.gson', name: 'gson', version: '2.6.2'
      compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5'
      compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5'
      compile name:'piqle'
  }
  
  jar {
      manifest {
          attributes(
                  'Implementation-Title': project.name,
                  'Implementation-Version': version,
                  'Built-By': System.getProperty('user.name'),
                  'Built-Date': new Date(),
                  'Built-JDK': System.getProperty('java.version'),
                  "Main-Class": mainClassName
          )
      }
      from {
          configurations.compile.collect {
              it.isDirectory() ? it : zipTree(it)
          }
      }
  }
  </code></pre>