https://kotlinlang.org logo
#library-development
Title
# library-development
g

George

08/17/2022, 4:24 PM
Hello folks, Im trying to publish a kotlin-jvm-only library which is dependent to an internally library of mine. When i publish it, i try to consume it in my demo-project but it asks for the jar of the internal module of mine. What are my options if lets say i cant publish directly at least the internal lib? Thanks in advance for any answers or help.
I was thinking if i could just add a typealias for every exposed public api of the internal lib, this would be enough? or it is a really bad-idea?
b

Big Chungus

08/17/2022, 5:20 PM
Your only option is to embed internal lib into your public lib jar, but then you still expose your internal code to the public
Recommended practice for these cases is to simply use private maven repo. You can get one for free via gh packages or jfrog artifactory
g

George

08/17/2022, 5:25 PM
hmm, ok thanks for the info 🙂
r

rnett

08/19/2022, 7:24 PM
You could obfuscate your private lib, too, and then use shadow to embed it in your public lib. Consumers of your public lib will have issues if it adds inaccessible transitive dependencies
g

George

08/20/2022, 1:58 PM
Hello @rnett, maybe you could give me an example of what do you mean by
obfuscate your private lib, too, and then use shadow to embed it in your public lib
. I can guess what you mean by
use shadow to embed
but im not sure what you mean by
obfuscate
, thanks in advance !. Also, about
inaccessible transitive dependencies
, i learned that the hard way 🙃. For now i publish them to a private repo like petuska recommend.
r

rnett

08/20/2022, 7:26 PM
What I meant about the private dependencies is that consumers of your public lib will also need access to that private repo, assuming your public lib depends on your private one without embedding it somehow. Try making an example project that consumes your private lib and see what you need to do to get it working. For the obfuscation and shadow: obfuscation is re-writing your code in a way that still works, but is essentially unreadable, for example with Proguard. Shadow is the Gradle plugin that's usually used to embed dependencies (the maven version is called Shade)
3 Views