Hi, how can I define a dependency to be only needed for my code to build but optional for the user ?
h
hfhbd
02/27/2022, 11:32 AM
compileOnly
v
Vampire
02/27/2022, 11:47 AM
Poor-mans solution
compileOnly
. But that is better suited for something like annotations that are really not necessary at usage time. An "optional" dependency is better modeled using feature variants. For Maven customers they will then land in scope
optional
. For Gradle consumers they can depend on the feature variant they need and get the proper dependency without the need to declare it manually while not using it themselves.
a
Ayfri
02/27/2022, 12:14 PM
Okay thanks, to explain a bit more, I'm doing a wrapper in Kotlin/JS about a JS library that have multiple optional modules, I guess I should split my library into multiple libraries with a main that imports the required ones, like how they do
h
hfhbd
02/27/2022, 12:17 PM
Yes, for functionality, I would use another module (don't know variants), like