title: How can I add local resources using Gradle Kotlin-DSL
body: <p>I'm trying to test gradle 5 using kotlin DSL.</p>
  
  <p>I created a lib, and built it as below:</p>
  
  <pre><code>Hasans-Air:blogiclib h_ajsf$ gradle init --type=kotlin-library
  
  Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details
  
  Select build script DSL:
  
  1: groovy
  
  2: kotlin
  
  Enter selection (default: kotlin) [1..2] 2
  
  Project name (default: blogiclib): 
  
  Source package (default: blogiclib): 
  
  **BUILD SUCCESSFUL** in 16s
  
  2 actionable tasks: 2 executed
  
  Hasans-Air:blogiclib h_ajsf$ ls
  
  build.gradle.kts gradlew settings.gradle.kts
  
  gradle gradlew.bat src
  
  Hasans-Air:blogiclib h_ajsf$ code .
  
  Hasans-Air:blogiclib h_ajsf$ gradle build
  </code></pre>
  
  <p>Then I got the output file generated as: <code>build\libs\blogiclib.jar</code></p>
  
  <p>The <code>Library.kt</code> file generated is:</p>
  
  <pre><code>package blogiclib
  
  class Library {
      fun someLibraryMethod(): Boolean {
          return true
      }
  }
  </code></pre>
  
  <p>And the <code>build.gradle.kts</code> generated is:</p>
  
  <pre><code>plugins {
      id("org.jetbrains.kotlin.jvm").version("1.3.10")
  }
  
  repositories {
      jcenter()
  }
  
  dependencies {
      implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
      testImplementation("org.jetbrains.kotlin:kotlin-test")
      testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
  }
  </code></pre>
  
  <p>Then I generated a kotlin app and tested it as below:</p>
  
  <pre><code>Hasans-Air:gradle h_ajsf$ gradle init --type=kotlin-application
  
  Starting a Gradle Daemon (subsequent builds will be faster)
  
  Select build script DSL:
  
  1: groovy
  
  2: kotlin
  
  Enter selection (default: kotlin) [1..2] 2
  
  Project name (default: gradle): blogic
  
  Source package (default: blogic): 
  
  **BUILD SUCCESSFUL** in 25s
  
  2 actionable tasks: 2 executed
  
  Hasans-Air:gradle h_ajsf$ ls
  
  build.gradle.kts gradlew settings.gradle.kts
  
  gradle gradlew.bat src
  
  Hasans-Air:gradle h_ajsf$ code .
  
  Hasans-Air:gradle h_ajsf$ gradle run
  **BUILD SUCCESSFUL** in 6m 4s
  
  3 actionable tasks: 3 executed
  
  Hasans-Air:gradle h_ajsf$ gradle run
  
  **&amp;gt; Task :run**
  
  Hello world.
  </code></pre>
  
  <p>Then I added the previously generated lib <code>blogiclib.jar</code> to the folder: <code>main\resources</code></p>
  
  <p>And made my <code>App.kt</code> file as:</p>
  
  <pre><code>package blogic
  
  import blogiclib.LibraryKt
  
  class App {
      val greeting: String
          get() {
              return "Hello world."
          }
  }
  
  fun main(args: Array&lt;String&gt;) {
      println("${App().greeting} = someLibraryMethod()")
  }
  </code></pre>
  
  <p>And its <code>build.gradle.kts</code> based on my understanding from <a href="https://docs.gradle.org/current/userguide/working_with_files.html" rel="noreferrer">here</a> as:</p>
  
  <pre><code>plugins {
      id("org.jetbrains.kotlin.jvm").version("1.3.10")
      application
  }
  
  repositories {
      jcenter()
  }
  
  dependencies {
      implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
      testImplementation("org.jetbrains.kotlin:kotlin-test")
      testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
  
  }
  
  application {
      mainClassName = "blogic.AppKt"
  }
  
  task&lt;JavaCompile&gt;("compile") {
      source = fileTree(file("src/main/resources/blogiclib.jar"))
  }
  </code></pre>
  
  <p>But at compiling I got the below error:</p>
  
  <blockquote>
  <pre><code>Hasans-Air:gradle h_ajsf$ gradle run
  
  e: /Users/h_ajsf/Documents/gradle/src/main/kotlin/blogic/App.kt: (6, 8): Unresolved reference: blogiclib
  
  **&amp;gt; Task :compileKotlin** FAILED
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  
  Execution failed for task ':compileKotlin'.
  
  &amp;gt; Compilation error. See log for more details
  
  * Try:
  
  Run with **--stacktrace** option to get the stack trace. Run with **--info** or **--debug** option to get more log output. Run with **--scan** to get full insights.
  
  * Get more help at **https://help.gradle.org**
  
  Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
  
  Use '--warning-mode all' to show the individual deprecation warnings.
  
  See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings
  
  **BUILD FAILED** in 1s
  
  2 actionable tasks: 2 executed
  </code></pre>
  </blockquote>
  
  <p><strong>UPDATE</strong></p>
  
  <p>In reference to the comments received, I did the below:</p>
  
  <ol>
  <li>Moved the library file to folder <code>src/main/libs</code>: </li>
  <li><p>Added the below code to the <code>build.gradle.kts</code>:</p>
  
  <p>configurations {
      create("externalLibs")
  }</p>
  
  <p>dependencies {
      "externalLibs"(files("src/main/libs/blogiclib.jar"))
  }</p></li>
  </ol>
  
  <p>instead of:</p>
  
  <pre><code>task&lt;JavaCompile&gt;("compile") {
      source = fileTree(file("src/main/resources/blogiclib.jar"))
  }
  </code></pre>
  
  <p>but still getting the same error :(</p>