title: Unable to read file from src/main/resources after gradle distTar in Kotlin
body: <p>I have a file called <code>user.json</code> in <code>src/main/resources</code> folder.
  <a href="https://i.stack.imgur.com/uYNno.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uYNno.png" alt="enter image description here"></a></p>
  
  <p>After I package my application into a jar file with gradle executing the command</p>
  
  <pre><code>gradle distTar
  </code></pre>
  
  <p>I am unable to open the file and getting an Exception like this</p>
  
  <pre><code>Caused by: java.io.FileNotFoundException: file:/app/api-latest/lib/api-latest.jar!/user.json (No such file or directory)
  </code></pre>
  
  <p>I tried to access to file in 3 ways now all resulting in a FileNotFoundException:</p>
  
  <p>1:</p>
  
  <pre><code>fun readFileFromResources(filename : String) : File {
      return File(filename)
  }
  </code></pre>
  
  <p>2:</p>
  
  <pre><code>fun readFileFromResources(filename : String) : File {
      val classLoader = Util::class.java.classLoader
      return File(classLoader.getResource(filename).file)
  }
  </code></pre>
  
  <p>3:</p>
  
  <pre><code>fun readFileFromResources(filename : String) : File {
      return File("src/main/resources", filename)
  }
  </code></pre>
  
  <p>I have unpackaged the generated .jar and see the user.json file is indeed in the root of the package. </p>
  
  <p>Does anybody know the reason why this does not work?
  I am using gradle 4.5.1 and Kotlin 1.2.30</p>
  
  <p>My build.gradle looks like this</p>
  
  <pre><code>group 'example'
  version 'latest'
  
  buildscript {
      ext {
          kotlin_version = '1.2.30'
          ktor_version = '0.9.0'
          logback_version =  '1.2.1'
          gson_version = '2.8.2'
          junit_version = '4.12'
          hibernate_version = '5.2.12.Final'
          hibernate_validator_version = '6.0.7.Final'
          mysql_connector_version = '6.0.4'
          h2_version = '1.4.196'
          kodein_version = '4.1.0'
          jedis_version = '2.9.0'
          mockito_version = '2.+'
          jaxb_version = '2.3.0'
      }
  
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
          classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version"
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'kotlin'
  apply plugin: 'application'
  apply plugin: 'kotlin-jpa'
  
  mainClassName = 'io.ktor.server.netty.DevelopmentEngine'
  
  sourceCompatibility = 1.8
  
  repositories {
      mavenCentral()
      jcenter()
      maven { url  "http://dl.bintray.com/kotlin/ktor" }
      maven { url "https://dl.bintray.com/kotlin/kotlinx" }
  }
  
  dependencies {
      compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
      compile "io.ktor:ktor:$ktor_version"
      compile "ch.qos.logback:logback-classic:$logback_version"
      compile "io.ktor:ktor-server-netty:$ktor_version"
      compile group: 'com.google.code.gson', name: 'gson', version: "$gson_version"
      compile group: 'org.hibernate', name: 'hibernate-core', version: "$hibernate_version"
      compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: "$hibernate_validator_version"
      compile group: 'mysql', name: 'mysql-connector-java', version: "$mysql_connector_version"
      compile group: 'org.hibernate', name: 'hibernate-c3p0', version: "$hibernate_version"
      compile group: 'com.github.salomonbrys.kodein', name: 'kodein', version: "$kodein_version"
      compile group: 'redis.clients', name: 'jedis', version: "$jedis_version"
      testCompile group: 'junit', name: 'junit', version: "$junit_version"
      testCompile group: 'io.ktor', name: 'ktor-server-test-host', version: "$ktor_version"
      testCompile group: 'com.h2database', name: 'h2', version: "$h2_version"
      testCompile "org.mockito:mockito-core:$mockito_version"
  }
  
  kotlin {
      experimental {
          coroutines "enable"
      }
  }
  
  compileKotlin {
      kotlinOptions.jvmTarget = "1.8"
  }
  compileTestKotlin {
      kotlinOptions.jvmTarget = "1.8"
  }
  </code></pre>