Mark Elston (131) [Avatar] Offline
I'm up to chapter 6 and have used the IntelliJ editor for much of the work following along with the code. However, the project structure created by this editor for Kotlin projects is flat. No source directories, no test directories, no Gradle build file, etc.

Is there a common project structure used in Kotlin projects? I think a section discussing Kotlin and Gradle would be helpful especially since Android Studio uses Gradle and it is a natural extension to use it in other projects as well.

I struggled a lot trying to get a Kotlin/Gradle working in IDEA 2016.1 and would have appreciated some pointers to get this working. Even a simple step-by-step recipe would have helped. I am not all that familiar with Gradle so I spent a lot of time googling for anything I could find.

One thing I ran into was that I was trying to use the latest Gradle (2.12) and, following an example I found on JetBrain's website, I had the build.gradle file specify 1.0.0 for the kotlin_version property. This failed spectacularly as, apparently, the plugin for 1.0.0 is completely incompatible with Gradle 2.12. I couldn't find that specified anywhere, though. I finally ran across a statement that implied it in the 1.0.1 release notes.

If Kotlin is expected to be used mainly on Android projects then it may not be so important to go into a lot of detail regarding a general project structure since Android Studio seems to take care of a lot of it. However, if Kotlin is to be a general purpose language (and I think it is) then providing some pointers (or best practices) regarding project setup is going to be necessary.
Dmitry Jemerov (40) [Avatar] Offline
The kind of issue that you ran into (an incompatibility with a specific version of Gradle) is very difficult to cover in a book, because such problems can arise at any time and are resolved fairly quickly. (In this particular case, IntelliJ IDEA 2016.1.1 will include Kotlin 1.0.1, which will work with Gradle out of the box.)

Also, in many cases a video screencast can work much better as an introduction to project creation than text in a book.

For these reasons, we plan to provide detailed information on project setup in online materials, and not in the book. There's already and and it's very likely that the set of materials will be expanded.
Mark Elston (131) [Avatar] Offline
Thanks. I read both of those links prior to posting this and neither one really answered my questions. I eventually found the kotlin-examples on github and took those as a basis for the build.gradle.

I'm surprised that IDEA seems to make it so hard to create a Gradle-based Kotlin project, though. At least I haven't found the right way to do it from the IDE yet. I had to create a Gradle project by hand, including creating the build.gradle file and the first Kotlin source file in its src/main/kotlin/... directory and then importing it into the IDE before I could get it to work. If there is another way to do this from the IDE I would love to see it. I am looking forward to the screencast being made available.
Dmitry Jemerov (40) [Avatar] Offline
File | New | Project, select "Gradle" option in the left list box, check "Kotlin (Java)" in the "Additional Libraries and Frameworks" list.
Mark Elston (131) [Avatar] Offline
I tried that but it never actually got to where it would build any Kotlin files. I got errors every time. I had to do an import of a hand-built project before it would work.