Kotlin Programming Cookbook
上QQ阅读APP看书,第一时间看更新

There's more...

The default structure of the project, when you create a new project in IntelliJ, is as illustrated:

project
- src
- main (root)
- kotlin
- java

If you want to have a different structure of the project, you should declare it in build.gradle. You can do it by adding the following lines in build.gradle.

The corresponding sourceSets property should be updated if not using the default convention:

sourceSets {
main.kotlin.srcDirs += 'src/main/myKotlin'
main.java.srcDirs += 'src/main/myJava'
}

Though you can keep Kotlin and Java files under the same package, it’s a good practice to keep them separated.