Updating to `1.9.20-Beta` , I'm hit with: ```w: Ko...
# gradle
m
Updating to
1.9.20-Beta
, I'm hit with:
Copy code
w: Kotlin Source Set 'jvmJavaCodegen' can't depend on 'commonTest' as they are from different Source Set Trees.
Please remove this dependency edge.
Is there somewhere I can learn about Source Set Trees? What constitutes a Tree?
t
I think the only publicly available documentation now is in this KDOC and we should have more information in what's new for final release
thank you color 1
m
commonMain
and
commonTest
are disjoint, interesting!
I was naively expecting
commonTest
to depend on
commonMain
to get the dependencies but we don't want to compile
commonMain
sources together with
commonTest
ones (since they are already compiled)
I guess a follow up question is that
javaCodegen
was created as a separate compilation. And looks like it's put in the
commonMain
tree by default? Can I create a compilation whose defaultSourceSet depends on
commonTest
instead? Not sure if that makes any sense... 😅
t
I am not an author of these changes 😅 Maybe @Anton Lakotka [JB] could answer your questions
thank you color 1
👍 1
m
I was actually re-reading https://youtrack.jetbrains.com/issue/KT-61007/Multiplatform-with-multiple-targets-of-the[…]ith-Consumable-configurations-must-have-unique-attributes he wrote not so long ago, I think the answer might be there, let me process that
a
What constitutes a Tree?
We will publish some documentation explaining that upon 1.9.20 release. Practically it is about Source Sets that compile together. for example commonMain, nativeMain linuxX64Main and etc expect to compile together. And "Main" suffix is that Source Set Tree. there are by default two Source Set Trees: main and test. As you noticed already test and main should be disjoint. Yet test still depends on main, but not via KotlinSourceSet.dependsOn mechanism but as regular dependency. It is done through
KotlinCompilation.associateWith(KotlinCompilation)
So if you want to see declarations from javaCodegen in main and test source sets. Then you need to use associateWith API. Maybe you can drop branch with your changes and where you need to fix this. Then I'll try to help you.
thank you color 1
👍 2
m
Thanks! Let me clean my code and see if I can formulate a good question from it!
I managed to make it work in a small project (larger project is around here if y ou want to take a look but heads up it's a bit messy). All in all, I think what I'm trying to do is to do something like
expect/actual
without actually having to write all the
expect/actual
. I have a lot of generated code in both Java and Kotlin. These are the same classes, same APIs, same behaviour, same everything, just the implementation language changes. I'd like write all my tests only once (in Kotlin) and run them twice, once with the Java generated code and another time with the Kotlin one. I've become quite convinced doing so without breaking IDE support is not possible (because there is no way to have both Java and Kotlin dependencies at the same time). All in all sounds like this is more a problem of missing a custom commonizer or something like so, not 100% sure. In all cases, I'm quite confident I can get rid of the warning now. I'll post the link to the commit when I get to it
Alright, I think I got it for good this time 🙂 https://github.com/apollographql/apollo-kotlin/pull/5232/commits/1731807f5413276606788b0b0bba832ff453f565 The thing I was missing is that compilation create separate source set trees (or is it more source set graphs ? Because there can be diamonds in the graph ?)
Thanks for the help thank you color !