rwallace
rwallace

Reputation: 33365

Gradle and IDEA disagree on where Kotlin source files should go

By default, IntelliJ IDEA puts Kotlin source files for package foo in src/*.kt but Gradle isn't happy with that; it can only see them if they go in src/main/kotlin/foo/*.kt.

I've tried moving them there, but now IDEA gives a warning in my source files, in the package foo line, saying 'package directive doesn't match file location' and wanting to change the package to main.kotlin.foo (which of course would be incorrect, and probably confuse Gradle again).

How do you get the two to agree on where the files should go? (Ideally I would like it to be somewhere that doesn't have any levels of empty subdirectories, but I will settle for anything the two programs can agree on.)

Upvotes: 0

Views: 43

Answers (1)

rwallace
rwallace

Reputation: 33365

It turns out that if you just delete the IDEA configuration, IDEA will automatically rebuild it from the Gradle project, and thereby become happy with the Gradle default layout.

Upvotes: 1

Related Questions