https://kotlinlang.org logo
#getting-started
Title
# getting-started
j

Joakim Tengstrand

06/22/2020, 10:26 AM
Hi! I'm new to Kotlin. Does Kotlin support having more than one src folder?
r

Ryan

06/22/2020, 10:30 AM
yes
but thats more your build system
j

Joakim Tengstrand

06/22/2020, 10:32 AM
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

Ryan

06/22/2020, 10:38 AM
Copy code
sourceSets["main"].java.srcDir("$generatedJavaSourcesPath/kapt/main")
👍 1
i’m using kotlin gradle dsl
j

Joakim Tengstrand

06/22/2020, 10:38 AM
Thanks
Can you please guide me to a good example project that uses gradle dsl?
r

Ryan

06/22/2020, 10:58 AM
you can download gradle quickstart and create a new kotlin project.
j

Joakim Tengstrand

06/22/2020, 10:58 AM
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

Ryan

06/22/2020, 11:18 AM
j

Joakim Tengstrand

06/22/2020, 11:19 AM
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

Joakim Tengstrand

06/22/2020, 11:21 AM
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).
3 Views