Hi! I'm using the venerable jengelman.shadow plug...
# gradle
t
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
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
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
That's weird, I would expect that to work... Invalidate and restart maybe ? 🤷
t
I've already tried that...
t
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
*.kotlin_modules
are only for things like top-level declarations right? Regular classes shouldn't need those.
t
not only -
internal
visibility is also in those
Here is the actual content of these file
t
@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
They are most likely required for top level functions and extension functions
At least the module file for you public API
t
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
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
no idea, they should be picked up by IDEA and it is working for Kotlin Gradle plugin
m
@Tianyu Zhu want to share your fatjar here? I can try to load it in my intelliJ
t
Uh... it's for work, so I can't share it 😕
m
No problem!