Hi. Not sure if multiplatform channel is the right...
# multiplatform
r
Hi. Not sure if multiplatform channel is the right place and even not sure if that is possible. So, I am generating Kotlin response/request data classes used by Ktor. I'd like to keep them separate from common module. Created another module and included
api(project(":generatedapi"))
it as a dependency to common module. It compiles and builds successfully but when I publish the project as a library, those generated classes are not included so clients which are using multiplatform library cannot access them. Does anybody tried to achive something similar like this or maybe know a way how to expose dependency classes to clients? Thanks.
b
Either publish that module as well or add it as implementation
r
@Big Chungus when say 'add it as implementation' you mean dump generated classes into common module?
b
No, i mean replace api to implementation on that dependency snippet you've sent
r
Copy code
Cannot access class 'xx.yy.DataClass. Check your module classpath for missing or conflicting dependencies
b
Is that from the lib consumer?
r
Getting this error on client side on attempt to use a class
Yeah
b
In that case you need to make your lib fat-ish jar that includes that module explicitly
Here's an example
And here
👍🏻 1
Second example is better suited to you. First one is embedded kotlin js as webjar
r
Yeah, maybe the second example is something I am looking for. Will give a try. Ačiū
Not sure why but
jar
task is not found in my main multiplatform module. Instead used
jvmJar
and that worked fine. That works for Android, but I suppose I'd get the same issue for iOS. 🤔
b
You will. In this case why not just publish your internal module?
r
But client/consumer would need to include (specify in dependencies) both libraries, wouldn't it?
b
Nope
Gradle/maven would download that internal dependency as transitive
r
This is the thing. I published the other module too. Also, I can see that on client/consumer app's dependency tree, library is pulled as transitive dependency but still on client/consumer side I am getting error
Copy code
Cannot access class XXX Check your module classpath for missing or conflicting dependencies
b
Is your class public?
r
Yes, correct. It is public.
b
Then I'm out of ideas. Can't help you more without seeing the actual code :/
r
No worries. I'll try to make SSCCE (a Simple, Self-Contained, Correct (Compilable), Example) and publish it on github, for instance.
b
Tbh, I'm only interested in your gradlefiles and class signature. So if you could remove all your source code and publish that I could have a proper look
r
Made gist files first. Let me know if you more context.
b
Can you make a proper git repo replicating your project structure? Will have a look at that first thing tomorrow
r
Yeah, sure. No problem. Will post a link here.
b
Hold on. I see you now have everything as implementation. Can you try changing all dependencies to api and see if that works?
r
Yeah, that worked. 🎉 Changed absolutely all
implementation
to
api
. I used
api
before but only for the other internal module and that didn't work.
b
Great! Api didn't work before because you weren't publishing the internal module
Api dependencies - transitive dependencies that gradle will download for the consumer Implementation dependencies - provided dependencies that gradle expects to already be on the classpath
r
I see! Yeah, probably you're right. then I used
api
before, I didn't publish it at that time. Thanks a lot! I owe a 🍺 🙂