Hi! I'm new to Kotlin. Does Kotlin support having ...
# getting-started
j
Hi! I'm new to Kotlin. Does Kotlin support having more than one src folder?
r
yes
but thats more your build system
j
I come from Clojure and in Clojure, multiple src folders are supported both in the build tooling and in the IDE. Is there any IDE support for multiple src folders in Kotlin?
r
Copy code
sourceSets["main"].java.srcDir("$generatedJavaSourcesPath/kapt/main")
👍 1
i’m using kotlin gradle dsl
j
Thanks
Can you please guide me to a good example project that uses gradle dsl?
r
you can download gradle quickstart and create a new kotlin project.
j
But it is huge.
Ok, will try that.
I can create a simple app from IDEA that creates a .iml project file (https://kotlinlang.org/docs/tutorials/jvm-get-started.html) but I haven't figured out how to create a corresponding gradle dsl build file.
r
j
Thanks! Now it will be easier to dig in.
i guess it can be confusing using the gradle kotlin dsl to build a kotlin project lol
j
I expected to find something like "Create Gradle DSL project" in IDEA.
I installed gradle + pointed out its root in the settings. I also created the file build.gradle.kts at the project root that looks like this. When I enter the module settings I can see that IDEA doesn't understand where my src folders live, and therefore I can't execute a main function under on of the two src-folders:
Copy code
plugins {
    kotlin("jvm") version "1.3.72"
}

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath(kotlin("gradle-plugin", version = "1.3.72"))
    }
}

sourceSets.main {
    java.srcDirs("components/logger/src",
                 "components/user/src")
}
I get the error 'gradle-wrapper.properties' not found.
After executing "gradle wrapper" I don't have that error message, but I can still not execute my function (which worked when I had my src folder on the root).