I think the way we want to solve this in the future is making it simpler to define variants of a library (both on the producer and consumer side), so that you can model this at a higher level than “optional” and “exclude”. I.e. one problem with “optional” is that there might be multiple optional dependencies, but you need them all together if you take one of them. That gets lost in a simple “optional” flag.
Until we have that my recommendation would go in the other direction: Make them normal
implementation dependencies and let the consumer decide if she wants to exclude or not. Or even better - make it a separate module that is discovered through Java’s
ServiceLoader mechanism or similar.