Project generates incorrect IntelliJ source roots for Kotlin modules
See original GitHub issueAfter running buck project
on a project that has kotlin (a project with rules such as kotlin_library
, android_library
with language set to Kotlin, etc), the source roots of those modules are not made correctly in IntelliJ.
Here are a couple examples:
Note how the app
directory is marked as the source root instead of src/main/java
which is where the packages actually begin.
And here, the kotlin-android
module is the source root instead of src/main/java
Both of these examples could be src/main/kotlin
depending on your naming conventions and/or use of mixed sources.
This causes the IDE to behave incorrectly when refactoring, importing those classes, and even when defining the package of that module.
If any of these modules are turned into pure java modules, they look correct:
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:8 (6 by maintainers)
Top GitHub Comments
Alternatively, one can apply this patch to buck to have
buck project
respect source roots correctly without having to post process. Its a similar approach, but happens inside the project command itselfhttps://gist.github.com/kageiit/4e48964cb6d9382737b96c21e1adf730
For those looking for a quick fix, I’ve written up a python script that post-processes .iml files after
buck project
has generated them, and touches up the folder definitions to correct them. We use this internally at Square and it seems to cover all the use cases we have for misconfigured modules.If you’re using okbuck, append this to your buck wrapper after running BUCK_BINARY to invoke the script automatically: