Reputation: 23
I have to create Scala library which should be split in core module and module that contains additional features (something like zio-core and zio-streams). My idea is to put them in single github repo but under separate subprojects. How do I do that? Do I have to publish these modules separately? Can they have different versions?
Also, it's not clear to me if library user should only include "feature module" which would transitively include core module. Again, that would mean in ZIO case that I could only include zio-streams and have zio-core available to me.
Upvotes: 0
Views: 162
Reputation: 22850
How do I do that?
In the way you just described, having multiple sbt modules.
I have to publish these modules separately?
You usually have a single root
module that aggregates all the other modules like core
and extras
(which would depend on core
) and you publish root
which will transitively publish the others.
Can they have different versions?
AFAIK there is nothing preventing you to have different versions... but, I have never seen a library doing this, when the versions must not be the same they are in separate github repos (which makes sense, since at the end you will probably have an automated process that publishes all of them at once)
Also, it's not clear to me if library user should only include "feature module" which would transitively include core module.
If you follow the previous schema, the POM of extras
will mention core
thus users of your library can only import extras
and their build tools will transitively fetch core
However, whenever or not they want to do that (or that they consider that a best / bad practice) rather than also including core
explicitly is up to them. This topic is somewhat controversial, although most people agree that if you explicitly use something from a library then you must explicitly depend on it; see: https://github.com/cb372/sbt-explicit-dependencies
Upvotes: 2