https://kotlinlang.org logo
Title
t

Tianyu Zhu

08/01/2022, 11:23 PM
Hi! I'm using the venerable jengelman.shadow plugin to create a fat jar containing a bunch of kotlin code I wrote. When I use this fat jar as a dependency in subsequent kotlin projects the code compiles fine but IntelliJ doesn't recognize any of the kotlin code in the fat jar! 1. Is this related the fact that my fat jar does not merge the
META-INF/*.kotlin_module
files together? 2. If so, is there a gradle plugin that will help me with that? 3. Otherwise, why doesn't IntelliJ understand kotlin code that's been put into fat jars?
m

mbonnin

08/01/2022, 11:27 PM
IntelliJ doesn't recognize any of the kotlin code in the fat jar!
What do you mean by that? Call sites that call into your fat jar are underlined in red? Or something else? I would expect the callsites to work as usual because typically, the public API of your fat jar isn't relocated
t

Tianyu Zhu

08/01/2022, 11:29 PM
Yes. The Call sites that call into my fat jar are all underlined in red. In fact, IntelliJ doesn't even know the packages in my fat jar exist!
m

mbonnin

08/01/2022, 11:29 PM
That's weird, I would expect that to work... Invalidate and restart maybe ? 🤷
t

Tianyu Zhu

08/01/2022, 11:30 PM
I've already tried that...
t

tapchicoma

08/02/2022, 9:18 AM
Is this related the fact that my fat jar does not merge the META-INF/*.kotlin_module files together?
That could be the case that some
*.kotlin_module
files are missing. Though they don't need to be merged/
m

mbonnin

08/02/2022, 9:21 AM
*.kotlin_modules
are only for things like top-level declarations right? Regular classes shouldn't need those.
t

tapchicoma

08/02/2022, 9:22 AM
not only -
internal
visibility is also in those
Here is the actual content of these file
t

Tianyu Zhu

08/02/2022, 12:05 PM
@tapchicoma Thank you for replying! If I understand correctly: • The
*.kotlin_module
files are not necessary for IntelliJ to work correctly, and • The
*.kotlin_module
files do not need to be merged to be effective
m

mbonnin

08/02/2022, 12:07 PM
They are most likely required for top level functions and extension functions
At least the module file for you public API
t

tapchicoma

08/02/2022, 12:08 PM
The *.kotlin_module files are not necessary for IntelliJ to work correctly, and
They are required for Kotlin compilation
The *.kotlin_module files do not need to be merged to be effective
They are files in protobuf format. I doubt Shadow could merge them correctly
t

Tianyu Zhu

08/02/2022, 12:12 PM
I see... Right now Shadow simply dumps them all into
META-INF/
. I guess this is fine since the
*.kotlin_module
files are helping my code compile correctly. But for some reason IntelliJ is still not picking up the classes in the fat jar... Do you have an idea of why?
t

tapchicoma

08/02/2022, 12:14 PM
no idea, they should be picked up by IDEA and it is working for Kotlin Gradle plugin
m

mbonnin

08/02/2022, 12:16 PM
@Tianyu Zhu want to share your fatjar here? I can try to load it in my intelliJ
t

Tianyu Zhu

08/02/2022, 12:23 PM
Uh... it's for work, so I can't share it 😕
m

mbonnin

08/02/2022, 12:35 PM
No problem!